CorrectIllumination Function Calculation; each or all?

Hi all,

Could anyone shed a light on how the CorrectIllumination function is calculated between ‘each’ and ‘all’?

I am understanding the function as:

  1. choosing ‘each’ means that the illumination function is only calculated based on one image that is being processed.
  2. choosing ‘all’ means that the illumination function is calculated based on all images in the project.

The reason I am asking this question is that whenever I choose ‘all’ to calculate the function, something strange happens.
The first image has no issues.
The second image has black spots that resemble where the objects were in the first image.
The third image has black spots that resemble where the objects were in both first and second images.
And it repeats throughout the list of images.
In this case, the objects exclusively mean cell bodies of neurons in my neuron images.

I do have a pipeline and the output images that show black spots in the post here:

If I am understanding the function correctly, I would want to calculate it based on all images to best eliminate the background in a data set.
However, these black spots force me to choose ‘each’ instead of ‘all’.

Any advice would be greatly appreciated.
Thank you!

Hi @citypalmtree,

The issue is that you are trying to do a CorrectIlluminationCalculate with the All Images option in the same pipeline as applying the correction. The way CellProfiler works is that each image is put through the pipeline one at a time so the so the image you want isn’t created until your final cycle of the pipeline.

What I think you want is to have your Calculate module then the SaveImages module then in a new pipeline do your CorrectIlluminationApply module with the saved image from the previous pipeline. Make sure, on your SaveImages module you need to have “When to Save” set to “Last Cycle”. This means that the image that’s created by the time you get to the final image will be the only one saved as that’s all your need.

If you scroll down on the CellProfiler examples page then you can see example pipelines and images to use them on as well as a written tutorial on this process that should help explain it more if the above is confusing

Hi @lmurphy,

Thank you very much for your response!
After reading your answer, I read the tutorial for the CorrectIllumination and I understand it now.
I should’ve been using Background/Subtract for my images, but I have been using Regular/Divide.
And I am saving the function in the last cycle of a pipeline and using that image at a new pipeline.
Thank you.

I have one more question about the illumination function if you don’t mind.
As you can see in the images below, the black spots present in the images even though I correctly calculate and apply the function (i.e. calculate the function in one pipeline as saving at the last cycle, and apply the function in another pipeline).
The spots only disappear when I increase the block size (from 5 to 32).
And I am not sure whether it’s because I have been focusing on the block spots too much, but I still see some speckles of abnormal dark spots throughout the image with block size=32.

I am understanding the block size as that the size of the imaginary square that solely covers the background and as large as possible.
Is that correct?
Although I only have 5 neurons in this image, other images in the set have more than 15 neurons and the background is hardly visible.
If I were to more effectively use CellProfiler’s CorrectIllumination function, should I focus on using images that have objects as evenly as possible?

I am just trying to understand whether I am doing everything correctly in CellProfiler but the issue lies within the data set or I am missing something in CP.

Any advice would be greatly appreciated!!
Thank you.

Here is my pipeline:
pipeline_issue_with_black_spots.cppipe (10.2 KB)

Here is a sample image with block size=5 with block spots:

And here are the images with block size=32 with very faint circling block spots: