[Fwd: Re: Fwd: ImageJ projection of 4D stack]

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

[Fwd: Re: Fwd: ImageJ projection of 4D stack]

dpoburko


-------- Original Message --------
Subject: Re: Fwd: ImageJ projection of 4D stack
Date: Tue, 08 Dec 2009 11:20:59 -0800
From: Damon Poburko <[hidden email]>
To: [hidden email]
References: <[hidden email]>
<[hidden email]>
<[hidden email]>



Hi All,
 
   I just wanted to add a note about the EPFL stack not being macro
scriptable. That's not entirely true. If you check out the example at  
http://bigwww.epfl.ch/demo/edf/EDF-demo.txt they explain the sciptable
aspects of Extended Depth of Field. I've attached a macro where we
implement this menthod in a macro to parse a folder to build stacks
based on file name and pass the stacks to Extended Depth of Field for
processing. This works pretty well for the basic mode of Extended Depth
of Field.

Best,
Damon
 

--

Damon Poburko, PhD
Postdoctoral Research Fellow
Stanford University School of Medicine
Dept. of Molecular & Cellular Physiology
279 Campus Dr., Beckman B103, Stanford, CA 94305
Ph: 650 725 7564, fax: 650 725 8021




Aryeh Weiss wrote:

> Wayne (almost immediately) added the required functionality to allow
> teh macro to get all of the information that it needs. I attached a
> version that will determine the number of slices and other relevant
> dimensions. I have not used it for a while, so I am not sure that it
> still works without modification, but it shoudl show you what you need
> to do.
>
> --aryeh
>
> David Knecht wrote:
>> I am trying to do an extended depth of focus on a stack.  I found
>> this macro from Joachim to do the job, but it is set for 256x256 and
>> 7 frames.  Is there a way to make this general or another way to do
>> EDF on a stack?  Thanks- Dave
>>
>> Begin forwarded message:
>>
>>> From: Joachim Walter <[hidden email]>
>>> Date: May 14, 2007 5:38:09 AM EDT
>>> To: [hidden email]
>>> Subject: Re: ImageJ projection of 4D stack
>>> Reply-To: ImageJ Interest Group <[hidden email]>
>>>
>>> Aryeh,
>>>
>>> here is a short macro to do this with the "Stack Focuser", which
>>> also does Extended Depht of Field. The EPFL Extended Depht of Field
>>> Plugin is not macro scriptable.
>>>
>>> Wayne, there is currently no way to retrieve the number of channels
>>> or frames of an Image in a macro. Could you add "nChannels" and
>>> "nFrames" commands similar to the "nSlices" command?
>>>
>>> Best wishes,
>>> Joachim
>>>
>>>
>>>
>>> // Macro start
>>> idOrig = getImageID();
>>> name = getTitle();
>>> nFrames = 7;
>>>
>>> run("New Image5D", "name="+name+"-ExtDepth type=8-bit fill=Black
>>> width=256 height=256 channels=1 slices=1 frames="+nFrames);
>>> idExtDepth = getImageID();
>>>
>>> for (i=1; i<=nFrames; i++) {
>>> selectImage(idOrig);
>>> run("Set Position", "frame="+i);
>>> run("Stack Focuser ", "enter=11");
>>> run("Select All");
>>> run("Copy");
>>> run("Close");
>>> selectImage(idExtDepth);
>>> run("Set Position", "frame="+i);
>>> run("Paste");
>>> }
>>>
>>> Aryeh Weiss schrieb:
>>>> I have a question about Image5D similar to the question below. I
>>>> want to take an XYZT series, and reduce it to XYT by running the
>>>> extended depth of field plugin on the z-stacks. Can this be done in
>>>> Image5D, of has someone done something similar?
>>>> --aryeh
>>>>
>>>> On Sat, 9 Dec 2006 18:15:53 +0100, Joachim Walter <[hidden email]-
>>>> MUENCHEN.DE> wrote:
>>>>
>>>>
>>>>> You can use the Image5D plugin.
>>>>> - If you have your data as separate 2D TIFF images all in one
>>>>> directory,
>>>>> you open them with the Virtual Image5D opener.
>>>>> - Click on the "Color" button and assign a color to each channel (not
>>>>> limited to RGB)
>>>>> - Use "Z Project" of the Image5D plugins. In the window that pops
>>>>> up you
>>>>> have to select "All Time Frames".
>>>>> The resulting series of projections has to fit in memory, though.
>>>>>
>>>>>
>>>>> Rainer Kohler schrieb:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have a time series of image stacks with three channels from
>>>>>> FluoView. Size 1 GB.
>>>>>> How can I project the z-stacks to create a time series of the
>>>>>> projections of merged images as well as of the separate channels.
>>>>>> Because of memory restrictions it seems not to work in FluoView.
>>>>>> Could I do it in ImageJ?
>>>>>>
>>>
>>>
>>> --
>>> -----------------------------------------------
>>> Dr. Joachim Walter
>>>
>>> TILL I.D. GmbH
>>> c\o BioImaging Zentrum
>>> Großhaderner Str. 2
>>> D-82152 Martinsried
>>>
>>> Tel.: +49-89-2180-74189
>>> Fax:  +49-89-2180-9974189
>>> Geschäftsführer: Dr. Rainer Uhl
>>> HRB 129399 Amtsgericht München
>>> USt.-IdNr. DE 205045721
>>
>> 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)
>>
>
>


--

Damon Poburko, PhD
Postdoctoral Research Fellow
Stanford University School of Medicine
Dept. of Molecular & Cellular Physiology
279 Campus Dr., Beckman B103, Stanford, CA 94305
Ph: 650 725 7564, fax: 650 725 8021


// =======================USER DEFINED VARIABLES =====================================
// ================================================================================

        nCells = 20;
        channels = newArray("C0","C1","C2");

// ================================================================================
// =================================================================================

print("\\Clear");
tStart = getTime();

    requires("1.42l");
    print("\\Clear");
    //run("Input/Output...", "jpeg=90 gif=-1 file=.txt use copy copy"); // set results file output paramters
    mainDir = getDirectory("Choose a Directory ");
    mainList = getFileList(mainDir);

//setBatchMode(true);

for (j=0; j<mainList.length; j++) {                                     // brace1  for loop to parse through names in main folder
    print("j = " + j + "of " + mainList.length);
    //showProgress(j, mainList.length);

  if(endsWith(mainList[j], "/")) {                                      // brace2 if the name is a subfolder...
          subDir = mainDir + mainList[j];
          subList = getFileList(subDir);
          baseName = replace(mainList[j],"/","");
          if (subList.length > 0) {                                                // brace3 skip analysis for empty folder    
     
    //starting looping through file list in subFolder
       
setBatchMode(true);
          //loop for scanning through subdirectory files.
             for (k=0; k<nCells; k++) {
      for (c=0; c<channels.length; c++) {    
                stack = 0;
                      for (i=0; i<subList.length; i++) {        
                         setBatchMode(true);  
                 nCellText = " " + k + "_";
                 if (filter(i,nCellText,channels[c], baseName, subList[i])) {
                  print("i: " + i + " nCellText: " + nCellText + " c: " + channels[c] + " base: " + baseName + "  " + subList[i]);  
                             open(subDir+subList[i]);
                    currName = substring( getTitle(), 0, 2 + lastIndexOf( getTitle(), channels[c] ) );  //get image name less "_Zxx.tif"
                        run("Copy");
            if (stack==0) {
                                type = "" +bitDepth;
                                if (type=="16") type = "16-bit";
                                w=getWidth(); h=getHeight();
                                close();
                                newImage("stack",type,w,h,1);
                                stack = getImageID();
                            } else {
                       close();
                                selectImage(stack);
                                run("Add Slice");
                            }
                    run("Paste");
                       
                        }   // End IF filter
                 
                }                                // closes i loop
                        //setBatchMode(false);      
                if (nImages() == 0) {
                print("no matching images" );
                }
                if (nImages() > 0) {
                        rename(currName);
                XDOF(currName, subDir, channels[c]);    
                  while (nImages>0) {                                                                     //close all open images without saving              
          selectImage(nImages);
    close();
                          }
                }                            //close If that is just taking into account for setting nCells > number of available stacks
                }                                    // closes c loop
      }                                        // closes k loop

setBatchMode(false);
 
                       print("time to analyze current folder: " + ( ( getTime() - tStart ) /1000) + " seconds");    //once files checkout , open stacks, save stacks to tiff. as basemane+stack, run XFOD, save XDOF
      }               // brace3 end If to skip analysis for empty folder ( if (subList.length > 0) {   )
                  // print("fileCheck = " + fileCheck + " numGoodImages " + numGoodImages );    // for each subfolder
         beep();
   }                  // brace2 close if statement for test for subfolder
}                     // brace1 close j loop through main list

//setBatchMode(false);

// ============================================================================================
// ============== FUNCTIONS ===================================================================
// ============================================================================================

// *****************************************************************************************************************************************************************************************
function filter(i,cellNum, color, folder, name) {    // selection criteria to only use certain images  ***************************************************************************************************************************
// *****************************************************************************************************************************************************************************************
                            //  include if contains "some text"
                if (indexOf(name,cellNum)==-1) return false;
                     if (indexOf(name,color)==-1) return false;
                            if (indexOf(name,folder)==-1) return false;
                            if (indexOf(name,".tif")==-1) return false;
                           //  exclude if name contains "someText"
                   if (indexOf(name,".txt")!=-1) return false;               // exclude images acquired with the 580 filter (usually mCherry time lapse
                           if (indexOf(name,".zip")!=-1) return false;
                           if (indexOf(name,"XDOF")!=-1) return false;
            if (indexOf(name,".log")!=-1) return false;
              return true;
 }    

// *****************************************************************************************************************************************************************************************
 function XDOF(currName,subDir,channel) {  // Isolate and measure puncta ***************************************************************************************************************************
// *****************************************************************************************************************************************************************************************

selectWindow(currName);
run("Out");
run("Out");

Tstart = getTime();

run("Easy mode...", "quality='2' topology='0' show-topology='off' show-view='off'");

// argument quality: Speed/Quality trade-off.- 0 fast, 1 intermediate speed, 2 medium quality/speed, 3 intermediate quality, 4 high quality
// argument topology: Topology smoothness - 0 no smoothing of topology, 1 weak smoothing, 2 medium smoothing, 3 strong smoothing, 4 very strong smoothing
// argument show-topology: Show the topology map - on, off
// argument show-view: Show the 3D view - on, off

  //print(isOpen("Output"));
   while (isOpen("Output") == 0) {    //checks if EDF has finished
        wait(100);
   }

Tend = getTime();
        print("EDF run time = " + ((Tend - Tstart)/1000 ) + " seconds.");

selectWindow(currName);
close();
selectWindow("Output");
run("16-bit");
analyzedName = currName + "_XDOF.tif";
rename(analyzedName);
newpath = subDir + analyzedName;
save(newpath);
print("saved " + currName + "_XDOF.tif");
        if (channel == "C1") {
        run("8-bit");
        save(subDir + currName + "_XDOF_8bit.tif");
        }
close();

 
call("java.lang.System.gc");  // clear memory usage


// *****************************************************************************************************************************************************************************************
 } // ******************* close function puncta()  *******************************************************************************************************************
// *****************************************************************************************************************************************************************************************
          //clean up images
          //while (nImages>0) {                                                                     //close all open images without saving              
          //selectImage(nImages);
          //close();

tEnd = getTime();
timeElapsed = (tEnd - tStart)/1000;
setBatchMode(false);
print("macro took " + timeElapsed + " (s)");