Posted by
Pariksheet Nanda on
Oct 26, 2013; 9:14pm
URL: http://imagej.273.s1.nabble.com/Import-Metamorph-ROI-tp5005310p5005334.html
On 10/24/2013 05:42 PM, Kristen Lee Witte wrote:
> I can get every part other but haven't been able to automate the
> plugin part that imports the ROIs.
>
"Metamorph ROI" was showing the dialog box, because you were not
overwriting the variable name it expected. To easiest way to find out
the name of the variables, is to use the Macro recorder i.e. Plugins >
Macros > Record... When I ran the "Metamorph ROI" plugin and selected a
MetaMorph region, I got this new line in the Recorder:
run("Metamorph ROI", "open=[/tmp/rois/bleach pattern for slide.rgn]");
This tells me I need to overwrite the "open" variable. The square
brackets are ImageJ's way of making sure spaces in the directory or
filename do not create problems, so we should keep those.
It looks like you were also missing a semicolon at the end of
region=list[i].
Below is a summary of the 2 changes.
------------------------------------------------------------------------
diff -c /tmp/m2.txt /tmp/m3.txt
--- /tmp/m2.txt 2013-10-26 17:02:30.704000000 -0400
+++ /tmp/m3.txt 2013-10-26 17:01:40.256000000 -0400
@@ -15,8 +15,8 @@
run("Duplicate...", "title=Duplicate");
selectWindow("Duplicate");
i=n-1;
- region=list[i]
- run("Metamorph ROI", rgn+region); //Opens up a dialog box for me to
pick which .rgn file I want to import
+ region=list[i];
+ run("Metamorph ROI", "open=["+rgn+region+"]");
count=roiManager("count");
for (i=1; i<=count; i++) {
roi=i-1;
Diff finished. Sat Oct 26 17:02:38 2013
------------------------------------------------------------------------
The full modified macro file is at the end of this e-mail.
> Kristen
Pariksheet
------------------------------------------------------------------------
setBatchMode(true);
waitForUser("Choose the directory to save string of images");
dir=getDirectory("Choose a Directory");
waitForUser("Choose the regions folder");
rgn=getDirectory("Choose a Directory");
list=getFileList(rgn);
selectWindow("Stack.stk");
run("Duplicate...", "title=Duplicate_stack duplicate range=1-100");
selectWindow("Duplicate_stack");
frames=nSlices();
for (n=1; n<=frames; n++) {
setSlice(n);
title=n;
run("Duplicate...", "title=Duplicate");
selectWindow("Duplicate");
i=n-1;
region=list[i];
run("Metamorph ROI", "open=["+rgn+region+"]");
count=roiManager("count");
for (i=1; i<=count; i++) {
roi=i-1;
roiManager("Select", roi);
run("Add Selection...");
}
selectWindow("Duplicate");
saveAs("Tiff", dir+title);
roiManager("Reset");
selectWindow("Duplicate_stack");
}
setBatchMode(false);
------------------------------------------------------------------------
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html