hyperstack color question

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

hyperstack color question

Cammer, Michael
This is a question about copying the LUT from one hyperstack to another.

We have a large hyperstack that the user custom colors each channel and traces or otherwise segments and saves the ROIs in the manager.

The macro selects all of the ROIs and reassembles them in a new hyperstack.

The question is, how do we assign the colors from the original hyperstack to the new hyperstack?  The commands
  Stack.setDisplayMode(displaymode);
  Stack.setActiveChannels(activechannel);
don't do this.

Thank you!!
________________________________________________________
Michael Cammer, Assistant Research Scientist
Skirball Institute of Biomolecular Medicine
Lab: (212) 263-3208  Cell: (914) 309-3270


Inelegant but functional macro that does everything we want except restore the correct colors:

//=============================================================================
//  Modified 20121001 for hyperstacks.
//  calls function clipCellAndPopOnStack(original, clipstack);
//
macro "clip all ROIs in Roi Manager, center, and put in stack for montage [F4]" {
  if (! Stack.isHyperstack) exit('Expecting a hyperstack');
  original = getImageID;
  Stack.getDimensions(width, height, channels, slices, frames);
  Stack.getDisplayMode(displaymode);
  Stack.getActiveChannels(activechannel);
  t = getTitle;
  bits = bitDepth();
  if (bits == 24) bitstring="RGB";
  else bitstring = ""+bits+"-bit";
  clipsize = getNumber("Enter side of square box in pixels: ", clipsize);
  setPasteMode("Copy");
  clipstackID=newArray(channels);
  clipstackTitle=newArray(channels);
  for (c=1; c<=channels; c++){
    setBatchMode(true);  // this has to be done inside the loop or else only the last stack is shown
    newImage("snippedstack "+ t + " C=" + c, bitstring+" Black", clipsize, clipsize, 1);
    clipstackTitle[c-1] = getTitle();
    clipstackID[c-1] = getImageID;
    for (i=0;  i<roiManager("count");  i++){
      selectImage(original);
      roiManager("select", i);
      clipCellAndPopOnStack(original, clipstackID[c-1], c);
    }  // for  i
    selectImage(clipstackID[c-1]);
    run("Delete Slice");
    run("Select None");
    setBatchMode(false);  // this has to be done inside the loop or else only the last stack is shown
    resetMinAndMax();
  } //for c channels

  frames = nSlices();
  catstring = " title=[tempcat] ";
  for(i=0;i<clipstackTitle.length; i++){
    catstring = catstring + "image"+(i+1)+"=[" + clipstackTitle[i] + "] ";
  }
  catstring = catstring +  "image" + (i+1) +"=[-- None --]";
  print(catstring);
  run("Concatenate...", catstring);
  run("Stack to Hyperstack...", "order=xytcz channels="+channels+" slices=1 frames="+frames+" display=Color");
  rename("snippedstack "+ t );
  Stack.setDisplayMode(displaymode);
  Stack.setActiveChannels(activechannel);
}  // macro "clip multiple ROIs in a stack and put in stack for montage"

//=======================================================================
// Modified 20121001 for hyperstacks.
// The ROI of the cell is selected and the original image is active before this function is called.
//  clipstack contains the imageID of the clipped stacks window.
//=======================================================================
function clipCellAndPopOnStack(original, clipstack, chan) {
  requires("1.45m");
  run("Set Scale...", "distance=1 known=1 pixel=1 unit=px");
  run("Set Measurements...", "  centroid area redirect=None decimal=0");
  run("Measure");
  xc = getResult("X", nResults-1);
  yc = getResult("Y", nResults-1);
  selectWindow("Results");
  run("Close");
  selectImage(original);
  Stack.setChannel(chan);
  makeRectangle(xc-(clipsize/2), yc-(clipsize/2), clipsize, clipsize);
  run("Copy");
  run("Select None");
  setPasteMode("Copy");
  selectImage(clipstack);
  run("Paste");
  run("Add Slice");
}  // clip cell


________________________________________________________
Michael Cammer, Assistant Research Scientist
Skirball Institute of Biomolecular Medicine
Lab: (212) 263-3208  Cell: (914) 309-3270


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: hyperstack color question

Michael P Ellis
Michael, I do not know if it helps put our CompositeAdjuster plugin lets you copy and pasted LUTS between Composite Images (or hyperstacks)

See the plugin here (it's free)

http://www.dsuk.biz/DSUK/SmartCaptureLite.html


And there is a video describing its use here:
http://www.youtube.com/watch?feature=player_embedded&v=g0hoRLxBlWE

and

http://www.youtube.com/watch?feature=player_embedded&v=QMHxGZ4No94

The CompositeAdjuster is also scriptable and macro recordable

See the scripting section on the webpage.

I'd be interested to hear if this is of any help to you.

-- Michael Ellis



On 1 Oct 2012, at 20:44, Cammer, Michael wrote:

> This is a question about copying the LUT from one hyperstack to another.
>
> We have a large hyperstack that the user custom colors each channel and traces or otherwise segments and saves the ROIs in the manager.
>
> The macro selects all of the ROIs and reassembles them in a new hyperstack.
>
> The question is, how do we assign the colors from the original hyperstack to the new hyperstack?  The commands
>  Stack.setDisplayMode(displaymode);
>  Stack.setActiveChannels(activechannel);
> don't do this.
>
> Thank you!!
> ________________________________________________________
> Michael Cammer, Assistant Research Scientist
> Skirball Institute of Biomolecular Medicine
> Lab: (212) 263-3208  Cell: (914) 309-3270
>
>
> Inelegant but functional macro that does everything we want except restore the correct colors:
>
> //=============================================================================
> //  Modified 20121001 for hyperstacks.
> //  calls function clipCellAndPopOnStack(original, clipstack);
> //
> macro "clip all ROIs in Roi Manager, center, and put in stack for montage [F4]" {
>  if (! Stack.isHyperstack) exit('Expecting a hyperstack');
>  original = getImageID;
>  Stack.getDimensions(width, height, channels, slices, frames);
>  Stack.getDisplayMode(displaymode);
>  Stack.getActiveChannels(activechannel);
>  t = getTitle;
>  bits = bitDepth();
>  if (bits == 24) bitstring="RGB";
>  else bitstring = ""+bits+"-bit";
>  clipsize = getNumber("Enter side of square box in pixels: ", clipsize);
>  setPasteMode("Copy");
>  clipstackID=newArray(channels);
>  clipstackTitle=newArray(channels);
>  for (c=1; c<=channels; c++){
>    setBatchMode(true);  // this has to be done inside the loop or else only the last stack is shown
>    newImage("snippedstack "+ t + " C=" + c, bitstring+" Black", clipsize, clipsize, 1);
>    clipstackTitle[c-1] = getTitle();
>    clipstackID[c-1] = getImageID;
>    for (i=0;  i<roiManager("count");  i++){
>      selectImage(original);
>      roiManager("select", i);
>      clipCellAndPopOnStack(original, clipstackID[c-1], c);
>    }  // for  i
>    selectImage(clipstackID[c-1]);
>    run("Delete Slice");
>    run("Select None");
>    setBatchMode(false);  // this has to be done inside the loop or else only the last stack is shown
>    resetMinAndMax();
>  } //for c channels
>
>  frames = nSlices();
>  catstring = " title=[tempcat] ";
>  for(i=0;i<clipstackTitle.length; i++){
>    catstring = catstring + "image"+(i+1)+"=[" + clipstackTitle[i] + "] ";
>  }
>  catstring = catstring +  "image" + (i+1) +"=[-- None --]";
>  print(catstring);
>  run("Concatenate...", catstring);
>  run("Stack to Hyperstack...", "order=xytcz channels="+channels+" slices=1 frames="+frames+" display=Color");
>  rename("snippedstack "+ t );
>  Stack.setDisplayMode(displaymode);
>  Stack.setActiveChannels(activechannel);
> }  // macro "clip multiple ROIs in a stack and put in stack for montage"
>
> //=======================================================================
> // Modified 20121001 for hyperstacks.
> // The ROI of the cell is selected and the original image is active before this function is called.
> //  clipstack contains the imageID of the clipped stacks window.
> //=======================================================================
> function clipCellAndPopOnStack(original, clipstack, chan) {
>  requires("1.45m");
>  run("Set Scale...", "distance=1 known=1 pixel=1 unit=px");
>  run("Set Measurements...", "  centroid area redirect=None decimal=0");
>  run("Measure");
>  xc = getResult("X", nResults-1);
>  yc = getResult("Y", nResults-1);
>  selectWindow("Results");
>  run("Close");
>  selectImage(original);
>  Stack.setChannel(chan);
>  makeRectangle(xc-(clipsize/2), yc-(clipsize/2), clipsize, clipsize);
>  run("Copy");
>  run("Select None");
>  setPasteMode("Copy");
>  selectImage(clipstack);
>  run("Paste");
>  run("Add Slice");
> }  // clip cell
>
>
> ________________________________________________________
> Michael Cammer, Assistant Research Scientist
> Skirball Institute of Biomolecular Medicine
> Lab: (212) 263-3208  Cell: (914) 309-3270
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: hyperstack color question

Cammer, Michael
Thanks for the suggestion of the plugin but while walking home last night I realized that I had overlooked the obvious and thought of this macro which I typed in this morning and seems to do the trick without worrying about the users having to make sure a plugin is installed.
Thanks.
-Michael

   for (c=1; c<=channels; c++){
      selectImage(original);
      Stack.setChannel(c);
      getLut(reds, greens, blues);
      getMinAndMax(min, max);
      selectImage(resultImage);
      Stack.setChannel(c);
      setLut(reds, greens, blues);
      setMinAndMax(min, max);
   } // for c  to update LUTs

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Michael Ellis
Sent: Monday, October 01, 2012 4:56 PM
To: [hidden email]
Subject: Re: hyperstack color question

Michael, I do not know if it helps put our CompositeAdjuster plugin lets you copy and pasted LUTS between Composite Images (or hyperstacks)

See the plugin here (it's free)

http://www.dsuk.biz/DSUK/SmartCaptureLite.html


And there is a video describing its use here:
http://www.youtube.com/watch?feature=player_embedded&v=g0hoRLxBlWE

and

http://www.youtube.com/watch?feature=player_embedded&v=QMHxGZ4No94

The CompositeAdjuster is also scriptable and macro recordable

See the scripting section on the webpage.

I'd be interested to hear if this is of any help to you.

-- Michael Ellis



On 1 Oct 2012, at 20:44, Cammer, Michael wrote:

> This is a question about copying the LUT from one hyperstack to another.
>
> We have a large hyperstack that the user custom colors each channel and traces or otherwise segments and saves the ROIs in the manager.
>
> The macro selects all of the ROIs and reassembles them in a new hyperstack.
>
> The question is, how do we assign the colors from the original
> hyperstack to the new hyperstack?  The commands  
> Stack.setDisplayMode(displaymode);
>  Stack.setActiveChannels(activechannel);
> don't do this.
>
> Thank you!!
> ________________________________________________________
> Michael Cammer, Assistant Research Scientist Skirball Institute of
> Biomolecular Medicine
> Lab: (212) 263-3208  Cell: (914) 309-3270

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