def split_channels_red(imp): #Create red channel original_red = ChannelSplitter.getChannel(imp, 1) original_red_IP = ImagePlus(filename, original_red) fs = FileSaver(original_red_IP) folder = "/Users/gceleste/Desktop/test/channels" filepath = folder + "/" + "{}_redchannel.tif".format(filename) fs.saveAsTiff(filepath) #Open red channel image. red = IJ.open(filepath) #red_IP = ImagePlus(filename, red) IJ.run( "3D Objects Counter", "threshold=130 slice=1 min.=50 max.=1447680 exclude_objects_on_edges objects summary" ) #Save red object map. red_map = IJ.getImage() fs = FileSaver(red_map) folder = "/Users/gceleste/Desktop/test/object maps" filepath = folder + "/" + "{}_objectmap(red).jpg".format(filename) fs.saveAsJpeg(filepath) #Close red channel images. red_map.close() red = IJ.getImage() red.close()
def resizeAndSave(filePaths, l): while l.get() < min(len(filePaths), currentWrittenLayer + nTilesAtATime + 1) : k = l.getAndIncrement() if k < min(len(filePaths), currentWrittenLayer + nTilesAtATime): filePath = filePaths[k] imageName = os.path.basename(filePath) resizedImageName = os.path.splitext(imageName)[0] + '_resized_' + factorString + os.path.splitext(imageName)[1] imageFolderName = os.path.basename(os.path.dirname(filePath)) resizedFilePath = fc.cleanLinuxPath(os.path.join(downSampledEMFolder, imageFolderName, resizedImageName)) im = Opener().openImage(filePath) IJ.log('Am I going to process the image: im.height = ' + str(im.height) + ' - tileHeight = ' + str(tileHeight) + ' tile number ' + str(k)) if im.height == tileHeight: # crop a few lines at the top only if it has not already been done (sometimes the pipeline gets rerun) im = fc.crop(im,cropRoi) im = fc.normLocalContrast(im, normLocalContrastSize, normLocalContrastSize, 3, True, True) # IJ.run(im, 'Replace value', 'pattern=0 replacement=1') # only for final waferOverview FileSaver(im).saveAsTiff(filePath) if not os.path.isfile(resizedFilePath): im = fc.resize(im, scaleFactor) FileSaver(im).saveAsTiff(resizedFilePath) IJ.log('Image resized to ' + resizedFilePath) im.close()
def split_channels_blue(imp): #Create blue channel original_blue = ChannelSplitter.getChannel(imp, 3) original_blue_IP = ImagePlus(filename, original_blue) fs = FileSaver(original_blue_IP) folder = "/Users/gceleste/Desktop/test/channels" filepath = folder + "/" + "{}_bluechannel.tif".format(filename) fs.saveAsTiff(filepath) #Open blue channel image. blue = IJ.open(filepath) #blue_IP = ImagePlus(filename, blue) IJ.run( "3D Objects Counter", "threshold=100 slice=1 min.=50 max.=1447680 exclude_objects_on_edges objects summary" ) #Save blue object map blue_map = IJ.getImage() fs = FileSaver(blue_map) folder = "/Users/gceleste/Desktop/test/object maps" filepath = folder + "/" + "{}_objectmap(blue).jpg".format(filename) fs.saveAsJpeg(filepath) #Close blue channel image. blue_map.close() blue = IJ.getImage() blue.close()
def saveImage(imp, out_file): if overwritePref == overwriteChoices[0]: if not os.path.exists(out_file): FileSaver(imp).saveAsTiff(out_file) else: overwriteList.append(out_file) elif overwritePref == overwriteChoices[1]: if not os.path.exists(out_file): FileSaver(imp).saveAsTiff(out_file) else: overwriteList.append(out_file) FileSaver(imp).saveAsTiff(out_file)
def generate_limit_labels(imp, limits, cb_fraction, params): """generate text ROIs in correct positions to label colorbar""" rois = [] w = imp.getWidth() h = imp.getHeight() txt_h_px = float(h) / 15 txt_sz_pt = int(round((18.0 / 24.0) * txt_h_px)) for limit in limits: roi = TextRoi(1, 1, str(round(limit, 3)), Font("SansSerif", Font.ITALIC, txt_sz_pt)) roi.setJustification(TextRoi.RIGHT) roi.setFillColor(Color.BLACK) roi.setStrokeColor(Color.WHITE) rois.append(roi) roim = RoiManager(False) roim.reset() imp.show() mbui.autoset_zoom(imp) for fridx in range(1, imp.getNSlices() + 1): imp.setPosition(fridx) roi_uu = rois[1].clone() xpos = w - cb_fraction * w - float(w) / 100 - rois[1].getFloatWidth() roi_uu.setLocation(xpos, 1) imp.setRoi(roi_uu) roim.addRoi(roi_uu) roi_ll = rois[0].clone() roi_ll.setLocation(xpos, h - rois[0].getFloatHeight()) imp.setRoi(roi_ll) roim.addRoi(roi_ll) roim.runCommand("Show All") FileSaver(imp).saveAsTiff( os.path.join(params.output_path, "overlaid curvature nudged labels.tif")) # nudge positions roim.reset() imp.killRoi() for fridx in range(1, imp.getNSlices() + 1): imp.setPosition(fridx) roi_uu = rois[1].clone() xpos = w - cb_fraction * w - float(w) / 100 roi_uu.setLocation(xpos, 1) imp.setRoi(roi_uu) roim.addRoi(roi_uu) roi_ll = rois[0].clone() roi_ll.setLocation(xpos, h - rois[0].getFloatHeight()) imp.setRoi(roi_ll) roim.addRoi(roi_ll) roim.runCommand("Show All") FileSaver(imp).saveAsTiff( os.path.join(params.output_path, "overlaid curvature.tif")) return imp
def saveCroppedROIs(self, event): """ Duplicates cropped ROIs and saves """ # Create export dir, if not already present current_export_dir = self.createExportDir("Cropped_ROI") for Image in self.Images.values(): # for all Image instances # save image cropped_copy = Image.imp.crop() # returns cropped image as an imp img_filename = os.path.join(current_export_dir, Image.title) if os.path.splitext(img_filename)[1] != ".tif": os.path.join(img_filename, ".tif") FileSaver(cropped_copy).saveAsTiff(img_filename) # save roi roi_filename = os.path.splitext(img_filename)[0] + "_roi.roi" roi = Image.imp.getRoi() if roi != None: rm = RM.getInstance() if rm == None: rm = RM() rm.addRoi(roi) rm.runCommand("Save", roi_filename) # which one does it save rm.runCommand("Delete") IJ.log("Cropped ROI saved: " + os.path.join(current_export_dir, Image.title))
def run(self): try: filepath = self.makeFilePath() if os.path.exists(filepath): return x, y, k = self.coords width, height, n_layers = self.dimensions # Cube's field of view in XY fov = Rectangle(x, y, width, height) # Join the bounds of the layers r = None for b in self.bounds[k:min(k + n_layers, len(bounds))]: if r is None: r = Rectangle(b.x, b.y, b.width, b.height) else: r.add(b) if not fov.intersects(r): # Would be empty return drawImage = Graphics2D.getDeclaredMethod( "drawImage", [Image, AffineTransform, ImageObserver]) drawImage.setAccessible(True) dispose = Graphics.getDeclaredMethod("dispose", []) dispose.setAccessible(True) # Populate and write cube stack = ImageStack(width, height) for layer in self.layers[k:min(k + n_layers, len(self.layers))]: img = layer.getProject().getLoader().getFlatAWTImage( layer, fov, 1.0, -1, ImagePlus.GRAY8, Patch, None, False, Color.black) bi = BufferedImage(img.getWidth(None), img.getHeight(None), BufferedImage.TYPE_BYTE_GRAY) g = bi.createGraphics() aff = AffineTransform(1, 0, 0, 1, 0, 0) #g.drawImage(img, aff, None) # Necessary to bypass issues that result in only using 7-bits and with the ByteProcessor constructor drawImage.invoke(g, [img, aff, None]) #g.dispose() dispose.invoke(g, []) g = None img = None stack.addSlice("", ByteProcessor(bi)) bi.flush() bi = None imp = ImagePlus("x=%s y=%s k=%s" % (x, y, k), stack) Utils.ensure(filepath) FileSaver(imp).saveAsZip(filepath) imp.flush() imp = None except: e = sys.exc_info() System.out.println("Error:" + str(e[0]) + "\n" + str(e[1]) + "\n" + str(e[2])) System.out.println(traceback.format_exception(e[0], e[1], e[2]))
def run(): srcDir = DirectoryChooser("Choose directory").getDirectory() if not srcDir: return targetDir = DirectoryChooser("Choose target directory").getDirectory() if targetDir is None: # User canceled the dialog return sId = ".tiff" for root, directories, filenames in os.walk(srcDir): for filename in filenames: path = os.path.join(root, filename) if not (sId in filename): continue cs = ChannelSeparator() cs.setId(path) print "cs", cs bf = BFVirtualStack(path, cs, False, False, False) for sliceIndex in xrange(1, bf.getSize() + 1): print "Processing slice", sliceIndex ip = bf.getProcessor(sliceIndex) sliceFileName = os.path.join(targetDir + filename + "_" + str(sliceIndex) + ".tiff") print "writing ", sliceFileName FileSaver(ImagePlus(str(sliceIndex), ip)).saveAsTiff(sliceFileName)
def SaveToZip(zf, ip, baseDir, counter): fs = FileSaver(ip) fs.setJpegQuality(75) fs.saveAsJpeg(baseDir + "/tmp.jpeg") zipName = str(counter) + ".jpeg" zf.write(baseDir + "/tmp.jpeg", arcname=zipName) os.remove(baseDir + "/tmp.jpeg")
def run(self): try: bounds = self.layer.getMinimalBoundingBox(Patch, True) filepath = os.path.join( self.target_dir, "section-" + str(self.i).zfill(5) + "-[x=" + str(bounds.x) + "-y=" + str(bounds.y) + "-width=" + str(bounds.width) + "-height=" + str(bounds.height) + "].zip") if os.path.exists(filepath): System.out.println("Skipping: " + filepath) return # Export System.out.println("Preparing: " + os.path.split(filepath)[1]) img = self.layer.getProject().getLoader().getFlatAWTImage( self.layer, bounds, 1.0, -1, ImagePlus.GRAY8, Patch, None, False, Color.black) bi = BufferedImage(img.getWidth(None), img.getHeight(None), BufferedImage.TYPE_BYTE_GRAY) g = bi.createGraphics() g.drawImage(img, 0, 0, None) g.dispose() g = None imp = ImagePlus(str(self.layer.getZ()), ByteProcessor(bi)) FileSaver(imp).saveAsZip(filepath) bi.flush() bi = None imp.flush() imp = None ip = None System.out.println("Saved: " + os.path.split(filepath)[1]) except: import sys e = sys.exc_info() System.out.println("Error:" + str(e[0]) + "\n" + str(e[1]) + "\n" + str(e[2]))
def run(): printLog("=====ZY_CreatTemp_V2====", 0) #Prompt user to open a image od = OpenDialog("Choose image file", None) if od is None: msgStr = "User Cancled" printLog(msgStr, 1) else: sourceFolder = od.getDirectory() fileName = od.getFileName() imp = IJ.openImage(sourceFolder + fileName) imp.show() n = imp.getNSlices() printLog("Processing source file: " + fileName, 1) imp2 = pickSlice(imp) if imp2: destFolder = os.path.join(sourceFolder, 'Temps') #outName = os.path.join(destFolder,fileName[:-4]+'_temp.tif') #remove the .tif in filename outName = os.path.join(destFolder, 'temp.tif') # check or make the folder if not os.path.isdir(destFolder): os.makedirs(destFolder) #make temp dupNSlice(imp2, n - 1) printLog("Saving to: " + outName, 1) fs = FileSaver(imp2) fs.saveAsTiffStack(outName) imp2.close() imp.close() msgStr = "ZY_CraetTemp_V2.py is Done." printLog(msgStr, 0)
def exportTifStack(self, destFolder=''): channelNumber = 1 for imp in self.channelImp: if not destFolder: destFolder = os.path.join(self.enclosingPath, self.enclosingfolder + '_tif') if not os.path.isdir(destFolder): os.makedirs(destFolder) if not imp: bPrintLog("ERROR: exportTifStack() did not find an imp at channel number '" + str(channelNumber) + "'", 0) return -1 self.updateInfoStr() imp.setProperty("Info", self.infoStr); saveFile = os.path.splitext(self.filename)[0] + '_ch' + str(channelNumber) + '.tif' savePath = os.path.join(destFolder, saveFile) # save fs = FileSaver(imp) bPrintLog('saveTifStack():' + savePath, 3) if imp.getNSlices()>1: fs.saveAsTiffStack(savePath) else: fs.saveAsTiff(savePath) channelNumber += 1
def save_qc_image(imp, rois, output_path): """save rois overlaid on imp to output_path""" imp.killRoi() if len(rois) > 0: roim = RoiManager(False) for roi in rois: roim.addRoi(roi) roim.runCommand("Show All with labels") RGBStackConverter.convertToRGB(imp) roim.moveRoisToOverlay(imp) FileSaver(imp).saveAsTiff(output_path) roim.runCommand("Show None") roim.close() else: FileSaver(imp).saveAsTiff(output_path) return
def makeStack(stackDir, stackName="stack"): IJ.run("Image Sequence...", "open=" + stackDir + " file = (\"img_.*\") sort") imp = IJ.getImage() #IJ.run("8-bit") fs = FileSaver(imp) print "Saving stack" fs.saveAsTiff(stackDir + "/" + stackName + ".tif")
def straighten(stackName): ''' IJ.run("Set Measurements...", "area mean min center redirect=None decimal=3") IJ.open(stackName) imp = IJ.getImage() stack = imp.getImageStack() for i in xrange(1, imp.getNSlices()+1): image = ImagePlus(str(i), stack.getProcessor(i)) xvals = [] yvals = [] maxvals = [] j = 0 for k in xrange(0, 512, 2): IJ.makeRectangle(k, 0, 4, 512) IJ.run("Measure") table = RT.getResultsTable() x = table.getValue("XM", 0) y = table.getValue("YM", 0) #maxi = IJ.getResult("Max") table = [] xvals.append(k) yvals.append(y) #maxvals.append(maxi) #if maxvals[j] == 0 and j > 0: #yvals[j] = yvals[j-1] j += 1 print "xvals:", xvals print "yvals:", yvals mr = MR() IJ.run("Make Selection...", "freeline, "+str(xvals)+" ,"+ str(yvals)) #IJ.runMacro("makeSelection...", "freeline, "+str(xvals)+" ,"+ str(yvals)); #IJ.run("makeSelection(\"freeline\", xvals, yvals);") #IJ.run("Straighten...", "line = 80") ''' IJ.open(stackName) imp = IJ.getImage() stack = imp.getImageStack() print imp.getNSlices() for i in range(1, imp.getNSlices() + 1): image = ImagePlus(str(i), stack.getProcessor(i)) IJ.runMacroFile( "/Users/juliansegert/repos/Bio119_root_tracking/straightenOneImage.ijm" ) newImp = WM.getCurrentImage() fs = FileSaver(newImp) fs.saveAsTiff( "/Users/juliansegert/Documents/Roots/Four_root_image_stacks/Pos01/" + str(i) + ".tif") newImp.close()
def saveTif(self, allowOverwrite=1): #make output folder if not os.path.isdir(self.dstFolder): os.makedirs(self.dstFolder) #ch1 if self.imp_ch1: #savePath = self.dstFolder + self.enclosingFolderName + '_ch1.tif' #save into new folder if os.path.isfile(self.savePath_ch1) and not allowOverwrite: print bPrintLog('File Exists NOT Saving: ' + savePath, 3) else: fs = FileSaver(self.imp_ch1) bPrintLog('Saving: ' + self.savePath_ch1, 3) if self.imp_ch1.getNSlices() > 1: fs.saveAsTiffStack(self.savePath_ch1) else: fs.saveAsTiff(self.savePath_ch1) #ch2 if self.imp_ch2: #save into new folder #savePath = self.dstFolder + self.enclosingFolderName + '_ch2.tif' #save into new folder if os.path.isfile(self.savePath_ch2) and not allowOverwrite: bPrintLog('File Exists NOT Saving: ' + self.savePath_ch2, 3) else: fs = FileSaver(self.imp_ch2) bPrintLog('Saving: ' + self.savePath_ch2, 3) if self.imp_ch2.getNSlices() > 1: fs.saveAsTiffStack(self.savePath_ch2) else: fs.saveAsTiff(self.savePath_ch2) #ch3 if self.imp_ch3: #save into new folder #savePath = self.dstFolder + self.enclosingFolderName + '_ch3.tif' #save into new folder if os.path.isfile(self.savePath_ch3) and not allowOverwrite: bPrintLog('File Exists NOT Saving: ' + self.savePath_ch3, 3) else: fs = FileSaver(self.imp_ch3) bPrintLog('Saving: ' + self.savePath_ch3, 3) if self.imp_ch3.getNSlices() > 1: fs.saveAsTiffStack(self.savePath_ch3) else: fs.saveAsTiff(self.savePath_ch3)
def bSaveStack(imp, fullPath): fs = FileSaver(imp) #print 'bSaveStack()', fullPath, 'nslices=', imp.getNSlices() bPrintLog('bSaveStack():' + fullPath + ' slices=' + str(imp.getNSlices()), 1) if imp.getNSlices() > 1: fs.saveAsTiffStack(fullPath) else: fs.saveAsTiff(fullPath)
def run(FolderName, SaveFolder): # Find tiffiles in folder onlyfiles = [f for f in os.listdir(FolderName) if os.path.isfile(os.path.join(FolderName, f)) and f.lower().endswith('.tif')] for ii in xrange(0, len(onlyfiles)): path = os.path.join(FolderName, onlyfiles[ii]) print "Processing file..", path # Find stimulus, Block, regions from filename for sorting # Get all underscores underscores = [m.start() for m in re.finditer('_', onlyfiles[ii])] # Fish Name findfish = onlyfiles[ii].find('Fish') findunderscore = [i for i in underscores if i > findfish][0] fishnum = onlyfiles[ii][findfish:findunderscore] print 'Fish Number..', fishnum # Block findblock = onlyfiles[ii].find('Block') findunderscore = [i for i in underscores if i > findblock][0] blocknum = onlyfiles[ii][findblock:findunderscore] print 'Block Number..', blocknum # Stimulus findstimulus = onlyfiles[ii].find('Blue') findunderscore = [i for i in underscores if i > findstimulus][0] stimulustype = onlyfiles[ii][findstimulus:findunderscore] print 'Stimulus type..', stimulustype # Region findregion = onlyfiles[ii].find('Hb') findunderscore = [i for i in underscores if i > findregion][0] region = onlyfiles[ii][findregion-1:findunderscore] print 'Region..', region targetDir = os.path.join(SaveFolder, fishnum, region) + filesep print 'Images will be saved in .....', targetDir if not os.path.exists(targetDir): os.makedirs(targetDir) cs = ChannelSeparator() cs.setId(path) bf = BFVirtualStack(path, cs, False, False, False) for sliceIndex in xrange(1,bf.getSize() + 1): print "Processing slice", sliceIndex ip = bf.getProcessor(sliceIndex) sliceFileName = os.path.join(targetDir, "T=" + str(sliceIndex) + ".tif") FileSaver(ImagePlus(str(sliceIndex), ip)).saveAsTiff(sliceFileName)
def saveFileImage(imagePlus, dumpSaveFilePath, dumpFileName): fileSaver = FileSaver(imagePlus) imageName = imagePlus.getTitle() #File.makeDirectory(dumpDirectory) dumpFileString = str(dumpSaveFilePath)+"/"+str(imageName)+"_"+str(dumpFileName) #filestring=File.openAsString(dumpFileString); #dumpFileString = str(dumpDirectory) #fileSaver.saveAsTiff(dumpFileString) #IJ.saveAsTiff(imagePlus,dumpFileString) IJ.saveAs(imagePlus, "Tiff", dumpFileString);
def save_tif(imps, new_name, new_dir): """ takes imps object and name string, saves as tif """ new_name = os.path.join(new_dir, new_name) if os.path.exists(new_name): print("File " + new_name + " exists, continuing") return else: fs = FileSaver(imps) fs.saveAsTiff(new_name)
def loadProcessAndSave(sourcepath, fn): try: imp = IJ.openImage(sourcepath) norm_imp = fn(imp) # invoke function 'fn', in this case 'normalizeContrast' targetpath = os.path.join(targetDir, os.path.basename(sourcepath)) if not targetpath.endswith(".tif"): targetpath += ".tif" FileSaver(norm_imp).saveAsTiff(targetpath) except: print "Could not load or process file:", filepath print sys.exc_info()
def covertTo8bitsBatch(folder_in,folder_out): for folder in os.listdir(folder_in): infolderpath = folder_in+folder outfolderpath = folder_out + folder os.mkdir(outfolderpath) for filename in os.listdir(infolderpath): imp = IJ.openImage(os.path.join(infolderpath, filename)) IJ.run(imp, "8-bit", "") fs = FileSaver(imp) filepath = os.path.join(outfolderpath, filename) fs.saveAsTiff(filepath)
def saveFile(imp, format, outputDirPath): fs = FileSaver(imp) saveDict = { 'tif': lambda: fs.saveAsTiff(outputDirPath + imp.getTitle() + ".tif"), 'zip': lambda: fs.saveAsZip(outputDirPath + imp.getTitle() + ".zip"), 'png': lambda: fs.saveAsPng(outputDirPath + imp.getTitle() + '.png'), 'txt': lambda: fs.saveAsTxt(outputDirPath + imp.getTitle() + '.txt'), 'jpg': lambda: fs.saveAsJpg(outputDirPath + imp.getTitle() + '.jpg') } saveDict[format]() return
def saveStack(destFolder,file_name,imp): #rename the result and save it to subfolder if not os.path.isdir(destFolder): os.makedirs(destFolder) fullname=os.path.join(destFolder,file_name) #print (fullname) fs = FileSaver(imp) #print 'bSaveStack()', fullPath, 'nslices=', sr_imp.getNSlices() msgStr = "Dimension:" + str(imp.width) + " X " + str(imp.height) + " X " + str(imp.getNSlices()) printLog("-Save "+file_name+" to "+destFolder,1) printLog("-"+msgStr,2) fs.saveAsTiffStack(fullname)
def writeZip(img, path, title=""): if isinstance(img, RandomAccessibleInterval): imp = IL.wrap(img, title) elif isinstance(img, ImagePlus): imp = img if title: imp.setTitle(title) else: syncPrint("Cannot writeZip to %s:\n Unsupported image type %s" % (path, str(type(img)))) return None # FileSaver(imp).saveAsZip(path) return imp
def save_tif(imps, name, new_dir): """ takes imps object and name string, saves as tif """ new_name = os.path.join(new_dir, name+".tif") if os.path.exists(new_name): message = ">> *File:* \n -->"+ new_name + "\n exists, continuing" IJ.log(message) print("File "+ new_name + " exists, continuing") return else: fs = FileSaver(imps[0]) fs.saveAsTiff(new_name)
def applyFilter(stackName): imp = IJ.openImage(stackName) stack = imp.getImageStack() for i in xrange(1, imp.getNSlices() + 1): image = ImagePlus(str(i), stack.getProcessor(i)) IJ.run(image, "Auto Threshold", "method=Li white") #IJ.run(image, "Analyze Particles...", "size= 1000-Infinity circularity=0.00-1.00 show=Masks in_situ") imp2 = ImagePlus("Threshold", stack) fs = FileSaver(imp2) print "Saving filtered stack" fs.saveAsTiff(stackName[:-4] + "-filtered(Li).tif")
def stackToSlices(folder_in,folder_out,folder_num): for filename in os.listdir(folder_in): imp = IJ.openImage(os.path.join(folder_in, filename)) stack = imp.getImageStack() output=folder_out+str(folder_num) folder_num = folder_num+1 os.makedirs(output) for i in xrange(1, imp.getNSlices()+1): ip = stack.getProcessor(i) imp = ImagePlus("imp", ip) fs= FileSaver(imp) filepath = os.path.join(output,str(i)) fs.saveAsTiff(filepath)
def tstormanlysis(inputfile, csvdatapath, hppath): ''' TSTORMANALYSIS will use predefined parameter for storm analysis in "ThunderSTORM" ''' # set camera IJ.run( inputfile, "Camera setup", "offset=166.0 isemgain=true photons2adu=8.8 gainem=300.0 pixelsize=160.0" ) # run STORM analysis IJ.run(inputfile, "Run analysis", ( "filter=[Wavelet filter (B-Spline)] " "scale=2.0 order=3 detector=[Local maximum] connectivity=8-neighbourhood " "threshold=std(Wave.F1) estimator=[PSF: Integrated Gaussian] sigma=1.6 " "fitradius=3 method=[Weighted Least squares] full_image_fitting=false " "mfaenabled=false renderer=[No Renderer]")) resultwd = wm.getWindow('ThunderSTORM: results') # run drift correction IJ.run( inputfile, "Show results table", ("action=drift magnification=5.0 " "method=[Cross correlation] save=false steps=5 showcorrelations=false" )) driftwd = wm.getWindow('Drift') IJ.run(inputfile, "Show results table", "action=density neighbors=5 radius=50.0 dimensions=2D") IJ.run(inputfile, "Export results", ("filepath=[" + csvdatapath + "] " "fileformat=[CSV (comma separated)] " "sigma=true intensity=true chi2=true " "offset=true saveprotocol=true " "x=true y=true bkgstd=true " "id=true uncertainty=true frame=true")) IJ.run( inputfile, "Visualization", "imleft=0.0 imtop=0.0 " "imwidth=128.0 imheight=128.0 " "renderer=[Averaged shifted histograms] " "magnification=5.0 colorizez=false threed=false shifts=2") imp_histogram = IJ.getImage() fs = FileSaver(imp_histogram) FileSaverCheck(fs, os.path.dirname(hppath), os.path.basename(hppath)) # close windows -------------------------------------------------------- inputfile.close() imp_histogram.close() driftwd.close()
def saveMaxProject(self, destFolder=''): # ch1 if self.imp_ch1: # make max project zp = ZProjector(self.imp_ch1) zp.setMethod(ZProjector.MAX_METHOD) zp.doProjection() zimp = zp.getProjection() # save fs = FileSaver(zimp) bPrintLog('saveMaxProject():' + self.savePathMax_ch1, 3) fs.saveAsTiff(self.savePathMax_ch1) # ch2 if self.imp_ch2: # make max project zp = ZProjector(self.imp_ch2) zp.setMethod(ZProjector.MAX_METHOD) zp.doProjection() zimp = zp.getProjection() # save fs = FileSaver(zimp) bPrintLog('saveMaxProject():' + self.savePathMax_ch2, 3) fs.saveAsTiff(self.savePathMax_ch2) # ch1 if self.imp_ch3: # make max project zp = ZProjector(self.imp_ch3) zp.setMethod(ZProjector.MAX_METHOD) zp.doProjection() zimp = zp.getProjection() # save fs = FileSaver(zimp) bPrintLog('saveMaxProject():' + self.savePathMax_ch3, 3) fs.saveAsTiff(self.savePathMax_ch3)