Stacking output images


I am using: CompiledCellProfilerXP325811Bugfix, working on Windows XP 32

I’m trying to count segmented objects over multiple planes. Each object may show up in multiple planes, but I only want to count it once.

My upstream pipeline PIPELINE#1 generates product images called “GrayObjects”. I have developed a pipeline to stack the gray segmented images into a single image and then to resegment this final image at the end.

I have attached a pipeline PIPELINE#2 that works well for a set of 8 images. I can refer specifically to the GrayObjects images 1-8. That would be OK if I wanted to do only one set at a time. But if I want to use the upstream pipeline (that created the output files) to analyze multiple stacks of 8 I get into trouble. For example, if I analyze 4 stacks, I will have 32 output GrayObjects images, numbered 1-32. that doesn’t work in this pipeline.

I can think of a couple of approaches:

  1. If I run the two pipelines in series using the “Run Multiple Pipelines” command, it runs all 32 images in PIPELINE#1 and then switches over to PIPELINE#2. I wouldn’t have the problem if it switched back and forth between PIPELINE#1 and PIPELINE#2 for each set of 8. There must be a way to do this, but I don’t know it.

  2. My Stack_Tracking pipeline is cumbersome Stack_tracking_PIPE_8_planes.mat. It requires me to load the 8 files in two steps, because I can only load 4 specific files at a time, and then to name specific images for each step. If instead of working with specific files (GrayObjects 1-8) I were able to add the images as a group of 8 and ratchet down the list for each subsequent step of the imagemath module. I have done this with MetaExpress, using 0, +1, +2 to tell it to compare the current plane (0) to the next plane in the stack (+1), etc. Does this make sense?

a. Is there any way to do this in CellProfiler?

b. How could I do it in groups of 8 and start a new group when I reach the 9th in the series.

Any ideas?



Stack_tracking_PIPE_8_planes.mat (1.3 KB)
PIPE_Count&Track.mat (1.68 KB)


Hi Jan,

Can you post your z-stack again? I don’t see the images. I’m pretty sure I help you out: In the second pipeline, you load each of your images individually, then use ImageMath to make the projection. Usually with z-stacks, we load all the images together as one ‘image’ and make the projection from that one stack. Unfortunately in the most recent release of CellProfiler, the maximum projection didn’t make it in- which is what it appears you’re trying to do by adding all the images- so you can only make an average projection. But if I see how your images are organized I may be able to figure something out.



Hi Kate,

I didn’t post a stk file in my earliuer post. I posted a single image because I didn’t think that I could work with stk files in CP. I just tried to upload the whole stack, but I got an error message saying the file was too large.

I will load 8 individual files. I will have to do it in 2 or 3 posts since I can’t load more than 3 at once.

Assuming that I can get the whole stack to load, will the output also be in the form of a stack that can be read directly by PIPELINE#2?

As I said in my earlier post, PIPELINE#2 is cumbersome. If I could load the whole stack, there is probably a better way to do combine the images, (average, sum or subtracting plane2 from plane1 (and so on) and only adding in the new pixels). But once we solve the first issue, I can play around with that to see which gives the most biologically accurate results.

Another possibility would be to combine it all into a single pipeline, but TrackObjects and Export to Excel don’t work well together in CompiledCellProfilerXP325811Bugfix.

OK. I have attached 3 planes. I’ll attach the rest in subsequent posts.These are 16 bit tif tiles. They will open and work in CompiledCellProfilerXP325811Bugfix, but they don’t necessarily open in PhotoshopCS2. Let me know if you need me to send some other files.

Thanks for everything. If you think it would be easier, feel free to call. My number is on the registration. Late morning or later is usually better.



I am attaching planes 4-6 (see message above)


I’m attaching planes 7 and 8.


Hi Jan,

The latest version of CellProfiler includes the LoadImageDirectory module. If you images were organized like this:
Folder1> 8 tif images comprising one stack where you’d like to measure the objects only once
Folder2> 8 tif images
Folder3> 8 tif images

this pipeline should do the trick. You default image folder should be the level above the folders containing all your images, and in LoadImageDirectory, the ‘text the folders have in common’ in this example would be ‘Folder’. In the example above, you would get 3 cycles total, not 24 because the images in each folder get made into a projection. You can either choose to make a maximum or average projection, but i think a maximum projection is probably what you’re looking for. My guess is you really only care about the brightest spots, so I also added a SmoothOrEnhance module to ‘enhance bright speckles’ (you can take this out if you don’t think it’s helping). I also had to play around a bit with the threshold in IdPrimAuto to get the segmentation accurate; in your earlier pipelines it looks like you may have filtered the objects, which also works. Let me know if this is what you were looking for as far as being able to process your images all in one pipeline!
StackPIPE.mat (818 Bytes)


Thanks Kate. I’m just now getting a chance to try it out. I’ll let you know how it goes. Thank you for taking the time to figure this out!



Hi Kate,

I’m excited about the potential of the new LoadImageDirectory module, but I’ve been working at it for days and I just can’t get it to work. I am having a number of technical problems with the LoadImageDirectory and MakeProjection modules. Please check out my posts on SaveImages and LoadImageDirectory in Bugs.

The series questions in this Post, however, is related to this ongoing Post.

My understanding of this module is that you load a series images from separate z stacks into separate folders which can be analyzed sequentially to make a separate Projection from each stack. Is that correct? If so, I could make projections from separate experiments for comparison in subsequent pipelines (i.e., counting organelles, as above). I could also use it to make a projection from each time point of a time lapse experiment and string it into an avi file movie.

Before spending any more time on it, I just want to verify a couple of points that were confusing in the module help section, in order to decide if this is the right application for my needs:

  1. Please clarify whether this module makes a separate projection of the set of images within each folder as described above, or a projection from the image at the same position in each folder (i.e., z07). That configuration, for example, would give me a picture of how an organelle or other structure might have traveled across the plate during the time period within a single plane, z07. That might be helpful for some applications, but it’s not what I am looking for. I also want to make sure that by asking the program to Analyze all subfolders, it is not making a single projection from all folders combined.

  2. It seems as if this LoadImageDirectory module might have some other functions beyond making projections. Once you have loaded the directory, you should be able to draw on the directories to perform other pipelines on each folder in sequence. Is there a simple way to use this module to do this, or does this require Parallel or Cluster Computing? Perhaps you could point me in the right direction.

I’d appreciate any insight.

MaxProjectionStackPIPE_alt.mat (864 Bytes)
MaxProjectionStackPIPE.mat (723 Bytes)


Hi Jan,

  1. Yes, what LoadImageDirectory does is take ALL the images in a folder and project them into one image (either a max. or ave. projection). That’s actually all it does. It allows you to filter out some images that may have been out of focus, etc based on a ‘QCFlag’ (the settings at the bottom) but if you don’t want to use this feature you can simply ignore it and it won’t affect your analysis.

  2. Once you have projected all the images in Folder1, for example into Image1, you treat it like any other image. So you can identify organelles, measure their intensity and shape, etc, and then do the same for Folder2.

Check out my responses to your bug questions for more detailed technical information.