Hippocampal neuron quantification

Hello everyone,
I am trying to quantify the number of neurons in different subregions of the hippocampus which is stained by NeuN. I encountered two problems: 1. the contrast is not consistent in my image so the CellProfiler is picking up some background stuffs that are not neurons (like below). 2. I want to count how many neurons in a confined area, not the whole image, how can I draw that out? I tried using ‘IdentifyObjectsManually’ along with ‘IdentifyPrimaryObjects’ but it is not working. Thank you!
image
image
I am attaching some of my original images:

[orinigal images removed on request]

The pipelines I am using: NeuN IHC trial 8.12.2019.cppipe (22.4 KB)

Hi, Open your image in ImageJ and outline the region you want:

convert that outline to a “mask”:

save it:

then, in the CP pipeline import it along with the neun label image:

use the MaskImage module to “mask” the image with the NeuN label:

now do the segmentation for NeuN objects on the masked image:

and CP will confine the segmentation to the region specified in the mask.

1 Like

Hi there,
Thank you so much for the answer! I have tried this way with the mask, however, the selected region appears black as a mask
Then in CP, it says “Error while processing UnmixColors: Image must be RGB, but it was grayscale”. When delete the UnmixColors module, it is measuring everything other than my selected region. Maybe it should be invert selection?865_HL_Mask.tif (1.3 MB)
Do you know how to solve this? I attached my pipelines.NeuN IHC trial 9.2.2019.cppipe (23.3 KB)
Thank you.

[original image removed on request]

Hi there,
Thank you so much for the answer! I have tried this way with the mask, however, the selected region appears black as a mask
Then in CP, it says “Error while processing UnmixColors: Image must be RGB, but it was grayscale”. When delete the UnmixColors module, it is measuring everything other than my selected region. Maybe it should be invert selection?865_HL_Mask.tif (1.3 MB)
Do you know how to solve this? I attached my pipelines.NeuN IHC trial 9.2.2019.cppipe (23.3 KB)
Thank you.

make sure that both the mask and the image you import in CP are the same image format. I made a mask as outlined above, but I changed it to an RGB image before I saved it as a .tif:

then I changed the .jpg example to a .tif as well and loaded both of those into your pipeline and it worked:

Thank you so much for answering!! May I ask why my background is white and selection appears black when I generate the mask? Yours is the opposite so the background is black.

Hmm, not sure. My comment about the ImageJ > options > colors didn’t change what happens with the mask. I opened your image, made a selection with the freehand tool and created a mask from the selection using the steps outlined above and I get a white selection on black background:

The mask you show is an RGB where mine is an 8-bit. How did your mask from the ImageJ ‘create mask’ function turn into an RGB?

Hi, I inverted the image and now it is black on the background. I changed the mask to RGB before saving it. Thank you.

Hi Johnmc,
I converted the mask into RGB before saving as tif, but the CP still has error massage saying:
image
Do you know how to fix this?Here are the pipeline i used.
NeuN IHC trial 9.2.2019.cppipe (23.3 KB)
Thank you very much.

Did you try removing Unmix Colors module? And ensuring downstream modules use the right image thereafter?

It sounds like you don’t need it anymore because your image is already single channel/grayscale.

Hi Anne,
Yes, I tried to drop Unmix Color, but it is not picking up the cells somehow (please see the picture). I tried adjust some parameters in the ‘IdentifyPrimaryObjects’ module but is not working. Do you know how to solve this?
image
Thank you very much.

Hi Fancy,

I tried your pipeline. There are following things which you might have to do,

  1. While loading your RGB image in NameAndTypes, load it as color image. Then you may not have problem in UnmixColors
  2. Maskimage module is not required since you would load your mask as binary image.
  3. After your primaryobject you can use Maskobjects to get only neurons in your region of interest.
    Here is the screen shot of what you would need i guess,
    Your primary object
    Neurons_primary_object.pdf (878.3 KB)
    your maskobjectsmasked_neurons.pdf (285.8 KB)

These are the sample images & pipelines I tried & modified,
NeuN IHC trial 9.2.2019.cpproj (1011.4 KB)

[one original image removed per request of the topic owner]

865_HL_Mask.tif (1.3 MB)

Hope this helps.

Regards,
Lakshmi
Fujfilm Wako Automation (Consultant)
www.wakoautomation.com

Hi Fancy,

Another better solution is as follows,
You need not use another software to get the mask. One of your earlier pipeline posted in this thread which has IdentifyobjectsManually module, I had modified. Using your manually identify object as a mask in the output of primary object using “Maskobject” module. This is how it looks,

One more modified pipeline,
NeuN IHC trial_single.cpproj (801.9 KB)

Regards,
Lakshmi
Fujfilm Wako Automation (Consultant)
www.wakoautomation.com

Hi Laskshmi,
Thank you so much for the brilliant solution! I gave it a try and here is what I got: the selected region shows colorful cells while some background cells are also lightened up. I am wondering if they are also counted? Is the background (circled out in red) automatically teased out during counting?

NeuN IHC trial 9.24.2019.cppipe (23.3 KB)
I am also attaching the pipeline used.
Thank you very much!

Hi Fancy,
Yes the background cells will also be counted as per your current pipeline. You can take the measurements in only the selected regions by chosing the “MaskedNeurons” object in MeasureObjectSizeShape module instead of Neurons.
Just to make it clear,

  1. you are first define Region of interest (manual )and having it as a mask.
  2. Then you identify the neurons as a primary object from your complete image.
  3. Next step you are applying your mask in the identified neurons.

Hope this helps.

Regards,
Lakshmi
Fujifilm Wako Automation (Consultant)
www.wakoautomation.com

Hi Lakshmi,
Thank you for the clarification. My goal is to count how many cells are in the ROI.
I changed it to ‘MaskedNeurons’ in MeasureObjectSizeShape module but the cell counting is still the same with background cells; I think this module only measure the size and shape but not count the cells.
Is there a way to count cells in the manually-defined ROI?
Thank you.

Hi Lalshmi,
I think I have the cell count: in the output cdv file (MyExpt_Image.csv), it has “Count_MaskedNeurons”. It should be the number of the cell in masked region, right?
Thank you.

Hi Lakshmi,
I have two small questions which really baffles me.

  1. for the clumped object, I tried to adjust several parameters in IdentifyPrimaryObject module but is not working very well (please see pic). Do you have some suggestions?
    image
  2. when manually draw ROI, the color of the pen is almost invisible, thus it is very hard to draw accurately. Do you know how to adjust the pen color or other suggestion?
    Thank you very much.

Hi Fancy,

Yes. you are right. “Count_maskedNeurons” is the the count you need.

Regards,
Lakshmi
Fujifilm Wako Automation (Consultant)
www.wakoautomation.com

Hi Fancy,

Answers to your questions,

  1. The pipeline I shared is rough estimate of what you require based on your query. You might have to played around with the parameters to work accurately for your images. Firstly, if there is an object which shows with pink boundary it means that, because these selected pixels fall under your threshold limit but just may fail just because of your size criteria. So you might have to adjust the size cutoff to get selected as object (green boundary). Secondly, regarding declumping, you might have to adjust the corresponding parameters like smoothning, local maxima. Attached is the screen of the primary object module from your pipeline. Notice the unlined parameters, which you might have to play around for declumping & size. The values in the screenshot just works for the above sample image, but have to ensure these values works for the complete image.

  2. I am not sure about changing the color.

Regards,
Lakshmi
Fujifilm Wako Automation (Consultant)
www.wakoautomation.com