Managing a CryoSPARC Live Session from the CLI (v5.0+)
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 on this page are correct for CryoSPARC v5.0+.
Setup
Management of CryoSPARC Live uses the same CryoSPARC command line mechanics described in the cryosparcm cli reference. That page also describes three ways to access the CryoSPARC command line interface: i) cryosparcm cli "COMMAND", ii) cryosparcm icli for an interactive CryoSPARC shell, or iii) using cryosparc-tools in a Python script.
In addition, you can write a script that imports the necessary Python API client directly from CryoSPARC. To do so, first use the following code at the start of your script, for example in a file called automate_cryosparc_live.py:
from client.api_client import APIClient
from core import core
core.startup()
db = core.db
gfs = core.gridfs
api = APIClient(
core.settings.api_base_url,
auth=core.settings.api_admin_auth,
headers={"license-id": core.settings.license_id},
)
# ...Then, use CryoSPARC’s provided python environment to execute your script:
The remainder of this guide will assume that you are writing code within a script like the above where the api object is defined, or else using the interactive python shell provided by CryoSPARC (i.e., cryosparcm icli) where the api object is predefined.
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.
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
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
Set the session’s compute configuration
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).
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
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.
Start Streaming 2D Classification
Start Ab-Initio Reconstruction
Create a new initial volume
Use an existing job’s volume output as the initial volume
Start Streaming Homogeneous Refinement
Note that an initial volume must be set for the session before starting Streaming Homogeneous Refinement.
Stop and clear the CryoSPARC Live Session
Pause the entire CryoSPARC Live Session
Clear the CryoSPARC Live Session (Note that this will delete the session progress and all results, rendering exposure and particle jobs unusable)
Export Exposures and Particles from the CryoSPARC Live Session
It is possible to export exposures and particles from a CryoSPARC Live Session for use in other
Export all exposures from the session
Export all particles from the session
Graceful Pause
New in v5.0+, CryoSPARC Live now has the ability to automatically pause a session once it is idle for a certain period of time.
It can be configured programmatically as follows:
Delayed start run configuration
New in v5.0+, CryoSPARC Live now has the abitity to wait until exposures are available on the filesystem before starting the session. This prevents the session from using hardware resources or license tokens until raw movie files are available for processing. It can be configured as follows:
Parameters
The full list of session parameters that can be modified can be obtained with:
Last updated