Dear ImageJ Mailing List -
I'm trying to automate a series of ImageCalculator commands with an ImageJ macro after asking the user to choose which images to work with. It's not working, I suspect some syntax problem I can't identify. I'd greatly appreciate any help at all, I've been round and round the archives but don't know what I'm looking for! Thank you in advance, Jennifer ------------------------------- var msNIR; var msR; var idNIR; var idR; macro "myMacro" { // Assumes at least 2 open images, asks user to choose the images to add together allopen=newArray(nImages+1); if (nImages==0) exit("open some images!!"); else { setBatchMode(true); for(i=1; i<nImages+1; i++){ selectImage(i); allopen[i] = getTitle; } } allopen[0] = "Choose open image"; //Create dialog box to ask user to identify the two images //Return user choices to appropriate variables title = "Select Choices"; width = 512; height = 512; Dialog.create("Select Choices"); Dialog.addChoice("NIR:", allopen, msNIR); Dialog.addChoice("Red:", allopen, msR); Dialog.show(); msNIR=Dialog.getChoice(); msR=Dialog.getChoice(); selectWindow(msNIR); idNIR = getImageID(); selectWindow(msR); idR = getImageID(); // All the above seems to work fine! I can put in print commands and I get back reasonable image names and id numbers imageCalculator("Add create", idNIR, idR); // This is where it goes wrong! This line won't execute! } -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Jennifer,
you have set BatchMode, so the resulting image won't be displayed. You can add at the end setBatchMode("exit and display"); Then all images created during the BatchMode macro will be shown. Michael ________________________________________________________________ On Apr 2, 2015, at 11:07, Longyear, Jennifer wrote: > Dear ImageJ Mailing List - > > I'm trying to automate a series of ImageCalculator commands with an ImageJ macro after asking the user to choose which images to work with. > It's not working, I suspect some syntax problem I can't identify. I'd greatly appreciate any help at all, I've been round and round the archives but don't know what I'm looking for! > > Thank you in advance, > Jennifer > > ------------------------------- > var msNIR; > var msR; > var idNIR; > var idR; > macro "myMacro" { > // Assumes at least 2 open images, asks user to choose the images to add together > allopen=newArray(nImages+1); > if (nImages==0) > exit("open some images!!"); > else { > setBatchMode(true); > for(i=1; i<nImages+1; i++){ > selectImage(i); > allopen[i] = getTitle; > } > } > allopen[0] = "Choose open image"; > //Create dialog box to ask user to identify the two images > //Return user choices to appropriate variables > title = "Select Choices"; > width = 512; height = 512; > Dialog.create("Select Choices"); > Dialog.addChoice("NIR:", allopen, msNIR); > Dialog.addChoice("Red:", allopen, msR); > Dialog.show(); > msNIR=Dialog.getChoice(); > msR=Dialog.getChoice(); > > selectWindow(msNIR); > idNIR = getImageID(); > selectWindow(msR); > idR = getImageID(); > // All the above seems to work fine! I can put in print commands and I get back reasonable image names and id numbers > imageCalculator("Add create", idNIR, idR); // This is where it goes wrong! This line won't execute! > } > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Michael,
Thank you so much! Jennifer -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Michael Schmid Sent: 02 April 2015 11:05 To: [hidden email] Subject: Re: imageCalculator in macro Hi Jennifer, you have set BatchMode, so the resulting image won't be displayed. You can add at the end setBatchMode("exit and display"); Then all images created during the BatchMode macro will be shown. Michael ________________________________________________________________ On Apr 2, 2015, at 11:07, Longyear, Jennifer wrote: > Dear ImageJ Mailing List - > > I'm trying to automate a series of ImageCalculator commands with an ImageJ macro after asking the user to choose which images to work with. > It's not working, I suspect some syntax problem I can't identify. I'd greatly appreciate any help at all, I've been round and round the archives but don't know what I'm looking for! > > Thank you in advance, > Jennifer > > ------------------------------- > var msNIR; > var msR; > var idNIR; > var idR; > macro "myMacro" { > // Assumes at least 2 open images, asks user to choose the images to > add together allopen=newArray(nImages+1); if (nImages==0) > exit("open some images!!"); > else { > setBatchMode(true); > for(i=1; i<nImages+1; i++){ > selectImage(i); > allopen[i] = getTitle; > } > } > allopen[0] = "Choose open image"; > //Create dialog box to ask user to identify the two images //Return > user choices to appropriate variables title = "Select Choices"; width > = 512; height = 512; Dialog.create("Select Choices"); > Dialog.addChoice("NIR:", allopen, msNIR); Dialog.addChoice("Red:", > allopen, msR); Dialog.show(); msNIR=Dialog.getChoice(); > msR=Dialog.getChoice(); > > selectWindow(msNIR); > idNIR = getImageID(); > selectWindow(msR); > idR = getImageID(); > // All the above seems to work fine! I can put in print commands and > I get back reasonable image names and id numbers imageCalculator("Add create", idNIR, idR); // This is where it goes wrong! This line won't execute! > } > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html ____________________________________________________________________________ This email has been scanned for Viruses and Spam. For more information please contact your local Business Unit Information Security representative. ____________________________________________________________________________ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |