setconcat=setconcat, openallseries=openallseries, showomexml=showomexml, attach=attach, autoscale=autoscale) if verbose: for k, v in MetaInfo.items(): log.info(str(k) + ' : ' + str(v)) # do the processing log.info('Start Processing ...') if extract_channel: imp = MiscTools.splitchannel(imp, channelindex) # correct background if correct_background: log.info('Removing Background using Rolling Ball ...') imp = FilterTools.apply_rollingball(imp, radius=rb_radius, createBackground=create_background, lightBackground=lightbackground, useParaboloid=useparaboloid, doPresmooth=dopresmooth, correctCorners=correct_corners) # filter image if filtertype != 'NONE':
background_threshold = 'dark' #imagefile = r"/datadisk1/tuxedo/Github/Tools_and_Scripts/Fiji/scripts/3d_nuclei_image_holes_T.ome.tiff" #imagefile = r"/datadisk1/tuxedo/Github/Tools_and_Scripts/Fiji/scripts/3d_nuclei_image_holes.ome.tiff" imagefile = r"/datadisk1/tuxedo/Github/Tools_and_Scripts/Fiji/scripts/Osteosarcoma_01.ome.tiff" imagefile = r'"C:\Temp\input\Osteosarcoma_01.ome.tiff" corrf = 1.0 if stackopt: thcmd = method + ' ' + background_threshold + ' stack' if not stackopt: thcmd = method + ' ' + background_threshold # open image stack imp, MetaInfo = ImportTools.openfile(imagefile) imp = MiscTools.splitchannel(imp, 3) imp = ThresholdTools.apply_threshold(imp, method=method, background_threshold='dark', stackopt=stackopt, corrf=corrf) imp.show()
def run(imagefile, verbose=False): # open image file and get a specific series log.log(LogLevel.INFO, 'Opening Image: ' + imagefile) imp, MetaInfo = ImportTools.openfile(imagefile) # output of image metadata in log window if verbose: for k, v in MetaInfo.items(): log.log(LogLevel.INFO, str(k) + ' : ' + str(v)) log.log(LogLevel.INFO, 'File Extension : ' + MetaInfo['Extension']) if 'ResolutionCount' in MetaInfo: log.log(LogLevel.INFO, 'Resolution Count : ' + str(MetaInfo['ResolutionCount'])) if 'SeriesCount' in MetaInfo: log.log(LogLevel.INFO, 'SeriesCount : ' + str(MetaInfo['SeriesCount'])) if 'SizeC' in MetaInfo: log.log(LogLevel.INFO, 'Channel Count : ' + str(MetaInfo['SizeC'])) # do the processing log.log(LogLevel.INFO, 'Start Processing ...') # create empty image list imglist = [] numch = imp.getNChannels() # do the processing for ch in range(numch): # get a channel imp_c = MiscTools.splitchannel(imp, ch) name = os.path.basename(imagefile) + '_CH=' + str(ch) sp, fv, fv_max, fv_max_index = calc_focus(imp_c, name) log.log(LogLevel.INFO, 'Processing Channel : ' + str(ch)) log.log(LogLevel.INFO, 'Max. Value : ' + str(fv_max)) log.log(LogLevel.INFO, 'Max. Value Slice : ' + str(fv_max_index)) # set correct image properties sp = MiscTools.setproperties(sp, scaleX=MetaInfo['ScaleX'], scaleY=MetaInfo['ScaleY'], scaleZ=MetaInfo['ScaleZ'], unit='micron', sizeC=1, sizeZ=1, sizeT=1) imglist.append(sp) # in case of more than one channel use an jarray if numch > 1: # create an array imgarray = jarray.array(imglist, ImagePlus) # create an ImageStack from the array imgstack = ImageStack.create(imgarray) # create an ImagePlus object from the jarray new_name = os.path.splitext(os.path.basename(imagefile))[0] imp_sp = ImagePlus(new_name + '_SHARPEST', imgstack) # ic case of exactly one channel directly use the ImgPlus if numch == 1: imp_sp = imglist[0] # set correct image properties for the final image imp_sp = MiscTools.setproperties(imp_sp, scaleX=MetaInfo['ScaleX'], scaleY=MetaInfo['ScaleY'], scaleZ=MetaInfo['ScaleZ'], unit='micron', sizeC=numch, sizeZ=1, sizeT=1) return imp_sp
def run(imagefile, outputpath_orig, convert_orig2copy=False, sft='ome.tiff', fillholes=True, watershed=True, watershed_connectivity=6, verbose=True): print fillholes, watershed, watershed_connectivity # Opening the image log.info('Opening Image: ' + imagefile) # stitch togehter tiles stitchtiles = True # when set to True the number of pyramid levels can be read setflatres = True # select the desired pyramid level - level=0 for full resolution readpylevel = 0 setconcat = True openallseries = True showomexml = False attach = False autoscale = True # read the image imp, MetaInfo = ImportTools.openfile(imagefile, stitchtiles=stitchtiles, setflatres=setflatres, readpylevel=readpylevel, setconcat=setconcat, openallseries=openallseries, showomexml=showomexml, attach=attach, autoscale=autoscale) if verbose: for k, v in MetaInfo.items(): log.info(str(k) + ' : ' + str(v)) if EXTRACT_CHANNEL: imp = MiscTools.splitchannel(imp, CHINDEX) # optional filtering if FILTERTYPE != 'NONE': log.info('Apply Filter : ' + FILTERTYPE) imp = FilterTools.apply_filter(imp, radius=FILTER_RADIUS, filtertype=FILTERTYPE) # apply threshold log.info('Apply Threshold ...') imp = ThresholdTools.apply_threshold(imp, method=THRESHOLD_METHOD, background_threshold=THRESHOLD_BGRD, stackopt=THRESHOLD_STACKOPTION) print "3D: ", MetaInfo['is3d'] # fill holes if fillholes: imp = BinaryTools.fill_holes(imp, is3d=MetaInfo['is3d']) if watershed: imp = WaterShedTools.run_watershed( imp, mj_normalize=True, mj_dynamic=1, mj_connectivity=watershed_connectivity, is3d=MetaInfo['is3d']) return imp
def run(imagefile, outputpath_orig, convert_orig2copy=False, sft='ome.tiff', verbose=False): # Opening the image log.info('Opening Image: ' + imagefile) # stitch togehter tiles stitchtiles = True # when set to True the number of pyramid levels can be read setflatres = True # select the desired pyramid level - level=0 for full resolution readpylevel = 0 setconcat = True openallseries = True showomexml = False attach = False autoscale = True # read the image imp, MetaInfo = ImportTools.openfile(imagefile, stitchtiles=stitchtiles, setflatres=setflatres, readpylevel=readpylevel, setconcat=setconcat, openallseries=openallseries, showomexml=showomexml, attach=attach, autoscale=autoscale) if convert_orig2copy: log.info('Detected Extension : ' + MetaInfo['Extension']) # check if it was already an OME-TIFF based on the file extension ft = ['.ome.tif', '.ome.tiff'] if MetaInfo['Extension'] in ft: """ # just copy the original file new_path = '/output/' + os.path.basename(imagefile) command = 'cp ' + imagefile + ' ' + new_path log.info('Copy Original file without conversion to output folder') os.popen(command) """ # just copy the original file new_path = '/output/' + os.path.basename(IMAGEPATH) copy_ok = copyorig(IMAGEPATH, new_path, force_overwrite=True) log.info(copy_ok) if MetaInfo['Extension'] not in ft: log.info('Converting original to OME-TIFF and save to output folder.') savepath_orig = ExportTools.savedata(imp, outputpath_orig, extension=sft, replace=True) log.info('Saving converted original image : ' + savepath_orig) if verbose: for k, v in MetaInfo.items(): log.info(str(k) + ' : ' + str(v)) # do the processing log.info('Start Processing ...') if EXTRACT_CHANNEL: imp = MiscTools.splitchannel(imp, CHINDEX) # correct background if CORRECT_BACKGROUND: log.info('Removing Background using Rolling Ball ...') imp = FilterTools.apply_rollingball(imp, radius=RB_RADIUS, createBackground=CREATEBACKGROUND, lightBackground=LIGHTBACKGROUND, useParaboloid=USEPARABOLOID, doPresmooth=DOPRESMOOTH, correctCorners=CORRECTCORNERS) # optional filtering if FILTERTYPE != 'NONE': log.info('Apply Filter : ' + FILTERTYPE) imp = FilterTools.apply_filter(imp, radius=FILTER_RADIUS, filtertype=FILTERTYPE) # apply threshold log.info('Apply Threshold ...') imp = ThresholdTools.apply_threshold(imp, method=THRESHOLD_METHOD, background_threshold=THRESHOLD_BGRD, stackopt=THRESHOLD_STACKOPTION) #ip = imp.getProcessor() #ip = ip.convertToByte(False) #imp.setProcessor(ip) #ImageConverter.setDoScaling(False) #ImageConverter(imp).convertToGray8() #imp.show() #ImageConverter.setDoScaling(True); #IJ.run(imp, "8-bit", ""); #IJ.run(imp, "Enhance Contrast", "saturated=0.35"); """ # run watershed on stack weights = ChamferWeights3D.BORGEFORS.getFloatWeights() normalize = True dynamic = 2 connectivity = 26 ImageConverter(imp).convertToGray8() try: dist = BinaryImages.distanceMap(imp, weights, normalize) except: dist = BinaryImages.distanceMap(imp.getImageStack(), weights, normalize) Images3D.invert(dist) #imp = ExtendedMinimaWatershed.extendedMinimaWatershed(dist, imp.getImageStack(), dynamic, connectivity, 32, False ) try: imp = ExtendedMinimaWatershed.extendedMinimaWatershed(dist, imp, dynamic, connectivity, 32, False) except: imp = ExtendedMinimaWatershed.extendedMinimaWatershed(dist, imp.getImageStack(), dynamic, connectivity, 32, False) """ """ pastack, results = AnalyzeTools.analyzeParticles(imp, MINSIZE, MAXSIZE, MINCIRC, MAXCIRC, filename=imagefile, addROIManager=ROIS) # apply suitable LUT to visualize particles pastack = ImagePlus('Particles', pastack) IJ.run(pastack, 'glasbey_inverted', '') IJ.run(pastack, 'Enhance Contrast', 'saturated=0.35') return imp, pastack, results """ return imp