Hello there,
I am trying to get a plug in (in imagej language) to run on all the files in a directory using a macro. I have been able to do this with other plug-ins that were simpler (eg. gaussian blur/subtract background) but I can't get this one to run despite trying all sorts of permutations of the code below and searching through multiple guides online. The macro runs perfectly when I specify the 'pathToBlurredImage' and 'pathToDeblurredImage' - but I can get it to look up files in my array. I am quite new to this so have probably overlooked something so obvious that it's not explained anywhere. function action(input, output, filename) { open(input + filename); pathToBlurredImage = input + filename; pathToPsf = "/Users/kirstenscott/Desktop/grain-psf.tif"; pathToDeblurredImage = output; boundary = "REFLEXIVE"; //available options: REFLEXIVE, PERIODIC, ZERO resizing = "AUTO"; // available options: AUTO, MINIMAL, NEXT_POWER_OF_TWO output = "SAME_AS_SOURCE"; // available options: SAME_AS_SOURCE, BYTE, SHORT, FLOAT precision = "SINGLE"; //available options: SINGLE, DOUBLE threshold = "-1"; //if -1, then disabled maxIters = "5"; nOfThreads = "2"; showIter = "false"; gamma = "0"; filterXY = "1.0"; normalize = "false"; logMean = "false"; antiRing = "true"; changeThreshPercent = "0.01"; db = "false"; detectDivergence = "true"; call("edu.emory.mathcs.restoretools.iterative.ParallelIterativeDeconvolution2D.deconvolveWPL", pathToBlurredImage, pathToPsf, pathToDeblurredImage, boundary, resizing, output, precision, threshold, maxIters, nOfThreads, showIter, gamma, filterXY, normalize, logMean, antiRing, changeThreshPercent, db, detectDivergence); close(); } input = "/Users/kirstenscott/Desktop/variation_output/"; output = "/Users/kirstenscott/Desktop/variation_study_deconvolved/"; setBatchMode(true); list = getFileList(input); for (i = 0; i < list.length; i++) action(input, output, list[i]); setBatchMode(false); Thanks very much. Kirsten |
Hi,
You don't tell us if there is a specific error generated so any help will be guess-work. I simplified your macro to a bare-bones version. As long as the output directory exists the macro runs fine. If the output directory doesn't exist then an error is generated stating that the output directory doesn't exist. Is that the error you encounter? To get around that, in the macro below I create the output directory on the fly if needed. I hope this helps. At least if this is not the issue then you know the problem lies elsewhere. Cheers, ben //START // reads a file and then writes it // note I squeeze the path separator in there function action(input, output, filename) { open(input + File.separator + filename); save(output + File.separator + filename); close(); } // I split the sample "bat-cochlea-volume" into individual images // check out that I did not use the closing path separator input = "/Users/ben/bat"; // I manually created this output directory output = input + "-out"; if (!File.exists(output)) File.makeDirectory(output); setBatchMode(true); // I shy away from using 'list' as a variable name now that Wayne has added the "List" functions // so I called it fileList fileList = getFileList(input); for (i = 0; i < fileList.length; i++){ action(input, output, fileList[i]); } setBatchMode(false); // END On Aug 25, 2011, at 7:42 AM, kirstens wrote: > Hello there, > > I am trying to get a plug in (in imagej language) to run on all the files in > a directory using a macro. I have been able to do this with other plug-ins > that were simpler (eg. gaussian blur/subtract background) but I can't get > this one to run despite trying all sorts of permutations of the code below > and searching through multiple guides online. > > The macro runs perfectly when I specify the 'pathToBlurredImage' and > 'pathToDeblurredImage' - but I can get it to look up files in my array. > > I am quite new to this so have probably overlooked something so obvious that > it's not explained anywhere. > > function action(input, output, filename) { > open(input + filename); > pathToBlurredImage = input + filename; > pathToPsf = "/Users/kirstenscott/Desktop/grain-psf.tif"; > pathToDeblurredImage = output; > boundary = "REFLEXIVE"; //available options: REFLEXIVE, PERIODIC, ZERO > resizing = "AUTO"; // available options: AUTO, MINIMAL, NEXT_POWER_OF_TWO > output = "SAME_AS_SOURCE"; // available options: SAME_AS_SOURCE, BYTE, > SHORT, FLOAT > precision = "SINGLE"; //available options: SINGLE, DOUBLE > threshold = "-1"; //if -1, then disabled > maxIters = "5"; > nOfThreads = "2"; > showIter = "false"; > gamma = "0"; > filterXY = "1.0"; > normalize = "false"; > logMean = "false"; > antiRing = "true"; > changeThreshPercent = "0.01"; > db = "false"; > detectDivergence = "true"; > call("edu.emory.mathcs.restoretools.iterative.ParallelIterativeDeconvolution2D.deconvolveWPL", > pathToBlurredImage, pathToPsf, pathToDeblurredImage, boundary, resizing, > output, precision, threshold, maxIters, nOfThreads, showIter, gamma, > filterXY, normalize, logMean, antiRing, changeThreshPercent, db, > detectDivergence); > close(); > } > input = "/Users/kirstenscott/Desktop/variation_output/"; > output = "/Users/kirstenscott/Desktop/variation_study_deconvolved/"; > setBatchMode(true); > list = getFileList(input); > for (i = 0; i < list.length; i++) > action(input, output, list[i]); > setBatchMode(false); > > > Thanks very much. > > Kirsten > > > -- > View this message in context: http://imagej.588099.n2.nabble.com/batch-files-macro-tp6724133p6724133.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Hi Ben,
Thanks for your suggestion. Originally, I was not getting any errors - it just wasn't even starting to run. I have now tried using your method - the problem lies with the way the macro is constructed - the pathToBlurredImage is actually the input file so it is this variable that needs to have an associated array but I haven't been able to get this variable to look in my array (see below with your alterations). The error I get is with line 9 - it says 'unidentified variable in line 9' - I have tried lots of different combinations, including substituting input with pathToBlurredImage. I am pretty sure it's something obvious I've missed. Thanks again for the suggestion - I will use this for macros in the future. Kirsten //START // reads a file and then writes it // note I squeeze the path separator in there function action(input, output, filename) { open(input + File.separator + filename); save(output + File.separator + filename); close(); } pathToBlurredImage = input pathToPsf = "/Users/kirstenscott/Desktop/grain-psf.tif"; pathToDeblurredImage = output; boundary = "REFLEXIVE"; //available options: REFLEXIVE, PERIODIC, ZERO resizing = "AUTO"; // available options: AUTO, MINIMAL, NEXT_POWER_OF_TWO output = "SAME_AS_SOURCE"; // available options: SAME_AS_SOURCE, BYTE, SHORT, FLOAT precision = "SINGLE"; //available options: SINGLE, DOUBLE threshold = "-1"; //if -1, then disabled maxIters = "5"; nOfThreads = "2"; showIter = "false"; gamma = "0"; filterXY = "1.0"; normalize = "false"; logMean = "false"; antiRing = "true"; changeThreshPercent = "0.01"; db = "false"; detectDivergence = "true"; call("edu.emory.mathcs.restoretools.iterative.ParallelIterativeDeconvolution2D.deconvolveWPL", pathToBlurredImage, pathToPsf, pathToDeblurredImage, boundary, resizing, output, precision, threshold, maxIters, nOfThreads, showIter, gamma, filterXY, normalize, logMean, antiRing, changeThreshPercent, db, detectDivergence); close(); // I split the sample "bat-cochlea-volume" into individual images // check out that I did not use the closing path separator input = "/Users/kirstenscott/Desktop/variation_study_output" // I manually created this output directory output = input + "-out"; if (!File.exists(output)) File.makeDirectory(output); setBatchMode(true); // I shy away from using 'list' as a variable name now that Wayne has added the "List" functions // so I called it fileList fileList = getFileList(input); for (i = 0; i < fileList.length; i++){ action(input, output, fileList[i]); } setBatchMode(false); // END On 25 Aug 2011, at 14:32, Ben Tupper wrote: > //START > // reads a file and then writes it > // note I squeeze the path separator in there > function action(input, output, filename) { > open(input + File.separator + filename); > save(output + File.separator + filename); > close(); > } > > // I split the sample "bat-cochlea-volume" into individual images > // check out that I did not use the closing path separator > input = "/Users/ben/bat"; > // I manually created this output directory > output = input + "-out"; > if (!File.exists(output)) File.makeDirectory(output); > > > setBatchMode(true); > > // I shy away from using 'list' as a variable name now that Wayne has added the "List" functions > // so I called it fileList > fileList = getFileList(input); > for (i = 0; i < fileList.length; i++){ > action(input, output, fileList[i]); > } > setBatchMode(false); > > > // END |
Hi,
On Aug 25, 2011, at 9:50 AM, Kirsten Scott wrote: > Hi Ben, > Thanks for your suggestion. > > Originally, I was not getting any errors - it just wasn't even starting to run. > > I have now tried using your method - the problem lies with the way the macro is constructed - the pathToBlurredImage is actually the input file so it is this variable that needs to have an associated array but I haven't been able to get this variable to look in my array (see below with your alterations). > > The error I get is with line 9 - it says 'unidentified variable in line 9' - I have tried lots of different combinations, including substituting input with pathToBlurredImage. Aha! That line has yet to be closed with a semicolon. (I hate it when that happens!) Cheers, Ben > > I am pretty sure it's something obvious I've missed. > > Thanks again for the suggestion - I will use this for macros in the future. > > Kirsten > > > > > //START > // reads a file and then writes it > // note I squeeze the path separator in there > function action(input, output, filename) { > open(input + File.separator + filename); > save(output + File.separator + filename); > close(); > } > pathToBlurredImage = input > pathToPsf = "/Users/kirstenscott/Desktop/grain-psf.tif"; > pathToDeblurredImage = output; > boundary = "REFLEXIVE"; //available options: REFLEXIVE, PERIODIC, ZERO > resizing = "AUTO"; // available options: AUTO, MINIMAL, NEXT_POWER_OF_TWO > output = "SAME_AS_SOURCE"; // available options: SAME_AS_SOURCE, BYTE, > SHORT, FLOAT > precision = "SINGLE"; //available options: SINGLE, DOUBLE > threshold = "-1"; //if -1, then disabled > maxIters = "5"; > nOfThreads = "2"; > showIter = "false"; > gamma = "0"; > filterXY = "1.0"; > normalize = "false"; > logMean = "false"; > antiRing = "true"; > changeThreshPercent = "0.01"; > db = "false"; > detectDivergence = "true"; > call("edu.emory.mathcs.restoretools.iterative.ParallelIterativeDeconvolution2D.deconvolveWPL", > pathToBlurredImage, pathToPsf, pathToDeblurredImage, boundary, resizing, > output, precision, threshold, maxIters, nOfThreads, showIter, gamma, > filterXY, normalize, logMean, antiRing, changeThreshPercent, db, > detectDivergence); > close(); > > // I split the sample "bat-cochlea-volume" into individual images > // check out that I did not use the closing path separator > input = "/Users/kirstenscott/Desktop/variation_study_output" > // I manually created this output directory > output = input + "-out"; > if (!File.exists(output)) File.makeDirectory(output); > > > setBatchMode(true); > > // I shy away from using 'list' as a variable name now that Wayne has added the "List" functions > // so I called it fileList > fileList = getFileList(input); > for (i = 0; i < fileList.length; i++){ > action(input, output, fileList[i]); > } > setBatchMode(false); > > > // END > > > > On 25 Aug 2011, at 14:32, Ben Tupper wrote: > >> //START >> // reads a file and then writes it >> // note I squeeze the path separator in there >> function action(input, output, filename) { >> open(input + File.separator + filename); >> save(output + File.separator + filename); >> close(); >> } >> >> // I split the sample "bat-cochlea-volume" into individual images >> // check out that I did not use the closing path separator >> input = "/Users/ben/bat"; >> // I manually created this output directory >> output = input + "-out"; >> if (!File.exists(output)) File.makeDirectory(output); >> >> >> setBatchMode(true); >> >> // I shy away from using 'list' as a variable name now that Wayne has added the "List" functions >> // so I called it fileList >> fileList = getFileList(input); >> for (i = 0; i < fileList.length; i++){ >> action(input, output, fileList[i]); >> } >> setBatchMode(false); >> >> >> // END |
Hi Ben,
Annoyingly I tried that... it still comes up with the same error with <input> in brackets as the offending word. It doesn't seem to be pulling up my input files for some reason. I can't believe I have spent all day trying to get this to work! Thanks so much for your suggestions. Kirsten On 25 Aug 2011, at 15:02, Ben Tupper wrote: > Hi, > > On Aug 25, 2011, at 9:50 AM, Kirsten Scott wrote: > >> Hi Ben, >> Thanks for your suggestion. >> >> Originally, I was not getting any errors - it just wasn't even starting to run. >> >> I have now tried using your method - the problem lies with the way the macro is constructed - the pathToBlurredImage is actually the input file so it is this variable that needs to have an associated array but I haven't been able to get this variable to look in my array (see below with your alterations). >> >> The error I get is with line 9 - it says 'unidentified variable in line 9' - I have tried lots of different combinations, including substituting input with pathToBlurredImage. > > Aha! That line has yet to be closed with a semicolon. (I hate it when that happens!) > > Cheers, > Ben > > > > >> >> I am pretty sure it's something obvious I've missed. >> >> Thanks again for the suggestion - I will use this for macros in the future. >> >> Kirsten >> >> >> >> >> //START >> // reads a file and then writes it >> // note I squeeze the path separator in there >> function action(input, output, filename) { >> open(input + File.separator + filename); >> save(output + File.separator + filename); >> close(); >> } >> pathToBlurredImage = input >> pathToPsf = "/Users/kirstenscott/Desktop/grain-psf.tif"; >> pathToDeblurredImage = output; >> boundary = "REFLEXIVE"; //available options: REFLEXIVE, PERIODIC, ZERO >> resizing = "AUTO"; // available options: AUTO, MINIMAL, NEXT_POWER_OF_TWO >> output = "SAME_AS_SOURCE"; // available options: SAME_AS_SOURCE, BYTE, >> SHORT, FLOAT >> precision = "SINGLE"; //available options: SINGLE, DOUBLE >> threshold = "-1"; //if -1, then disabled >> maxIters = "5"; >> nOfThreads = "2"; >> showIter = "false"; >> gamma = "0"; >> filterXY = "1.0"; >> normalize = "false"; >> logMean = "false"; >> antiRing = "true"; >> changeThreshPercent = "0.01"; >> db = "false"; >> detectDivergence = "true"; >> call("edu.emory.mathcs.restoretools.iterative.ParallelIterativeDeconvolution2D.deconvolveWPL", >> pathToBlurredImage, pathToPsf, pathToDeblurredImage, boundary, resizing, >> output, precision, threshold, maxIters, nOfThreads, showIter, gamma, >> filterXY, normalize, logMean, antiRing, changeThreshPercent, db, >> detectDivergence); >> close(); >> >> // I split the sample "bat-cochlea-volume" into individual images >> // check out that I did not use the closing path separator >> input = "/Users/kirstenscott/Desktop/variation_study_output" >> // I manually created this output directory >> output = input + "-out"; >> if (!File.exists(output)) File.makeDirectory(output); >> >> >> setBatchMode(true); >> >> // I shy away from using 'list' as a variable name now that Wayne has added the "List" functions >> // so I called it fileList >> fileList = getFileList(input); >> for (i = 0; i < fileList.length; i++){ >> action(input, output, fileList[i]); >> } >> setBatchMode(false); >> >> >> // END >> >> >> >> On 25 Aug 2011, at 14:32, Ben Tupper wrote: >> >>> //START >>> // reads a file and then writes it >>> // note I squeeze the path separator in there >>> function action(input, output, filename) { >>> open(input + File.separator + filename); >>> save(output + File.separator + filename); >>> close(); >>> } >>> >>> // I split the sample "bat-cochlea-volume" into individual images >>> // check out that I did not use the closing path separator >>> input = "/Users/ben/bat"; >>> // I manually created this output directory >>> output = input + "-out"; >>> if (!File.exists(output)) File.makeDirectory(output); >>> >>> >>> setBatchMode(true); >>> >>> // I shy away from using 'list' as a variable name now that Wayne has added the "List" functions >>> // so I called it fileList >>> fileList = getFileList(input); >>> for (i = 0; i < fileList.length; i++){ >>> action(input, output, fileList[i]); >>> } >>> setBatchMode(false); >>> >>> >>> // END |
In reply to this post by BenTupper
I need to put a logo image onto all of the images in an image sequence. I have been trying to use Image->Overlay.
I can see the logo image on each image of the image sequence, but when I save it to AVI or a TIFF image sequence, the logo image is not saved. Does anyone know how to do this? Thank you, Frank --____YUCTQXTVKENQCEVMOQLH____-- --____FUVZTDRKMZEZUOIYUGMP____-- --____NAHJDVUMOQDZLJNOLOAF____-- --____UPPWIZZJJJZEVSCNAGLP____-- |
You need to flatten the image before saving it. Image->Overlay->Flatten
Phil On Aug 25, 2011, at 10:16 AM, Franklin Shaffer wrote: > I need to put a logo image onto all of the images in an image sequence. I have been trying to use Image->Overlay. > I can see the logo image on each image of the image sequence, but when I save it to AVI or a TIFF image sequence, the logo image is not saved. > > Does anyone know how to do this? > > Thank you, > Frank > > > --____YUCTQXTVKENQCEVMOQLH____-- > > --____FUVZTDRKMZEZUOIYUGMP____-- > > --____NAHJDVUMOQDZLJNOLOAF____-- > > --____UPPWIZZJJJZEVSCNAGLP____-- > > > <Franklin Shaffer.vcf> Philip R. Ershler Ph.D. University of Utah Cardiovascular Research and Training Institute 95 South 2000 East Salt Lake City, UT 84112-5000 phone: (801) 230-8771 alt ph: (801) 587-9528 fax: (801) 581-3128 e-mail: [hidden email] |
I tried that. I have an image sequence upon which I've overlain a single logo image. When I use Flatten, it generates only one image with the logo on it.
>>> "Philip Ershler" <[hidden email]> 8/25/2011 12:27 PM >>> You need to flatten the image before saving it. Image->Overlay->Flatten Phil On Aug 25, 2011, at 10:16 AM, Franklin Shaffer wrote: > I need to put a logo image onto all of the images in an image sequence. I have been trying to use Image->Overlay. > I can see the logo image on each image of the image sequence, but when I save it to AVI or a TIFF image sequence, the logo image is not saved. > > Does anyone know how to do this? > > Thank you, > Frank > > > --____YUCTQXTVKENQCEVMOQLH____-- > > --____FUVZTDRKMZEZUOIYUGMP____-- > > --____NAHJDVUMOQDZLJNOLOAF____-- > > --____UPPWIZZJJJZEVSCNAGLP____-- > > > <Franklin Shaffer.vcf> Philip R. Ershler Ph.D. University of Utah Cardiovascular Research and Training Institute 95 South 2000 East Salt Lake City, UT 84112-5000 phone: (801) 230-8771 alt ph: (801) 587-9528 fax: (801) 581-3128 e-mail: [hidden email] |
In reply to this post by Franklin Shaffer-2
How about using:
Image -> Stacks -> Tools -> Insert... -Ved |
Free forum by Nabble | Edit this page |