Last active
December 4, 2019 09:44
-
-
Save tferr/e8e1498837e114313dd2ffb1b10d9805 to your computer and use it in GitHub Desktop.
Fiji script for extracting image data from HDF5 files
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
#@File(style="directory", label="Input directory containing H5 files") inDir | |
#@File(style="directory", label="Output directory for saving converted TIFFs") outDir | |
import static groovy.io.FileType.FILES | |
import sc.fiji.hdf5.HDF5ImageJ | |
import ij.IJ | |
inDir.eachFileRecurse(FILES) { file -> | |
if (file.name.endsWith(".h5")) { | |
println("Converting "+ file) | |
imp = HDF5ImageJ.hdf5read(file.getAbsolutePath(), "/Data") | |
if (imp == null) { | |
print(" Error! something failed") | |
} else { | |
outFile = new File(outDir, file.name.replace(".h5", ".tif")) | |
IJ.save(imp, outFile.getAbsolutePath()) | |
} | |
if (imp.isVisible()) imp.close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment