macro "Composite_Stack_Split_and_Save" { //do file dialog stuff path = File.openDialog("Select a File"); //open(path); // open the file dir = File.getParent(path); name = File.getName(path); print("Path:", path); print("Name:", name); //open image run("Bio-Formats Importer", "open="+path+" view=[Standard ImageJ] stack_order=Default use_virtual_stack"); //get number of z slices and times Dialog.create("Divide up images"); Dialog.addNumber("Number of Z-slices per time series:", 0); Dialog.addNumber("Number of time series:", 0); Dialog.show() no_z_stack = Dialog.getNumber(); no_time_series = Dialog.getNumber(); print("number of slices per stack:" + no_z_stack); print("number of times series in composite stack:" + no_time_series); //do my stuff itr = 0; for (j = 1; j < ((no_z_stack * no_time_series) - no_z_stack); j = j + no_z_stack) { jString = toString(j); jEndString = toString(j+no_z_stack-1); subStackString = jString+"-"+jEndString; print("getting stack index: " + j + " to: " + jEndString); //extract a substack run("Substack Maker", "slices="+subStackString); //do some processing run("8-bit"); run("Smooth", "stack"); //save substack saveAs("Tiff",""+File.directory +"Stack_"+itr); //print("saving:"+File.directory +"Stack_"+itr); //close window close(); //inc itr itr = itr + 1; } print("ALL DONE! YAY!"); }