Error loading coloured czi images


I have been using CellProfiler to analyse gray scale images. We recently obtained a colour camera and I would like to analyse the beta Gal images. However, I can’t even get CP to read in the czi file. It throws the following error:

Traceback (most recent call last):
File “/home/anja/CellProfiler/cellprofiler/gui/”, line 1134, in callback
self.__on_do_something(event, setting)
File “/home/anja/CellProfiler/cellprofiler/gui/”, line 2064, in __on_do_something
File “/home/anja/CellProfiler/cellprofiler/”, line 1934, in on_event_fired
File “/home/anja/CellProfiler/cellprofiler/modules/”, line 483, in
lambda : self.do_update_metadata(group),doc = “”"
File “/home/anja/CellProfiler/cellprofiler/modules/”, line 863, in do_update_metadata
metadata = get_omexml_metadata(url = url)
File “/usr/local/lib/python2.7/dist-packages/bioformats/”, line 1025, in get_omexml_metadata
xml = jutil.run_script(script, dict(path=rdr.path, reader = rdr.rdr))
File “/usr/local/lib/python2.7/dist-packages/javabridge/”, line 392, in run_script
raise JavaException(call(e.throwable, “unwrap”, “()Ljava/lang/Object;”))
JavaException: Invalid C index: 1/1

Any suggestions? The metadata should be saved exactly the same way as with the gray-scaled images
Here is an example file: betaGal

Cheers, Anja


Hello, it appears to work on CP 3.0.
Have you tried maybe reloading the images or starting the pipeline from scratch? errorloading.cpproj (401.4 KB)


Huh, I’m having a different experience than @vchernys; I can’t open it in CP 2.2, 3.0, or FIJI, and all report the same error you are having. Based on that I’d think it’s an issue with the file itself, not the programs, but I’m concerned by the user-to-user variation…


It is odd. You can try to open it using ImageJ and saving it in another format (tiff ?).


Hi, the Zeiss czi file format is quite versatile and tricky in my experience, there where lots of fixes on reading it in the recent releases of Bio-formats.

The image opens fine in FIJI using bio-formats 5.6, which recognizes 20 series (different field of views I guess)
inside this czi. Each image is recognized to have 6 channels.

@anou85 I suppose the acquisition setup on the microscope was 2 channels, first DAPI, then transmitted light (phase contrast). Recorded with a color camera, this results in two R+G+B images, which would explain the 6 channels.

Here, DAPI is contained in the “blue” channel of the first RGB, i.e. channel 3/6. The first two channels do not contain anything.

The last three channels then make most sense transformed to a proper RGB and contain the Brigthfield image including any color information.

From you error message,I think that CP2.2 uses an older version of Bio-formats that does not include the fix for reading this specific *czi :

It only sees one channel when in fact there are 6.

new versions of CP (like CP3) likely use a newer version Bio-formats and thus work as @vchernys posted.

What you could do as a workaround is to

  • test the nigthly build of CP, or
  • write a ImageJ-macro that’s separates the channels before loading it into CP, or
  • maybe write a csv file that specifies the metadata correctly. This could be imported in CPs metadata module instead of “extract from image file headers”


sorry for the late reply, I’ve been away on holiday.
Thank you very much for the suggestions. I’ve tried to install the nightly version on Ubuntu 16.04 LTS (cellprofiler 3.0.0rc2 from the git hub site). It installs fine, saying that all the requirements are already satisfied. But when I try to run it, I’m getting:
system > cellprofiler
Traceback (most recent call last):
File “/home/anja/.local/bin/cellprofiler”, line 5, in
from pkg_resources import load_entry_point
File “/usr/lib/python2.7/dist-packages/pkg_resources/”, line 2927, in
File “/usr/lib/python2.7/dist-packages/pkg_resources/”, line 2913, in _call_aside
f(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/pkg_resources/”, line 2940, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File “/usr/lib/python2.7/dist-packages/pkg_resources/”, line 635, in _build_master
File “/usr/lib/python2.7/dist-packages/pkg_resources/”, line 943, in require
needed = self.resolve(parse_requirements(requirements))
File “/usr/lib/python2.7/dist-packages/pkg_resources/”, line 829, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘MySQL-python’ distribution was not found and is required by CellProfiler

However, the distribution is already installed:

sudo pip install mysql-python
Requirement already satisfied: mysql-python in /home/anja/.local/lib/python2.7/site-packages

The installation from source worked fine for version 2.2.0. What am I missing?

@vchernys unfortunately it didn’t work with your pipeline either

@CellKai I’m usually importing metadata from a csv, as CP wouldn’t otherwise be able to recognise the setup of the experiment. My file looks like this:
Series Well Site
0 A1 1
1 A1 2
2 A1 3
20 A2 1
21 A2 2

with 20 images per well. Would there be a better setup?

Cheers, Anja


Hi Anja,
I’ve made a GitHub issue for you here; please keep an eye on that as our engineers may have questions about package versions, what commit you’re using, etc.

I’ll also say though that as we push to our CP 3.0 release a lot of major changes are being pushed daily, so please try again to pull and run CP as the issue may have already been fixed!


Hi Beth,

I couldn’t get CP 3.0 running (diverse error messages), so I’ve tried to use CP 2.2 with the tiff files. I’m attempting to count the cells with beta gal staining. I’ve used the unmix module to identify the secondary objects, but it’s not quite working… any suggestions?
Below is my pipeline and a sample image

bgal.cppipe (8.6 KB)

Cheers, Anja


Can you explain more specifically what you want? Literally just count the ones with BetaGal?

In that case eventually you’re going to want to eventually use either MaskObjects (my recommendation), FilterObjects, or ClassifyObjects- IDSecondary is just going to draw a “cell” area around the nucleus. To use FilterObjects or ClassifyObjects you’d make some sort of a measurement first on the nuclei (like intensity in the BetaGal channel) and then make a Filter/Classification on one or more of those measurements; to use MaskObjects you’d threshold the BetaGal image with ApplyThreshold to try to find the BetaGal positive/negative areas then use MaskObjects to keep only nuclei that colocalize with the positive areas- I like this better because I personally feel it handles the best when there’s variability across images but YMMV. I’d recommend reading the help on all the modules, particularly if your goal is something more subtle than counting BGal positive/negative.

No matter what though

  1. I think you need to do SOME sort of image processing to improve your “BetaGal” channel to get high-quality results- there are a few different things you could try (background subtraction, illumination correction, etc), but probably the easiest IF your lighting conditions are pretty similar across the board is adding a second channel to UnmixColors that it can contrast the Betagal color against- most of your image is sort of a blue-purple, so probably a stain in that part of the color spectrum. That’ll allow UnmixColors to really separate the stained from unstained areas. This is what it originally looked like with only one stain set in UnmixColors compared to when I added a second “Hematoxylin” stain to your image:

As I said though, how well that UnmixColors trick works across many images will almost certainly depend on the consistency of your lighting conditions (if sometimes your background looked more red or yellow than purple, say), so if they’re quite variable you may need to try some of the other processing steps I mentioned to get your cleaned-up BetaGal channel.

  1. Since the BetaGal looks in at least some cases cytoplasmic rather than nuclear, you may want to add an ExpandOrShrinkObjects module to expand your nuclei by a few pixels to obtain the best results in either measuring them in the BetaGal channel or masking them with a thresholded BetaGal channel.

Good luck!


Hi Beth,

thank you very much for your quick and extensive answer. Sorry if the goal didn’t come across so clearly. We actually want to count the cases where there is staining in the cytoplasma, but only if there is a nucleus nearby. This is why I thought I could use IDsecondary to find the stained cytoplasma… But maybe it will work if I expand the nuclei by enough pixel…? I’ve added a second strain as you suggested, and will give it a go.