3D Classification - error converting the particles to a .star?

Hi, when the 3D classification finishes, I have a file of the form, for example cryosparc_P1_J100_00010_particles.cs and others of the form cryosparc_P1_J100_classXXXXX_00010_particles.cs for each of the generated classes. As in other jobs (heterogeneous refinement), in the cryosparc_P1_J100_00010_particles.cs file are all the particles where the class to which each one belongs is specified. In my case, I generate the classes from this file and now I even have my doubts if I am doing it correctly.
In 3D classification, when converting to .star, all particles belong to the same class. My question is: Is it a CS bug or is it a pyem library bug? It would be convenient if this file had that information so as not to have to go through each .cs of each class.

Hi @cfonseca,

After some investigation, this is indeed a bug in the 3D classification outputs. Apologies! We’ll get a fix out in the next patch. For now, you can fix this with the following cryosparcm cli script (you can launch an icli session in a terminal window by executing cryosparcm icli):

from cryosparc_compute import dataset

#Import the CS file
particle_ds = dataset.Dataset()
particle_ds.from_file('/path/to/cryosparc_P1_J100_00010_particles.cs')

#Find all keys that look like alignments_class3D_X/class
alignment_keys = [key for key in particle_ds.fields() if (key.startswith('alignments_class3D_') and key.endswith('class'))]

#Update class keys to appropriate integers
for c_i, key in enumerate(alignment_keys):
    particle_ds.data[key] = c_i

#Save
particle_ds.to_file('/path/to/cryosparc_P1_J100_00010_particles_fixedclasses.cs')

You should be able to now use this new fixed .cs file with csparc2star.py as expected.

Let me know if you run into any issues!
Valentin