Hi to all,
Although I am not new to creating macros to automate my work, I am not an
experienced macro writer but rather create my macros by the model Record...
-> Adapt the recorded commands
Recently my lazyness prompted me to create a macro for saving images stored
in a folder into image stacks (sequences) using criteria stored in a text
file.
E.g. I have a folder of images named animal1-1, 2,3 etc, animal2-1,2,3 etc
etc.. So I wanted to create separate image sequences from all images
belonging to animal1, animal2 etc. with as little interaction as possible.
I looked everywhere but couldn't find anything that was already created so
combining several ideas from different similar macros i came up with the
following code:
---
//create image sequence
inputDir1 = getDirectory("Choose directory with the images to be added! ");
outputDir = getDirectory("Choose Output directory for the sequences! ");
b = getString("Chose Sequence Name:", "Top-Hat");
showMessage("Instruction", "Choose file with criteria for selection. \nThe
text file must be in the format <key> TAB <criteria> \n \n");
pathcriteria=File.openDialog("Choose text file!");
setBatchMode(true);
criteria=File.openAsString(pathcriteria);
rows=split(criteria, "\n");
x=newArray(rows.length);
y=newArray(rows.length);
for(i=0; i<rows.length; i++){
columns=split(rows[i],"\t");
y[i]=toString(columns[1]);
a=y[i];
run("Image Sequence...", "open=&inputDir1 file=&a sort use");
saveAs("tiff", outputDir+b+a);
close();
}
showMessage("Finished");
---
It gets the job done, but I can't help but think that there might be a more
elegant and fast way to do the same (frankly right now the macro runs
rather slow andburdens my machine as well).
So I am asking if anyone of the macro mages out there could give some
advice on polishing this macro a bit!
Thank you in advance!
Stoyan
---
Dr. Stoyan P. Pavlov, MD, PhD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
Bulgaria
Tel: +359 (0) 52 - 677 - 052
e-mail:
[hidden email]
[hidden email]
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html