Parcticle re-extraction from *.cs file

Hi,
I accidentally cleared my project, which also resulted in the removal of the particle extraction. Fortunately, my particle coordination file, ‘cryosparc_P7_P7_S8_live_particles.cs,’ was saved. Is there a way to recover my lost particles?
Thanks,
LZ

I do not have experience with cryosparc live, but in “regular” cryosparc, you could create a new particle extraction job and connect the original micrographs and “particles” from the old extraction job (these should contain the pick locations). This should recreate your lost particles. I am not sure if your old particle UIDs will be preserved though.

Hi @Ming99, you might be able to do this with a Python script that uses cryosparc-tools (for CryoSPARC v4.1+).

Install the latest version for the current CryoSPARC v4.3.0+ from the command line into a Python environment:

python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install cryosparc-tools

You may also substitute the last line with a version specifier. For example, if you have CryoSPARC v4.2.1, use this line:

pip install cryosparc-tools~=4.2.0

Then create a Python script called restore.py with the following contents (make the noted substitutions):

import sys
from cryosparc.tools import CryoSPARC
from cryosparc.dataset import Dataset

project = sys.argv[1]
workspace = sys.argv[2]
dset_path = sys.argv[3]

cs = CryoSPARC(
    # insert instance details and credentials here...
    license="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    host="localhost",
    base_port=39000,
    email="user@example.com",
    password="password123"
)

particles = Dataset.load(dset_path)
valid_slots = {"blob", "ctf", "location", "pick_stats", "motion", "alignments2D", "alignments3D"}
result = cs.save_external_result(
    project,
    workspace
    particles,
    type="particle", 
    name="particles",
    slots=[slot for slot in particles.prefixes() if slot in valid_slots]
    title="Recovered Particles"
)
print(result)

Then run it from the command line like this. Substitute the P# and W# with the project and workspace numbers where you’d like to save the dataset, and /path/to/... with the location of the retained .cs file:

python restore.py P# W# /path/to/cryosparc_P7_P7_S8_live_particles.cs

Let me know if you run into any trouble setting that up! You can also check out the full cryosparc-tools documentation here:
https://tools.cryosparc.com/intro.html

Edit: typo

3 Likes