ciampluca / counting_perineuronal_nets

Apache License 2.0
9 stars 1 forks source link

Question regarding PNN segmentation #8

Open rsnelson18 opened 1 month ago

rsnelson18 commented 1 month ago

Hello, I am a researcher at looking histologically at PV neurons, PNNs (both WFA+ and ACAN+) and the relationship between them in Alzheimer's disease pathology.

I would like to segment the background/foreground of each individual PNN to quantify its size and intensity as you have done in your paper, as this obviously adds significant depth to the analysis. I see in your paper that you used "random forest pixel classifier implemented with the MATLAB Treebagger class with the support of additional custom MATLAB functions". I have experience in R and python, but not MATLAB.

Do you have any advice to conduct this analysis for someone that is new to MATLAB and and random forest classification?

Any help super appreciated!! Thanks :)

P.S. I really admire the elegance and thoroughness of your approach in this paper!

LeonardoLupori commented 1 month ago

Hi!

Thanks a lot for writing us. I'm happy to try to help. The segmentation was done by @valtot and implemented in MATLAB just for the convenience of integration with other pipelines already existing in the lab but it should be relatively easy to translate to different languages or also to implement differently (the problem is relatively simple and I'm sure there are even easier strategies one can use).

The general idea is to take small images (~80x80 pixels) around all the XY locations of cells/PNNs detected. Then segment these images and compute the mean fluorescence of pixels belonging to the object.

You would need: 1- A ground truth dataset, so a certain number of small images that you segmented yourself. You can use part of this dataset to train and part to validate the segmentation. 2- For each pixel, you need to extract some features. The function that we used for feature extraction is here 3- Train a binary classifier to classify pixel by pixel in foreground/background

I think the final MATLAB implementation that we used is here

If you have experience in Python, though, I think you can scratch the MATLAB implementation and just try to do something similar directly in Python.

Some alternatives that come to mind:

  1. A tool that you might want to check out is Ilastik. It's a Random Forest classifier that you can interactively train in a GUI. Once you have a trained model that you are happy with You should be able to use the APIs (https://www.ilastik.org/documentation/basics/headless.html) to programmatically predict new images in your analysis script.

  2. You can try to merge the detection and segmentation steps by using Cellpose. This also has a GUI. I'm sure it will work well with minimal training for PV cells, but you might need to train quite a bit for PNNs since they come in so many different shapes and flavors

  3. If you want to do all from scratch I would suggest to start from here and try to implement something similar to what we did in MATLAB, using roughly the same pixel features.

Let us know if this is helpful and of course if you have any other doubts feel free to ask! I'm very happy to help

best, Leo