Login  Register

Re: code to open, display, modify, pause, go back to directory

Posted by ktoo on Dec 21, 2012; 10:04pm
URL: http://imagej.273.s1.nabble.com/help-with-Batch-Merge-of-2-channel-image-sequence-tp5001242p5001256.html

Volker,

Thanks for your reply to my question! For some reason, the macro I have written (below) does not display an image for me to work on. My files are in Zeiss LSM format, so unfortunately the "Open next" command doesn't work. Maybe it would be worth my time to convert the files before trying to work on them, it might save me time. Also, thanks for the pointer to the batch processing tutorial. I will look into that more after the holidays.

Happy holidays!

Klara



dir = getDirectory("Choose a Directory "); list = getFileList(dir); setBatchMode(true); for (i=0; i<list.length; i++) { showProgress(i, list.length); open(dir+list[i]);

title = getTitle();
run("Split Channels");
selectWindow("C1-"+title);
close();
selectWindow("C2-"+title);
close();
selectWindow("C3-"+title);
close();

selectWindow("C4-"+title);
setAutoThreshold("Default dark");
run("Convert to Mask");

run("Fill Holes");
run("Watershed");
//setTool("wand");

run("Set Measurements...", "area mean perimeter display add redirect=None decimal=3");
run("wait For User");
close;}





-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Volker Baecker
Sent: Friday, December 21, 2012 2:59 AM
To: [hidden email]
Subject: Re: code to open, display, modify, pause, go back to directory

Hi,
do you want to do this in java code or in a macro?

Is the image already displayed or not? If not you have to show the image and then you call waitForUser. This can be done in a macro or plugin. See

http://imagejdocu.tudor.lu/doku.php?id=plugin:utilities:wait_for_user:start

It will stop the execution of a macro or plugin, let the user do something with the image. When he finished he presses the button on the dialog and the macro or plugin continues its work.

I'm not sure what you mean by "take me back to the directory that the image came from". ImageJ has the "open next" command that opens the next image in the folder the current image came from. You can run it with run("Open Next"); from a macro.

You could of course as well just iterate over the images in the folder.
See for example section 4.1 in
http://www.sussex.ac.uk/gdsc/intranet/pdfs/ImageJBatchProcessing.pdf

I hope this helps,
Volker

 On 21/12/12 00:45, Olofsdotter Otis, Klara wrote:

> Hi all,
>
> I would like ImageJ to open a 4-channel image file from a directory, display the channel I'm interested in, perform some modifications of that image (these steps I know how to do), let me manually work on that image, and take me back to the directory that the image came from when I close it (these two last steps I haven't been able to work out).
>
> It doesn't even have to open the first image automatically, as long as it takes me back to the same folder as the previously used image.
>
> I would be grateful for help!
>
>
>
> IMPORTANT WARNING:  This email (and any attachments) is only intended for the use of the person or entity to which it is addressed, and may contain information that is privileged and confidential.  You, the recipient, are obligated to maintain it in a safe, secure and confidential manner.  Unauthorized redisclosure or failure to maintain confidentiality may subject you to federal and state penalties. If you are not the intended recipient, please immediately notify us by return email, and delete this message from your computer.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

IMPORTANT WARNING:  This email (and any attachments) is only intended for the use of the person or entity to which it is addressed, and may contain information that is privileged and confidential.  You, the recipient, are obligated to maintain it in a safe, secure and confidential manner.  Unauthorized redisclosure or failure to maintain confidentiality may subject you to federal and state penalties. If you are not the intended recipient, please immediately notify us by return email, and delete this message from your computer.

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