Connect to CryoSPARC¶
In [1]:
%%bash
# find the licence id for your instance
cat /sw/cryosparc/cryosparc_worker/config.sh | grep -oP 'CRYOSPARC_LICENSE_ID="\K[^"]+'
[REDACTED]
In [2]:
from cryosparc.tools import CryoSPARC
cs = CryoSPARC(host="localhost",
base_port=39000,
license="[REDACTED]", # licence id above
email="participant@noreply.com",
password="Cryo-EMWorkshop2025"
)
assert cs.test_connection()
Connection succeeded to CryoSPARC command_core at http://localhost:39002 Connection succeeded to CryoSPARC command_vis at http://localhost:39003 Connection succeeded to CryoSPARC command_rtp at http://localhost:39005
Load particles from flex train¶
In [3]:
# fill out as appropriate for your project!
project = cs.find_project("P2")
workspace = project.find_workspace("W1")
job_flextrain = project.find_job("J20")
In [4]:
particle_dataset = job_flextrain.load_output("particles")
particle_dataset
# components_mode_0/value and components_mode_1/value are the Flex latents at the current checkpoint
# once the job is complete, this dataset will include all passed through information (ctf, alignments3D, etc.)
Out[4]:
| uid | components_mode_0/component | components_mode_0/value | components_mode_1/component | components_mode_1/value | |
|---|---|---|---|---|---|
| 0 | 1779700710537823949 | 0 | -0.5173333883285522 | 1 | 0.3893333375453949 |
| 1 | 9029280422963986132 | 0 | 0.8266666531562805 | 1 | -0.005333326291292906 |
| 2 | 5511921049727446425 | 0 | 0.5386666655540466 | 1 | 1.4346667528152466 |
| 3 | 18049292750063892067 | 0 | -0.9120000004768372 | 1 | -0.2720000147819519 |
| 4 | 10552935038128461132 | 0 | 0.06933334469795227 | 1 | -0.36800000071525574 |
| ... | ... | ... | ... | ... | ... |
| 137996 | 16003989330585177938 | 0 | 1.2640000581741333 | 1 | -0.24000000953674316 |
| 137997 | 7494929393788351034 | 0 | -0.42133334279060364 | 1 | 1.2106666564941406 |
| 137998 | 17203334619651482593 | 0 | -0.6666666865348816 | 1 | 0.4533333480358124 |
| 137999 | 7348860851528375692 | 0 | 0.2613333463668823 | 1 | -0.35733333230018616 |