Skip to content
Snippets Groups Projects
Commit 7c8c67e4 authored by Marius Hintsche's avatar Marius Hintsche
Browse files

handle last substack properly

parent 4751b12e
No related branches found
No related tags found
No related merge requests found
......@@ -27,22 +27,43 @@ setBatchMode(true);
methodPrefix = replace(method,' ','-');
iMax = floor(nSlices()/subStackSize)+1;
print("Saving result files to "+basePath+" ...");
for (i=0; i<=iMax; i++) {
for (i=0; i<(iMax-1); i++) {
//TODO handle smaller substack at the end of original stack
start=i*subStackSize+1;
stop=start+subStackSize;
run("Duplicate...", "title=SubStack"+i+" duplicate range="+start+"-"+stop);
run("Z Project...", "start=1 stop="+(subStackSize+1)+" projection=["+method+"]");
calculateProjection(start,stop,i,method);
print(methodPrefix+"_"+IJ.pad(start,5)+"-"+IJ.pad(stop,5)+".tif");
run("Save", "save=["+basePath+methodPrefix+"_"+IJ.pad(start,5)+"-"+IJ.pad(stop,5)+".tif]");
showProgress(i/iMax);
close();
function saveSlice(basePath,methodPrefix,start,stop);
selectWindow("SubStack"+i);
close();
selectImage(myStack);
}
//Handle last substack separately
start=(iMax-1)*subStackSize+1;
stop=nSlices();
calculateProjection(start,stop,i,method);
print(methodPrefix+"_"+IJ.pad(start,5)+"-"+IJ.pad(stop,5)+".tif");
function saveSlice(basePath,methodPrefix,start,stop);
selectWindow("SubStack"+i);
close();
selectImage(myStack);
tStop = getTime();
walltime = (tStop-tStart)/1000/60;
setBatchMode(false);
//TODO open completed Max Proj Stack
print("Done! (took "+d2s(walltime,1)+" min to complete.");
function calculateProjection(iStart,iStop,nSlice,method) {
run("Duplicate...", "title=SubStack"+nSlice+" duplicate range="+iStart+"-"+iStop);
run("Z Project...", "start=1 stop="+(iStop-iStart+1)+" projection=["+method+"]");
}
function saveSlice(path,prefix,iStart,iStop) {
//TODO save result as tiff stack
run("Save", "save=["+path+prefix+"_"+IJ.pad(start,5)+"-"+IJ.pad(iStop,5)+".tif]");
showStatus("Grouped Stack Proj. ("+i+"/"+iMax+"):");
showProgress(i/iMax);
close();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment