Batch Analysis and ROIset saving

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Batch Analysis and ROIset saving

Sean Burke
Hello Everyone,
                    I am trying to find an easy way to do a batch analysis of 10 sets of images. Each set contains a DNA and Cytoplasmic channel. I would like to load each image, segment on the DNA Image, get the measurements for the nuclear intensity on the DNA and Cytoplasmic images, then save out the ROIset.zip with a custom or new name for the .zip file, and also save out the measurements as a csv, txt, or excel file. I am relatively new to Image J and wanted to know if anyone has any advice on this.
It would also be great if I could save out an image of the ROI mask as well.

Any help or advice would be greatly appreciated.


Sincerely,
Sean Burke
Reply | Threaded
Open this post in threaded view
|

Re: Batch Analysis and ROIset saving

Nathaniel Ryckman
Sean Burke wrote
Hello Everyone,
                    I am trying to find an easy way to do a batch analysis of 10 sets of images. Each set contains a DNA and Cytoplasmic channel. I would like to load each image, segment on the DNA Image, get the measurements for the nuclear intensity on the DNA and Cytoplasmic images, then save out the ROIset.zip with a custom or new name for the .zip file, and also save out the measurements as a csv, txt, or excel file. I am relatively new to Image J and wanted to know if anyone has any advice on this.
It would also be great if I could save out an image of the ROI mask as well.

Any help or advice would be greatly appreciated.


Sincerely,
Sean Burke
What type of cells are your cells? I got stuck with some macrophages that are heavily clumped, speckled, and unevenly lit, so I've actually been working on making a program for a couple of months. I just know someone out there has an easy way to deal with this, but, unfortunately, I can't find an easy way online.

If you have evenly lit, relatively non-clumped mammalian cells though, you should use this pipeline:

autothreshold (otsu seems popular for some reason) -> watershed -> particle analyzer -> save roi's to zip & multi-measure -> save measurements to .xls

You can use the "record macro" tool under Plugins->Macros->Record... to figure out how to do that.

Theoretically, it should take you only ~20 lines of code. Realistically, I don't think that it will happen unless you are using perfect cells.

Good luck!
Reply | Threaded
Open this post in threaded view
|

Re: Batch Analysis and ROIset saving

Nathaniel Ryckman
In reply to this post by Sean Burke
Sean Burke wrote
Hello Everyone,
                    I am trying to find an easy way to do a batch analysis of 10 sets of images. Each set contains a DNA and Cytoplasmic channel. I would like to load each image, segment on the DNA Image, get the measurements for the nuclear intensity on the DNA and Cytoplasmic images, then save out the ROIset.zip with a custom or new name for the .zip file, and also save out the measurements as a csv, txt, or excel file. I am relatively new to Image J and wanted to know if anyone has any advice on this.
It would also be great if I could save out an image of the ROI mask as well.

Any help or advice would be greatly appreciated.


Sincerely,
Sean Burke
By the way, if you do not have experience programming, you might also want to give cell profiler a try. Some scientists also settle for that software. The reason that I mention CellProfiler is that you can also use imageJ through CellProfiler for specialized tasks.

I tried CellProfiler, and it wasn't very customizable. I would only use it if you are interested in "relative quality" (aka assuming your control population has about as much error as your variable population).
Reply | Threaded
Open this post in threaded view
|

Re: Batch Analysis and ROIset saving

Arne Seitz
In reply to this post by Sean Burke

Hello Everyone,
                    I am trying to find an easy way to do a batch analysis of 10 sets of images. Each set contains a DNA and Cytoplasmic channel. I would like to load each image, segment on the DNA Image, get the measurements for the nuclear intensity on the DNA and Cytoplasmic images, then save out the ROIset.zip with a custom or new name for the .zip file, and also save out the measurements as a csv, txt, or excel file. I am relatively new to Image J and wanted to know if anyone has any advice on this.
It would also be great if I could save out an image of the ROI mask as well.

Any help or advice would be greatly appreciated.


Sincerely,
Sean Burke

Dear Sean,

please find below a macro which should more or less do what you were asking for.
It is creating a mask/ROI in images which contain the key word "cherry.tif" and then does the measurements in the other channel which name ended with GFP2.tif.
You probably will have to adapt the one or the other parameter.
Feel free to contact me again if you have further questions.

Cheers Arne

setBatchMode(true);

run("Set Measurements...", "area mean standard min integrated area_fraction display redirect=None decimal=3");

       
dir=getDirectory("Choose a  Source Directory ");
savedir=getDirectory("Choose a Storage Directory");
list = getFileList(dir);
print (dir);
print (savedir);

for (i=1; i<list.length; i++) {

        if (endsWith(list[i],"cherry.tif")){          
           
                ch1=dir+list[i];
                ch2=replace(list[i],"cherry.tif","GFP2.tif");
               
                stem=replace(list[i],"cherry.tif","");
                nucmask=stem+"NucMask.tif";

                open(ch1);
                createObjects(savedir,stem);
                rename(nucmask);
                saveAs(nucmask,savedir+nucmask);
                close();
 
                open(ch2);
                measureObjects(ch2);
                selectWindow("Results");
                savename=savedir+stem+"MeasureResults.xls";
                saveAs("Text", savename);
                if (isOpen("Results")) {
          selectWindow("Results");
          run("Close" );
                }
               
                savename=savedir+stem+"Roi.zip";
                roiManager("Save",savename);
               
        }
 
}

function createObjects(dir,stem){
  run("Median...", "radius=2");
  run("Convert to Mask");
  run("Fill Holes");
  rename(stem+"Nuc.tif");
  saveAs(stem+"Nuc.tif",dir+stem+"Nuc.tif");
  run("Watershed");
  run("Analyze Particles...", "size=10-6000 circularity=0.00-1.00 show=Nothing exclude clear add");
 
}

function measureObjects(object){
  open(object);
  num=roiManager("count");
  for (i=0;i<num;i++){
        roiManager("select",i);
        setAutoThreshold();
        run("Measure");
  }
  close();
}





















Reply | Threaded
Open this post in threaded view
|

Re: Batch Analysis and ROIset saving

Nathaniel Ryckman
<quote author="Arne Seitz">
Hello Everyone,
                    I am trying to find an easy way to do a batch analysis of 10 sets of images. Each set contains a DNA and Cytoplasmic channel. I would like to load each image, segment on the DNA Image, get the measurements for the nuclear intensity on the DNA and Cytoplasmic images, then save out the ROIset.zip with a custom or new name for the .zip file, and also save out the measurements as a csv, txt, or excel file. I am relatively new to Image J and wanted to know if anyone has any advice on this.
It would also be great if I could save out an image of the ROI mask as well.

Any help or advice would be greatly appreciated.


Sincerely,
Sean Burke

Dear Sean,

please find below a macro which should more or less do what you were asking for.
It is creating a mask/ROI in images which contain the key word "cherry.tif" and then does the measurements in the other channel which name ended with GFP2.tif.
You probably will have to adapt the one or the other parameter.
Feel free to contact me again if you have further questions.

Cheers Arne

setBatchMode(true);

run("Set Measurements...", "area mean standard min integrated area_fraction display redirect=None decimal=3");

       
dir=getDirectory("Choose a  Source Directory ");
savedir=getDirectory("Choose a Storage Directory");
list = getFileList(dir);
print (dir);
print (savedir);

for (i=1; i<list.length; i++) {

        if (endsWith(list[i],"cherry.tif")){          
           
                ch1=dir+list[i];
                ch2=replace(list[i],"cherry.tif","GFP2.tif");
               
                stem=replace(list[i],"cherry.tif","");
                nucmask=stem+"NucMask.tif";

                open(ch1);
                createObjects(savedir,stem);
                rename(nucmask);
                saveAs(nucmask,savedir+nucmask);
                close();
 
                open(ch2);
                measureObjects(ch2);
                selectWindow("Results");
                savename=savedir+stem+"MeasureResults.xls";
                saveAs("Text", savename);
                if (isOpen("Results")) {
          selectWindow("Results");
          run("Close" );
                }
               
                savename=savedir+stem+"Roi.zip";
                roiManager("Save",savename);
               
        }
 
}

function createObjects(dir,stem){
  run("Median...", "radius=2");
  run("Convert to Mask");
  run("Fill Holes");
  rename(stem+"Nuc.tif");
  saveAs(stem+"Nuc.tif",dir+stem+"Nuc.tif");
  run("Watershed");
  run("Analyze Particles...", "size=10-6000 circularity=0.00-1.00 show=Nothing exclude clear add");
 
}

function measureObjects(object){
  open(object);
  num=roiManager("count");
  for (i=0;i<num;i++){
        roiManager("select",i);
        setAutoThreshold();
        run("Measure");
  }
  close();
}
</quote>

More or LESS. Do you have any practical examples where this macro will actually work? He could use CellProfiler instead if this is all he wants to do. With CellProfiler, he won't have to bother coding.

The Watershed program is inherently flawed in my opinion.
Reply | Threaded
Open this post in threaded view
|

Re: Batch Analysis and ROIset saving

Sean Burke
In reply to this post by Nathaniel Ryckman
Thanks....I actually use Cell Profiler all the time and have the Mask and ROI features down....What I am trying to do is figure out a way to get the ROI data and masks from imageJ in a format that can be read into FCS Express Image Cytometry like I can do with cell profiler.


~Sean