Skip to content

Instantly share code, notes, and snippets.

@tferr
Last active December 4, 2019 09:44
Show Gist options
  • Save tferr/e8e1498837e114313dd2ffb1b10d9805 to your computer and use it in GitHub Desktop.
Save tferr/e8e1498837e114313dd2ffb1b10d9805 to your computer and use it in GitHub Desktop.
Fiji script for extracting image data from HDF5 files
#@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