documents:101029imagej_cui_lifconversion
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
documents:101029imagej_cui_lifconversion [2010/10/29 15:38] – kota | documents:101029imagej_cui_lifconversion [2010/10/29 15:54] – added macro kota | ||
---|---|---|---|
Line 114: | Line 114: | ||
Each file would have a single image plane. | Each file would have a single image plane. | ||
</ | </ | ||
+ | |||
+ | ===== LifOpenerCUI.ijm ===== | ||
+ | |||
+ | ImageJ macro for converting LIF stack series to multiple tiff stacks, together with setting physical parameters. | ||
+ | < | ||
+ | // converts LIF file to channel-separated tif stacks. | ||
+ | // output files will be saved under the folder <LIF file name> | ||
+ | |||
+ | //bach command example | ||
+ | /* | ||
+ | / | ||
+ | */ | ||
+ | // TODO: scale should be set as the propertiy of tiff file. | ||
+ | // reading out of the scale from LIF is somehow not working, unlike it was done in 2009 | ||
+ | // metadata of .lif file would be saved as < | ||
+ | //will be saved in the same directory. | ||
+ | // TODO: program might return error if sequence is terminated abruptly. | ||
+ | |||
+ | // for setting scale, plugin " ImpProp.class" | ||
+ | |||
+ | srcfile = getArgument(); | ||
+ | // srcfile = File.openDialog(" | ||
+ | requires(" | ||
+ | run(" | ||
+ | |||
+ | path = srcfile; | ||
+ | name = File.getName(path); | ||
+ | dir = File.getParent(path); | ||
+ | DAPIch = 0;// | ||
+ | FISHch = 1;// | ||
+ | metaname = name + " | ||
+ | |||
+ | q = File.separator; | ||
+ | metafullpath = dir+q+metaname; | ||
+ | metastr = File.openAsString(metafullpath); | ||
+ | workdir = File.getParent(srcfile); | ||
+ | |||
+ | //create " | ||
+ | pathtifstack = workdir + q + name+ " | ||
+ | if (File.isDirectory(pathtifstack)==0) File.makeDirectory(pathtifstack); | ||
+ | |||
+ | Ext.setId(path); | ||
+ | Ext.getSeriesCount(seriesCount); | ||
+ | Ext.getCurrentFile(file); | ||
+ | Ext.close(); | ||
+ | print(" | ||
+ | print(" | ||
+ | |||
+ | for (s=0; s< | ||
+ | |||
+ | seriesNum = s; | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | |||
+ | if (s>0) refresh =0; | ||
+ | |||
+ | seriesName = OpenLIFSeriesOneChannel(path, | ||
+ | G_GID = getImageID(); | ||
+ | savepath = pathtifstack + q+getTitle(); | ||
+ | print(savepath); | ||
+ | saveAs(" | ||
+ | close(); | ||
+ | |||
+ | OpenLIFSeriesOneChannel(path, | ||
+ | G_RID = getImageID(); | ||
+ | savepath = pathtifstack | ||
+ | print(savepath); | ||
+ | saveAs(" | ||
+ | close(); | ||
+ | } | ||
+ | |||
+ | |||
+ | // | ||
+ | /* 090907 | ||
+ | 090908 | ||
+ | - save tif file in a specified directory | ||
+ | - problem with DAPI appearance in the resulting window. | ||
+ | */ | ||
+ | function OpenLIFSeriesOneChannel(id, | ||
+ | run(" | ||
+ | |||
+ | //if (datasetOpened ==0) Ext.setId(id); | ||
+ | Ext.setId(id); | ||
+ | Ext.setSeries(seriesNum); | ||
+ | Ext.getSeriesName(seriesName); | ||
+ | Ext.getSizeZ(sizeZ); | ||
+ | Ext.getSizeC(sizeC); | ||
+ | Ext.getSizeT(sizeT); | ||
+ | Ext.getImageCount(imageCount); | ||
+ | print(" | ||
+ | calculatedCount = sizeZ*sizeC*sizeT; | ||
+ | print(" | ||
+ | if (imageCount != calculatedCount) { | ||
+ | print(); | ||
+ | exit(); | ||
+ | } | ||
+ | sizeT = imageCount/ | ||
+ | print(" | ||
+ | newname = name+" | ||
+ | setBatchMode(true); | ||
+ | for (j=0; j<sizeT; j++){ | ||
+ | for (i=0; i<sizeZ; i++){ | ||
+ | currentZch0 = i*sizeC; | ||
+ | currentPlane = j*sizeZ*sizeC + i*sizeC; | ||
+ | Ext.openImage(" | ||
+ | if ((i==0) && (j==0)) | ||
+ | stackID=getImageID(); | ||
+ | else { | ||
+ | run(" | ||
+ | close; | ||
+ | selectImage(stackID); | ||
+ | run(" | ||
+ | run(" | ||
+ | } | ||
+ | // | ||
+ | } | ||
+ | } | ||
+ | rename(newname); | ||
+ | xscale = returnXscale(metastr); | ||
+ | yscale = returnYscale(metastr); | ||
+ | zscale = returnZscale(metastr); | ||
+ | tscale = 1;// | ||
+ | xscalemicron = parseFloat(xscale) * pow(10, 6); | ||
+ | yscalemicron = parseFloat(yscale) * pow(10, 6); | ||
+ | zscalemicron = parseFloat(zscale) * pow(10, 6); | ||
+ | op = " | ||
+ | //since run(" | ||
+ | // | ||
+ | // ImpProp.class | ||
+ | SsizeC = "" | ||
+ | SsizeZ = "" | ||
+ | SsizeT = "" | ||
+ | Sxscalemicron = "" | ||
+ | Syscalemicron = "" | ||
+ | Szscalemicron = "" | ||
+ | call(" | ||
+ | SsizeC, SsizeZ, SsizeT, " | ||
+ | Sxscalemicron, | ||
+ | |||
+ | setBatchMode(false); | ||
+ | //if (datasetOpened ==0) Ext.close(); | ||
+ | Ext.close(); | ||
+ | return seriesName; | ||
+ | } | ||
+ | |||
+ | //zscale in micron | ||
+ | function returnZscale(metastr){ | ||
+ | metaA = split(metastr, | ||
+ | zscale = 1; | ||
+ | for (i=0; i< | ||
+ | if (startsWith(metaA[i], | ||
+ | lineA = split(metaA[i], | ||
+ | //for (j=0; j< | ||
+ | if (lineA.length> | ||
+ | zscale = parseFloat(lineA[2]); | ||
+ | print(zscale); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | return zscale; | ||
+ | } | ||
+ | |||
+ | //Xscale in micron | ||
+ | function returnXscale(metastr){ | ||
+ | metaA = split(metastr, | ||
+ | xscale = 1; | ||
+ | for (i=0; i< | ||
+ | if (startsWith(metaA[i], | ||
+ | lineA = split(metaA[i], | ||
+ | //for (j=0; j< | ||
+ | if (lineA.length> | ||
+ | xscale = parseFloat(lineA[2]); | ||
+ | print(xscale); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | return xscale; | ||
+ | } | ||
+ | |||
+ | function returnYscale(metastr){ | ||
+ | metaA = split(metastr, | ||
+ | yscale = 1; | ||
+ | for (i=0; i< | ||
+ | if (startsWith(metaA[i], | ||
+ | lineA = split(metaA[i], | ||
+ | //for (j=0; j< | ||
+ | if (lineA.length> | ||
+ | yscale = parseFloat(lineA[2]); | ||
+ | print(yscale); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | return yscale; | ||
+ | } | ||
+ | |||
+ | function returnTscale(){ | ||
+ | metaA = split(metastr, | ||
+ | for (i=0; i< | ||
+ | if (startsWith(metaA[i], | ||
+ | lineA = split(metaA[i], | ||
+ | //for (j=0; j< | ||
+ | if (lineA.length> | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ |
documents/101029imagej_cui_lifconversion.txt · Last modified: 2020/11/26 09:11 by 127.0.0.1