Created
June 19, 2019 10:51
-
-
Save jcasado/22d89926c51ab7b23d02ba158f3bedfd to your computer and use it in GitHub Desktop.
Fiji script to convert multipage TIFF 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
// Prepare file formats for segmentation workflow: Ilastik + Cell Profiler + HistoCAT | |
// Input must be a folder with multipage TIFF files, one for each sample or core | |
// 19.6.2019 Julia and Nuppu | |
basePath = "/path/to/project/folder/"; | |
coreStacks = "tiff/files/folder/"; | |
for_histocat = "for_histocat/"; //Where to save Image sequences | |
for_ilastik = "for_ilastik/"; //Where to save .h5 files | |
function processCore(dir, filename, for_histocat, for_ilastik) { | |
// Open multipage TIFF file | |
run("Bio-Formats Windowless Importer", "open="+dir + filename); | |
// Get name | |
dotIndex = indexOf(filename, "."); | |
coreName = substring(filename, 0, dotIndex); | |
// Save for Histocat | |
newDir = for_histocat + coreName; | |
File.makeDirectory(newDir); | |
run("Image Sequence... ", "format=TIFF name="+coreName+"_ digits=2 save="+newDir+"/"+coreName+"_00.tif"); | |
// Save for Ilastik | |
run("Properties...", "channels=32 slices=1 frames=1 unit=pixel pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000 global"); | |
run("Export HDF5", "select="+for_ilastik+coreName+".h5 exportpath="+for_ilastik+coreName+".h5 datasetname=data compressionlevel=0 input="+filename); | |
close(); | |
} | |
dir = basePath + coreStacks; | |
setBatchMode(true); | |
coreList = getFileList(dir); | |
// Iterate over all cores | |
for (i = 0; i < corelist.length; i++) | |
processCore(dir, coreList[i], basePath + for_histocat, basePath + for_ilastik); | |
setBatchMode(false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment