Login  Register

Re: problem with conversion to RGB - IJ 1.51k18 java 1.6.0_20

Posted by Swayne, Theresa C. on Feb 24, 2017; 10:00pm
URL: http://imagej.273.s1.nabble.com/problem-with-conversion-to-RGB-IJ-1-51k18-java-1-6-0-20-tp5018189p5018191.html

Hi Michael,

On my system, this failed every time. The debug window showed id1 and id2 to be the same — even though the projection window was on top.

A workaround, which you probably already considered, is to find the projection by the window title.  The below macro works for me. I added a line to make a test hyperstack in the first step.

macro "Set up images [q]" {
// create an image to process
newImage("HyperStack", "16-bit color-mode label", 300, 300, 3, 10, 1);
 //run("Channels Tool...");
 Stack.setDisplayMode("composite");
 //run("Brightness/Contrast...");
 Stack.getDimensions(width, height, channels, slices, frames) ;
 for (n=1; n<=channels; n++) {
   Stack.setChannel(n);
   setMinAndMax(0, 65535);
 }
 Stack.setSlice(floor(slices / 3)) ;
}


/*  Draw a box around an area to be 3D projected.
    Run this macro.
*/
macro "Do 3D projections [F2]" {

  run("Duplicate...", "duplicate");
  id1 = getImageID();

  title = getTitle();

  // change to get scale for each sample if Z different than 0.3 um
  run("3D Project...", "projection=[Brightest Point] axis=X-Axis slice=0.30 initial=0 total=360 rotation=10 lower=1 upper=255 opacity=0 surface=50 interior=25 interpolate");
  //run("RGB Color", "frames");  // buggy
  wait(200);   // appears the projection command needs this to hand off the image properly

  selectWindow("Projections of " + title);
  id2 = getImageID();

  run("RGB Color", "frames keep");
  selectImage(id1);
  close();
  selectImage(id2);
  close();
}

On Feb 24, 2017, at 4:26 PM, Cammer, Michael <[hidden email]<mailto:[hidden email]>> wrote:

We are having a problem converting hyperstacks to RGB in a macro.  Approximately one out of five times we run the macro, it does not work.  We tried adding a wait(200) step, but don't know if this really helps or not.

The error is that ImageJ cannot find image with id2.

[cid:image001.png@01D28EBA.CC7A15E0]

Any help appreciated.  The problem is with the second macro.  Included the first macro to show what types of files we are using (2 or 3 channel Z series confocal).

macro "Set up images [q]" {
 //run("Channels Tool...");
 Stack.setDisplayMode("composite");
 //run("Brightness/Contrast...");
 Stack.getDimensions(width, height, channels, slices, frames) ;
 for (n=1; n<=channels; n++) {
   Stack.setChannel(n);
   setMinAndMax(0, 65535);
 }
 Stack.setSlice(floor(slices / 3)) ;
}

/*  Draw a box around an area to be 3D projected.
    Run this macro.
*/
macro "Do 3D projections [F2]" {
  run("Duplicate...", "duplicate");
  id1 = getImageID();
  // change to get scale for each sample if Z different than 0.3 um
  run("3D Project...", "projection=[Brightest Point] axis=X-Axis slice=0.30 initial=0 total=360 rotation=10 lower=1 upper=255 opacity=0 surface=50 interior=25 interpolate");
  //run("RGB Color", "frames");  // buggy
  wait(200);   // appears the projection command needs this to hand off the image properly
  id2 = getImageID();
  run("RGB Color", "frames keep");
  selectImage(id1); close(); selectImage(id2); close();
}








=*===========================================================*=
Michael Cammer, DART Microscopy Laboratory, NYU Langone Medical Center
   Cell:  914-309-3270     Office: Skirball 2nd Floor main office, back right
     http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/


------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

------------------------------------
Theresa Swayne, Ph.D.
Manager
Confocal and Specialized Microscopy Shared Resource<http://hiccc.columbia.edu/research/sharedresources/confocal>

Herbert Irving Comprehensive Cancer Center
Columbia University Medical Center
1130 St. Nicholas Ave., Room 222A
New York, NY 10032
Phone: 212-851-4613
[hidden email]<mailto:[hidden email]>


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html