Export star file?

This is something that’s on our TODO list to be able to handle directly inside cryoSPARC. In the mean time, Daniel Asarnow (UCSF) wrote a python script that does this. See the csparc2star.py in https://github.com/asarnow/pyem Note that we’ve not reviewed or used this ourself so if you have any issues with it you’ll need to contact Daniel directly.

Thanks Marcus - I have tried this script but with no luck I’m afraid - it seems to be looking for a key, data_input_rel_path, which is not present in the csv. The key that is present instead is data_input_idx, which is an integer. My csv file was generated from a star referring to a single stack of all the particle images - am I correct in thinking that this field refers to the particle number in the stack? Or is it something else?


Yes the data_input_idx is the (zero based) index into the original star file you used to set up the dataset. data_input_rel_path would be set if the original star file had references multiple different mrc stacks.

Maybe it would be good to keep data_input_rel_path in there, even when it is constant? Would make it easier for star file conversion (because otherwise the stack name needs to be supplied separately).


Daniel has now kindly updated the script to take account of this situation:

“With the new version, the --data-path option is used to give the stack location, like:
csparc2star.py --data-path Particles/Micrographs/single_stack.mrcs cryosparc.csv output.star”



I used Daniel’s script and it works well. However, it seems the original cSPARC .csv files have 3 empty lines at the end, which need to be removed for script to work.



Hi All,

Daniel was very quick to respond and now the script accounts for such empty lines and doesn’t crash anymore. No need to fix the original .csv!



There is something wrong with the conversion script, the distribution of angles of the output star file fall into a vary narrow range. Does anyone know how to fix this? Thanks,


Hi @jcoleman Have you reported it to the author of the script, Daniel Asarnow? I noticed that continuing refinements from the resulting star file was unsuccessful, and I wonder if this is related to the issue you observe.


Yes, I have sent him a message. Will keep posted if it gets sorted it out.

Daniel has updated fix the script, it is working well for us. Maybe others can give it a try as well.

1 Like

Thanks @jcoleman I was just going to post to let everyone know that the script is now fixed to output correct angles.

Still getting the following error:
what am I doing wrong?

File “csparc2star.py”, line 7

SyntaxError: invalid syntax

I’ll need more information - the error message appears truncated.

Most likely however the download is incomplete or the Python version is not 2.7.

Please install following the directions in the project wiki.

I am trying to use the $ python csparc2star.py <cryosparc_exp000211_006.csv> (that is the metadata from the homogeneous refinement output). It gives me this error: -bash: syntax error near unexpected token `newline’
Am I doing something wrong?

Hi @aglape, thanks for the note. @DanielAsarnow and @apunjani may have some insight.

You don’t need to run the program with python, because it has a #! line already that calls env python2.7. The error you get indicates that bash is trying to interpret the command, not python. Perhaps, you have misinterpreted the money sign $ as part of the command. It’s just a symbol for the bash command prompt.

Hi Daniel and everyone,

I have been trying csparc2star.py. It runs fine, but when I use the resultant star file to re-extract particles in relion, I get images attached. What could be the problem?

Many thanks!

@zehre It seems your star file is still missing the particle coordinates and micrograph name. In this case, Relion tries to re-extract from the particle images. Relion always replicates the last column or row when images aren’t large enough to shift, so you get streaks.

Please follow the tutorial on my wiki page (in particular the “merge micrograph information” section) and let us know if it works.