// This macro take user input single Leica .lif file and output every single image data set as .tif format // macro will create a sub-folder with same name of the input .lif file, under the same folder of .lif file. // the macro requires Bio-Format plugin installed. // user choose .lif file path = File.openDialog("user Select .lif file"); dir = File.getParent(path); name = File.getName(path); print(dir); // create sub-folder to store individual tiff images. newname=substring(name, 0, indexOf(name, ".lif")); dir1=dir+"/" + newname; File.makeDirectory(dir1); dir1=dir+"/"+newname+"/"; // read how many files in .lif file run("Bio-Formats Macro Extensions"); Ext.setId(path); Ext.getSeriesCount(seriesCount); // batch process begins setBatchMode(true); // loop through all individual image in .lif for(i=1; i<=seriesCount; i++) { run("Bio-Formats Importer", "open=["+path+"] color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT series_"+i); tmpname=substring(getTitle(), indexOf( getTitle(), ".lif - ")+7, lengthOf( getTitle() )); rename(tmpname); getDimensions(width, height, channels, slices, frames); if( channels > 1 ) { run("Split Channels"); for(c=1; c<=channels; c++) { selectWindow("C"+c+"-"+tmpname); saveAs("Tiff", dir1+tmpname+"_C"+c+".tif"); close(); } } else { saveAs("Tiff", dir1+tmpname+".tif"); close(); } // print progress print("\\Clear"); print("Finish "+i+" files of total "+ seriesCount +" files"); }