High resolution image of 2D classification

Hi CS community

Is there a way to export 2D classification result at a higher resolution than the png or pdf files provided by 2D classification job? I would like to export a publication quality 2D classification result from Select 2D Classes job, however the images are lower resolution than the actual pixel size of the particles.

Thank you.

Hi @alburse,

You can use the plotting function used by the 2D Classification job itself. Check out the function parameters for more info (found in cryosparc2_worker/cryosparc2_compute/plotutils.py)

The .mrc file is from the “particles_selected” output of the Select 2D job:


Thank you, I will try this.

I tried this but could not get it to work. I guess CRYOSPARC_ROOT_DIR is not right, I tried the master folder and worker too. I found this link but not sure if this solution will effect other operations.

Thank you

import os
from cryosparc2_compute import plotutil
from cryosparc2_compute.blobio import mrc

KeyErrorTraceback (most recent call last)
in ()
1 import os
----> 2 os.chdir(os.environ[’/share/PI/yiorgo/alpay/modules/alpaysprograms/cryosparc/2.9’])
3 from cryosparc2_compute import plotutil
4 from cryosparc2_compute.blobio import mrc

/share/software/user/open/python/2.7.13/lib/python2.7/UserDict.pyc in getitem(self, key)
38 if hasattr(self.class, “missing”):
39 return self.class.missing(self, key)
—> 40 raise KeyError(key)
41 def setitem(self, key, item): self.data[key] = item
42 def delitem(self, key): del self.data[key]

KeyError: ‘/share/PI/yiorgo/alpay/modules/alpaysprograms/cryosparc/2.9’

Check your system environment that if “CRYOSPARC_ROOT_DIR” is set


You may set it by

echo “export CRYOSPARC_ROOT_DIR=/path/to/cryosparc/root/dir” >> ~/.bashrc && . ~/.bashrc

Thank you. I gave the directory (CRYOSPARC_RROT_DIR) directly to Jupyter notebook and it did not work. System environment worked. Thank you

Hi sarulthasan,

I’m also struggling with this. Unfortuantely, I don’t really understand what you meant. Where should I use this plotting function?

Also, is there a reason why this is relatively difficult, compared to a downloading or displaying a 3d map? It seems to me 2D classes are an important (intermediate) result?

Many thanks,

Hi Maarten

@stephan showed an example on Jupyter Notebook. You can start a Jupyter notebook and use it as a python environment. I believe cryosparc itself has the jupyter notebook setup and has all the necessary python libraries but I could not find how to start Jupyter notebook from cryosparc environment. Therefore I used my own Jupyter notebook. You will need at least the following python 2.7 libraries installed.
py-numpy py-scipy py-numba py-matplotlib pyFFTW
and CRYOSPARC_ROOT_DIR defined in your bashrc or bash_profile or equivalent file for other shells.
Below worked for me on my bash_profile file.
export CRYOSPARC_ROOT_DIR="/directory-to-cryosparc/cryosparc/2.11/cryosparc2_worker"

If @stephan tells us how to use the jupyter notebook from cryosparc that would be great.
More importantly, I could not really find what parameter to change on the plotutils.py to get the native resolution on the 2D-class averages. If you find it, please let me know.

1 Like

Hi @maarten.tuijtel,

You’re right- we’re planning on adding a “download images” button that will output a compressed folder of individual class images at full resolution. I’ll keep you updated on this!


Hi @alburse,

I believe the parameter is figsize_each.

Hi @maarten.tuijtel,

I was wondering if there are any updates on this. Is there a simple way to save higher resolution images of 2D class averages yet?



1 Like

Dear @stephan,

I was wondering if there an update on this topic or do I still need to use the plotting function to obtain the high resolution images.

EDIT: Trying using the aforementioned procedure using Jupyter Notebook but stuck on this error:
" ModuleNotFoundError: No module named ‘finitesum’ " I am not sure which module this function belongs to. A Google search also did not help narrow it down. I made sure to install all the other required modules (Numpy, Scipy… ect).

Any suggestions?

Hi @Omid,

For the time being, you still need to use the plotting function.
A better method to use the python kernel would be through the interactive python shell provided by cryoSPARC (cryosparcm icli).
For more information on how to use this, and how to load .cs files, read our “Manipulating .cs Files” Tutorial here.

1 Like

Thanks @stephan for your quick reply.
I’ll give this a go today.


I have two alternative solutions.

Solution 1:
I don’t know if I’d call it simple, but… I use EMAN2 to display images. EMAN was one of the original 3D reconstruction tools. I don’t use it for that anymore, but still find it to have a very useful set of tools. I can run it from my Mac, so that’s handy too.

  1. Install EMAN2: https://blake.bcm.edu/emanwiki/EMAN2/Install
  2. Go to the cryoSPARC project folder and the job folder for the 2D class averages you want. You should see a file that looks like this: cryospac_P##_J##_020_class_averages.mrc. That’s the file you need to display. Download or copy that file to your local computer (or wherever you installed EMAN2).
  3. Run this EMAN command: e2proc3d.py inputFile.mrc outputFile.mrcs. This converts the file from .mrc (which will be understood as a 3D volume) to a .mrcs (which will be understood as a stack of 2D images.
  4. Then to display the image, run this command: e2display.py outFile.mrcs.
  5. When the image displays, you can middle click to get a popup window that allows you to adjust the magnfication, which you should set to 1, and the brightness, contrast, and gamma, which you can adjust how you like to make the averages look pretty. You can resize the image window to make it however many column/rows you want it to be.
  6. The crazy part, is that you then need to take a screen shot of that image. That’s the only way to save. But if the magnification = 1, then everything is ok, and the image will have the same number of pixels as the actual reconstruction.

Solution 2:

  1. Install Fiji: https://imagej.net/Fiji/Downloads. Fiji is just a version of ImageJ with the necessary plugins already added. The advantage is that it’s a point and click installation and usage. It will open mrc files automatically. You can save them in any format you like. The disadvantage is that it opens them as a stack, so you get one class average at a time. If want to tile them, the way you normally view 2D class averages, you will have to tile them yourself in some other program.



Dear @rj.edwards,

Thank you for this suggestion. I already had EMAN2 installed so it was really easy to do. Really appreciate the quick tip :slight_smile:


Hi @rj.edwards - although the manuscript I wanted this for has now been published, I will definitely give this a go for the next one :wink:
Many thanks