Macro: Zoom in without changing window size (tiled display)

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

Macro: Zoom in without changing window size (tiled display)

mattjackson
Hello,

I'm having some difficulties with a macro. I'm trying to do something that should be quite easy, and I would appreciate some help (thank you in advance).

The setup: I have a set of tiled fluorescence images. These are very large images (225 20X images of a well in a 96-well plate stitched together). I've identified nuclei via the particle analyzer, and they're arrayed in the ROI manager. I need to zoom in to each ROI on each channel so I can make calls of phenotype via a dialogue box, all of which is written.

The problem: When zooming in to the ROI, the channel windows expand, and they are no longer tiled (I can only see a single channel at a time). Here's the script, as well as attempts to fix this.

Script 1: There's a for loop here (index i) looping over the ROIs

selectWindow("Stitched_DAPI.tif");
roiManager("select",i);
run("To Selection");
run("Out [-]");
run("Out [-]");
run("Out [-]");
run("Out [-]");
run("Out [-]");
run("Out [-]");
run("Out [-]");
run("Out [-]");
run("Out [-]");

Script 2: Tried to define the window size with a rectangle selection and zoom into that. The rectangle was near the ROI but not overlaying. There's some error there, but the windows still expand.

selectWindow("Stitched_DAPI.tif");
roiManager("select",i);
Roi.getCoordinates(xroi, yroi);
Array.getStatistics(xroi, xmin, xmax);
Array.getStatistics(yroi, ymin, ymax);
xcenter = (xmax - xmin)/2 + xmin;
ycenter = (ymax - ymin)/2 + ymin;
recx = xcenter - 230;
recy = ycenter + 260;
makeRectangle(recx, recy, 460, 520);
run("To Selection");

Further attempts: Tried to trick ImageJ by moving the window off screen (to negative X,Y values) and then do the zooming, but the window still expanded. Also, running Tile again doesn't work because it zooms the image out again.

Anybody have an idea how to accomplish this in an ImageJ macro?

Thanks,
Matt Jackson
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Zoom in without changing window size (tiled display)

Rasband, Wayne (NIH/NIMH) [E]
> On Jan 28, 2015, at 3:49 PM, mattjackson <[hidden email]> wrote:
>
> Hello,
>
> I'm having some difficulties with a macro. I'm trying to do something that
> should be quite easy, and I would appreciate some help (thank you in
> advance).
>
> The setup: I have a set of tiled fluorescence images. These are very large
> images (225 20X images of a well in a 96-well plate stitched together). I've
> identified nuclei via the particle analyzer, and they're arrayed in the ROI
> manager. I need to zoom in to each ROI on each channel so I can make calls
> of phenotype via a dialogue box, all of which is written.
>
> The problem: When zooming in to the ROI, the channel windows expand, and
> they are no longer tiled (I can only see a single channel at a time). Here's
> the script, as well as attempts to fix this.

The window will not expand if you run the Image>Zoom>To Selection command with the alt key down. Here is an example:

  run("Blobs (25K)");
  makeRectangle(113, 70, 37, 30);
  setKeyDown("alt")
  run("To Selection");

-wayne

> Script 1: There's a for loop here (index i) looping over the ROIs
>
> selectWindow("Stitched_DAPI.tif");
> roiManager("select",i);
> run("To Selection");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
>
> Script 2: Tried to define the window size with a rectangle selection and
> zoom into that. The rectangle was near the ROI but not overlaying. There's
> some error there, but the windows still expand.
>
> selectWindow("Stitched_DAPI.tif");
> roiManager("select",i);
> Roi.getCoordinates(xroi, yroi);
> Array.getStatistics(xroi, xmin, xmax);
> Array.getStatistics(yroi, ymin, ymax);
> xcenter = (xmax - xmin)/2 + xmin;
> ycenter = (ymax - ymin)/2 + ymin;
> recx = xcenter - 230;
> recy = ycenter + 260;
> makeRectangle(recx, recy, 460, 520);
> run("To Selection");
>
> Further attempts: Tried to trick ImageJ by moving the window off screen (to
> negative X,Y values) and then do the zooming, but the window still expanded.
> Also, running Tile again doesn't work because it zooms the image out again.
>
> Anybody have an idea how to accomplish this in an ImageJ macro?
>
> Thanks,
> Matt Jackson
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Macro-Zoom-in-without-changing-window-size-tiled-display-tp5011359.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> 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: Macro: Zoom in without changing window size (tiled display)

mattjackson
Thanks so much, Wayne. I didn't know about the setKeyDown function. I'm surprised it doesn't pop up in the macro recorder.

So... Very weird, but the code you posted works perfectly. However, if I exchange the Blob image with my own, it doesn't work. The image still resizes.

selectWindow("Stitched_DAPI.tif");
//run("Blobs (25K)");
makeRectangle(113, 70, 37, 30);
setKeyDown("alt");
run("To Selection");

I've attached the file, "Stitched_DAPI.tif", to help debug this. I tried downloading a fresh version of FIJI and enabling ImageJ2, but the same issue happens. Any ideas?

-Matt
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Zoom in without changing window size (tiled display)

mattjackson
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Zoom in without changing window size (tiled display)

mattjackson
________________________________
From: mattjackson [via ImageJ] [[hidden email]]
Sent: Thursday, January 29, 2015 10:39 AM
To: Jackson, Matt
Subject: Re: Macro: Zoom in without changing window size (tiled display)

File too large to upload. I can email if requested.

________________________________
If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Macro-Zoom-in-without-changing-window-size-tiled-display-tp5011359p5011371.html
To unsubscribe from Macro: Zoom in without changing window size (tiled display), click here<
NAML<
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://imagej.1557.x6.nabble.com/Macro-Zoom-in-without-changing-window-size-tiled-display-tp5011359p5011372.html
Sent from the ImageJ mailing list archive at Nabble.com.

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

Re: Macro: Zoom in without changing window size (tiled display)

mattjackson
Dropbox link to download "Stitched_DAPI.tif".

https://www.dropbox.com/s/bnn9escvwl0enj6/Stitched_DAPI.tif?dl=0

Any feedback would really help. This has been very frustrating.



--
View this message in context: http://imagej.1557.x6.nabble.com/Macro-Zoom-in-without-changing-window-size-tiled-display-tp5011359p5011374.html
Sent from the ImageJ mailing list archive at Nabble.com.

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

Re: Macro: Zoom in without changing window size (tiled display)

Michael Entrup
In reply to this post by mattjackson
Hi Matt,

with 'Boats', zoom without resize does not work, too. Here is my example:

run("Boats (356K)");
run("Out [-]");
run("Out [-]");
makeRectangle(364, 260, 184, 104);
showMessage("The image windows is very small.");
setKeyDown("alt");
run("To Selection");
showMessage("Now it is much larger.");

There is another problem, if I add another 'run("Out [-]")'. Try this:

run("Boats (356K)");
run("Out [-]");
run("Out [-]");
run("Out [-]");
makeRectangle(364, 260, 184, 104);
showMessage("The image windows is very small.");
setKeyDown("alt");
run("To Selection");
showMessage("Now it is much larger.");

The top left corner is shown and not the selection.

I'm a bit confused how holding down [alt] should help. If I open the
menu and hold [ald], it will directly close (on Win7). There is no
chance to select any menu item.

Best regards
Michael


Am 29.01.2015 um 16:27 schrieb mattjackson:

> Thanks so much, Wayne. I didn't know about the setKeyDown function. I'm
> surprised it doesn't pop up in the macro recorder.
>
> So... Very weird, but the code you posted works perfectly. However, if I
> exchange the Blob image with my own, it doesn't work. The image still
> resizes.
>
> selectWindow("Stitched_DAPI.tif");
> //run("Blobs (25K)");
> makeRectangle(113, 70, 37, 30);
> setKeyDown("alt");
> run("To Selection");
>
> I've attached the file, "Stitched_DAPI.tif", to help debug this. I tried
> downloading a fresh version of FIJI and enabling ImageJ2, but the same issue
> happens. Any ideas?
>
> -Matt
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Macro-Zoom-in-without-changing-window-size-tiled-display-tp5011359p5011369.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> 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: Macro: Zoom in without changing window size (tiled display)

Herbie-4
Michael,

both of your macros work as I expect them under OSX.

Best

Herbie

::::::::::::::::::::::::::::::::::::::::
On 30.01.15 10:49, Michael Entrup wrote:

> Hi Matt,
>
> with 'Boats', zoom without resize does not work, too. Here is my example:
>
> run("Boats (356K)");
> run("Out [-]");
> run("Out [-]");
> makeRectangle(364, 260, 184, 104);
> showMessage("The image windows is very small.");
> setKeyDown("alt");
> run("To Selection");
> showMessage("Now it is much larger.");
>
> There is another problem, if I add another 'run("Out [-]")'. Try this:
>
> run("Boats (356K)");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
> makeRectangle(364, 260, 184, 104);
> showMessage("The image windows is very small.");
> setKeyDown("alt");
> run("To Selection");
> showMessage("Now it is much larger.");
>
> The top left corner is shown and not the selection.
>
> I'm a bit confused how holding down [alt] should help. If I open the
> menu and hold [ald], it will directly close (on Win7). There is no
> chance to select any menu item.
>
> Best regards
> Michael
>
>
> Am 29.01.2015 um 16:27 schrieb mattjackson:
>> Thanks so much, Wayne. I didn't know about the setKeyDown function. I'm
>> surprised it doesn't pop up in the macro recorder.
>>
>> So... Very weird, but the code you posted works perfectly. However, if I
>> exchange the Blob image with my own, it doesn't work. The image still
>> resizes.
>>
>> selectWindow("Stitched_DAPI.tif");
>> //run("Blobs (25K)");
>> makeRectangle(113, 70, 37, 30);
>> setKeyDown("alt");
>> run("To Selection");
>>
>> I've attached the file, "Stitched_DAPI.tif", to help debug this. I tried
>> downloading a fresh version of FIJI and enabling ImageJ2, but the same
>> issue
>> happens. Any ideas?
>>
>> -Matt
>>
>>
>>
>> --
>> View this message in context:
>> http://imagej.1557.x6.nabble.com/Macro-Zoom-in-without-changing-window-size-tiled-display-tp5011359p5011369.html
>>
>> Sent from the ImageJ mailing list archive at Nabble.com.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> 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: Macro: Zoom in without changing window size (tiled display)

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Michael Entrup
On Jan 30, 2015, at 4:49 AM, Michael Entrup <[hidden email]> wrote:

>
> Hi Matt,
>
> with 'Boats', zoom without resize does not work, too. Here is my example:
>
> run("Boats (356K)");
> run("Out [-]");
> run("Out [-]");
> makeRectangle(364, 260, 184, 104);
> showMessage("The image windows is very small.");
> setKeyDown("alt");
> run("To Selection");
> showMessage("Now it is much larger.”);

This macro and the one below should work as expected if you upgrade to the latest ImageJ daily build (1.49p6).

> There is another problem, if I add another 'run("Out [-]")'. Try this:
>
> run("Boats (356K)");
> run("Out [-]");
> run("Out [-]");
> run("Out [-]");
> makeRectangle(364, 260, 184, 104);
> showMessage("The image windows is very small.");
> setKeyDown("alt");
> run("To Selection");
> showMessage("Now it is much larger.");
>
> The top left corner is shown and not the selection.
>
> I'm a bit confused how holding down [alt] should help. If I open the menu and hold [ald], it will directly close (on Win7). There is no chance to select any menu item.

It should work if you use keyboard shortcuts, for example press both the alt and “+” keys to zoom in without enlarging the window.

-wayne

> Am 29.01.2015 um 16:27 schrieb mattjackson:
>> Thanks so much, Wayne. I didn't know about the setKeyDown function. I'm
>> surprised it doesn't pop up in the macro recorder.
>>
>> So... Very weird, but the code you posted works perfectly. However, if I
>> exchange the Blob image with my own, it doesn't work. The image still
>> resizes.
>>
>> selectWindow("Stitched_DAPI.tif");
>> //run("Blobs (25K)");
>> makeRectangle(113, 70, 37, 30);
>> setKeyDown("alt");
>> run("To Selection");
>>
>> I've attached the file, "Stitched_DAPI.tif", to help debug this. I tried
>> downloading a fresh version of FIJI and enabling ImageJ2, but the same issue
>> happens. Any ideas?
>>
>> -Matt
>>
>>
>>
>> --
>> View this message in context: http://imagej.1557.x6.nabble.com/Macro-Zoom-in-without-changing-window-size-tiled-display-tp5011359p5011369.html
>> Sent from the ImageJ mailing list archive at Nabble.com.

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