Managing a CryoSPARC Live Session from the CLI

This guide details how to automate the creation, configuration and overall management of a CryoSPARC Live session in Python via the CryoSPARC API.

Overview

This guide details how to automate the creation, configuration and overall management of a CryoSPARC Live session in Python via the CryoSPARC API.

The instructions are valid for CryoSPARC versions from 3.3 through 4.6.

Setup

To run the following commands, you can use the built-in python interpreter provided by CryoSPARC by running cryosparcm icli.

You can also issue one-off calls directly to CryoSPARC by running cryosparcm cli "<function_name()>" or cryosparcm rtpcli “<function_name()>” for command_core and command_rtp functions, respectively.

This guide will use the interactive python shell provided by CryoSPARC to create a CryoSPARC Live Session. When you run cryosparcm icli, you will have access to the command_core API via cli, the command_rtp API via rtp, and the database via db.

Using a Script

You can also put these functions inside a bash script or a python script. To get access to the CryoSPARC API (cli and rtp) inside a python script, add the following lines to your script, e.g., called automate_cryosparc_live.py:

import os
from cryosparc_compute import client

host = os.environ['CRYOSPARC_MASTER_HOSTNAME']
command_core_port = int(os.environ['CRYOSPARC_COMMAND_CORE_PORT'])
command_rtp_port = int(os.environ['CRYOSPARC_COMMAND_RTP_PORT'])

cli = client.CommandClient(host=host, port=command_core_port)
rtp = client.CommandClient(host=host, port=command_rtp_port)

# ...

Use CryoSPARC’s provided python interpreter to execute your script (required):

Automate a CryoSPARC Live Session

Create A Project [Optional]

You will need a project to create your Live session. If you already have a project, you can skip this step.

  1. Get your CryoSPARC user ID using your CryoSPARC email address

  2. Create the project

    Note that CryoSPARC will create a folder for the project inside the project_container_dir path you specify named after the UID of the project created (e.g., P12).

    The definition of the project_description variable and the corresponding desc parameter are optional.

Create a CryoSPARC Live Session

  1. Get your CryoSPARC user ID using your CryoSPARC email address

  2. Create the CryoSPARC Live Session

    Note that the title and desc arguments are optional. project_uid can be defined explicitly for pre-existing projects, or by using the value returned by cli.create_empty_project(<..>)(see above).

Configure your CryoSPARC Live Session

  1. Set the session’s compute configuration

  2. Set the session’s exposure group parameters

    Note that the following lines change the exposure group parameters for the first exposure group (exp_group_id=1).

  3. Set the session’s processing parameters

    Note that the following parameters are required to be set before starting a session.

    To see the full list of parameters available to be set, see below.

Start the CryoSPARC Live Session

  1. Start the session

    If you’ve configured your session properly, CryoSPARC Live will start to find movies and process data. At this point, you can navigate to the user interface and watch as exposures are processed. The next step would be to start Streaming 2D Classification and Streaming Homogeneous Refinement. You can also use the user interface to manually pick particles and use the template picker to identify particle locations.

  2. Start Streaming 2D Classification

  3. Start Ab-Initio Reconstruction

    1. Create a new initial volume

    2. Use an existing job’s volume output as the initial volume

  4. Start Streaming Homogeneous Refinement

    Note that an initial volume must be set for the session before starting Streaming Homogeneous Refinement.

Stop the CryoSPARC Live Session

  1. Pause the entire CryoSPARC Live Session

  2. Clear the CryoSPARC Live Session

Export Exposures and Particles from the CryoSPARC Live Session

  1. Export all exposures from the session

  2. Export all particles from the session

Appendix

As of v3.3, these are the parameters you can set for a live session:

Last updated