Last active
December 18, 2015 16:49
-
-
Save ackman678/5813956 to your computer and use it in GitHub Desktop.
An ImageJ macro that performs image registration using the [StackReg](http://bigwww.epfl.ch/thevenaz/stackreg/) plugin on all the TIFF movies in a folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "BatchStackreg" by James Ackman June 7, 2007 | |
// | |
// This macro batch processes all the files in a folder and any | |
// subfolders in that folder. In this example, it runs the Stackreg plugin for automatic | |
// image registration of multipageTIFF files. Stackreg plugin must be installed. | |
// For other kinds of processing, edit the processFile() function at the end of this macro. | |
// Based on the BatchProcessFolders.txt macro on the ImageJ website. | |
requires("1.33s"); | |
dir = getDirectory("Choose a Directory "); | |
//setBatchMode(true); | |
count = 0; | |
countFiles(dir); | |
n = 0; | |
processFiles(dir); | |
print(count+" files processed"); | |
function countFiles(dir) { | |
list = getFileList(dir); | |
for (i=0; i<list.length; i++) { | |
if (endsWith(list[i], "/")) | |
countFiles(""+dir+list[i]); | |
else | |
count++; | |
} | |
} | |
function processFiles(dir) { | |
list = getFileList(dir); | |
for (i=0; i<list.length; i++) { | |
if (endsWith(list[i], "/")) | |
processFiles(""+dir+list[i]); | |
else { | |
showProgress(n++, count); | |
path = dir+list[i]; | |
processFile(path); | |
} | |
} | |
} | |
function processFile(path) { | |
if (endsWith(path, ".tif")) { | |
open(path); | |
num=nSlices; | |
if (num >200) { | |
run("StackReg ", "transformation=[Rigid Body]"); | |
} | |
//run("Subtract Background...", "rolling=50 white"); | |
save(path); | |
close(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment