Hi all,
I am trying to make a macro to process data from MRI (usually many folders at once) in a way that I don't have to do anything else than set the input and output folders. The folder structure is the same for every measurement so, it is a viable approach. The macro works just as it should untill the moment it is supposed to save the image sequence (alternating 5 or 10 images). It opens the file in folder structure, it creates a folder in the output folder, for an unknown reason it doesn't save anything and even doesn't show a sign of error, closes the images and moves on. Last folder gives an error in a way that there is some bracket expected. Thank you in advance, Jakub Macroinput=input_images+input_folder; output=output_images + output_folder; setBatchMode(true); list = getFileList(input); list=Array.trim(list, list.length-3); //last 3 files in the folder don't contain images for (i = 0; i < list.length; i++) save_all(input, output, list[i]); setBatchMode(false); function save_all(input, output, filename) { input_file=filename+"pdata\\1\\2dseq"; file=input+input_file; File.makeDirectory(output+filename) open(file); fileNameStack="2dseq.png"; //this can be anything as long as there are numbers of the stack position run("Image Sequence... ", "format=PNG name="+fileNameStack+" digits=2 save=[output+filename]); close(); } |
Hi Jakub,
if you write run("Image Sequence... ", "format=... save=[output+filename]); it tries to save the image sequence in a directory named "output+filename" (literally), not in a directory named according to the contents of the variables output and filename. So you need run("Image Sequence... ", "format=... save=["+output+filename+"]"); The square brackets are needed to avoid truncating the file path (output+filename) in case there are spaces in it, they do not prevent the contents from being interpreted as a String. Example: "...save=[/users/jakub/data 1/test 17.png]" Michael ________________________________________________________________ On 2016-12-02 10:36, JakubD wrote: > Hi all, > > I am trying to make a macro to process data from MRI (usually many folders > at once) in a way that I don't have to do anything else than set the input > and output folders. The folder structure is the same for every measurement > so, it is a viable approach. > > The macro works just as it should untill the moment it is supposed to save > the image sequence (alternating 5 or 10 images). It opens the file in folder > structure, it creates a folder in the output folder, for an unknown reason > it doesn't save anything and even doesn't show a sign of error, closes the > images and moves on. Last folder gives an error in a way that there is some > bracket expected. > > Thank you in advance, > Jakub > > Macro > > > input=input_images+input_folder; > output=output_images + output_folder; > > > setBatchMode(true); > list = getFileList(input); > list=Array.trim(list, list.length-3); //last 3 files in the folder don't > contain images > > for (i = 0; i < list.length; i++) > save_all(input, output, list[i]); > setBatchMode(false); > > > > function save_all(input, output, filename) { > > input_file=filename+"pdata\\1\\2dseq"; > file=input+input_file; > > File.makeDirectory(output+filename) > > open(file); > > fileNameStack="2dseq.png"; //this can be anything as long as there are > numbers of the stack position > > run("Image Sequence... ", "format=PNG name="+fileNameStack+" digits=2 > save=[output+filename]); > close(); > } > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Macro-for-Image-sequence-tp5017672.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 |
Free forum by Nabble | Edit this page |