Login  Register

Re: Counting spots within nuclei

Posted by Peter Haub on Aug 07, 2011; 4:29pm
URL: http://imagej.273.s1.nabble.com/Counting-spots-within-nuclei-tp3683546p3683549.html

ps: The cell ROIs can be created by thresholding the DAPI image and
utilizing the ParticleManager.

On 07.08.2011 18:25, Peter Haub wrote:

> Hi David,
>
> here is a possible solution.
> Copy the following code into a file named 'CountCellMaxi_.java',
> stored it in the IJ plugins folder and use the command 'Plugins /
> Compile and Run' to compile it to a class file.
> Now you can use it interactively or in a macro code.
> the Input has to be:
>     - Current image = signal image as 8bit grayscale
>     - Roi Manager with cell rois has to be open
> Modify the code according to your needs.
>
> Regards,
> Peter
>
>  /*********************************************
> import ij.IJ;
> import ij.ImagePlus;
> import ij.plugin.filter.MaximumFinder;
> import ij.plugin.filter.PlugInFilter;
> import ij.plugin.frame.RoiManager;
> import ij.process.ImageProcessor;
>
> /**
> Count the maxima in in individual cells.
>
> Input:
>     - Current image = signal image as 8bit grayscale
>     - Roi Manager with cell rois has to be open
>
> Output in log window:
>     - Image name
>     - Roi number and number of maxima
>
> Macro call:
>     run("CountCellMaxi ");
>
> Author: Peter Haub 08/2011
> **/
>
> public class CountCellMaxi_ implements PlugInFilter{
>
>     ImagePlus imp;
>     double tolerance = 10.0;
>     double threshold = 20.0;
>
>     public int setup(String arg, ImagePlus imp) {
>         this.imp = imp;
>         return DOES_ALL;
>     }
>
>     public void run(ImageProcessor ip) {
>
>         // check image
>         if (imp.getType() != ImagePlus.GRAY8){
>             IJ.log("8bit grayscale image required");
>             return;
>         }
>         // Check if Roi Manager is open
>         RoiManager roiM = RoiManager.getInstance();
>         if (roiM == null){
>             IJ.log(imp.getTitle() + ": No Roi's");
>             return;
>         }
>
>         IJ.log("Img: " + imp.getTitle());
>         MaximumFinder maxF = new MaximumFinder();
>         int idxMax = roiM.getCount();
>         for (int i=0; i<idxMax; i++){
>             roiM.select(i);
>             // find & count maxima per cell/roi
>             ImageProcessor ipFM = ip.duplicate();
>             ipFM = maxF.findMaxima(ip, tolerance, threshold, 0, false,
> false);
>             byte[] pFM = (byte[]) ipFM.getPixels();
>             int cnt = 0;
>             for (int n=0; n<pFM.length; n++)
>                 if (pFM[n] != 0) cnt++;
>             // log result
>             IJ.log("Cell/Roi: " + (i+1) + "   Nmax: " + cnt);
>         }
>     }
> }
> /**********************************************
>
> On 06.08.2011 13:26, David Knecht charter wrote:
>> I need some help with a project one of my users would like to do.  
>> They are doing medium throughput screening for nuclear segregation
>> defects.  The samples are stained and then a nuclear image (DAPI) and
>> a protein immunofluorescence image is collected.  In wild-type there
>> is one protein spot per nucleus.  In a mutant, there are multiple
>> spots per nucleus or none.  THere are 50-100 nuclei per image and
>> each image represents a putative mutant. We have used the Find
>> Maximum command to effectively count the total number of spots per
>> field, but it turns out to not be enough information (since some with
>> two spots and some with zero spots is the same as wild-type). They
>> would like to generate a histogram of the distribution of spot
>> numbers per nucleus for each image since a mutant would be skewed
>> away from one.  Is there a way to use the nuclear image to define the
>> area of each nucleus and then count spots in each individual nucleus
>> so that the distribution can be plotted in Excel etc.?  Thanks- Dave
>>
>> Dr. David Knecht
>> Department of Molecular and Cell Biology
>> Co-head Flow Cytometry and Confocal Microscopy Facility
>> U-3125
>> 91 N. Eagleville Rd.
>> University of Connecticut
>> Storrs, CT 06269
>> 860-486-2200
>> 860-486-4331 (fax)