Ejemplo n.º 1
0
    def setReaderOptions(imagefile, stitchtiles=False,
                                    setflatres=True,
                                    setconcat=False,
                                    openallseries=False,
                                    showomexml=False,
                                    attach=False,
                                    autoscale=True):

        czi_options = DynamicMetadataOptions()
        czi_options.setBoolean("zeissczi.autostitch", stitchtiles)
        czi_options.setBoolean("zeissczi.attachments", attach)

        # set the option for the CZIReader
        czireader = ImportTools.setCZIReaderOptions(imagefile, czi_options, setflatres=setflatres)

        # Set the preferences in the ImageJ plugin
        # Note although these preferences are applied, they are not refreshed in the UI
        Prefs.set("bioformats.zeissczi.allow.autostitch", str(stitchtiles).lower())
        Prefs.set("bioformats.zeissczi.include.attachments", str(attach).lower())

        # set the option for the BioFormats import
        reader_options = ImporterOptions()
        reader_options.setOpenAllSeries(openallseries)
        reader_options.setShowOMEXML(showomexml)
        reader_options.setConcatenate(setconcat)
        reader_options.setAutoscale(autoscale)
        reader_options.setStitchTiles(stitchtiles)
        reader_options.setId(imagefile)

        return reader_options, czireader
Ejemplo n.º 2
0
def run(imagefile, useBF=True,
        series=0,
        filtertype='MEDIAN',
        filterradius='5'):

    #log.log(LogLevel.INFO, 'Image Filename : ' + imagefile)
    log.info('Image Filename : ' + imagefile)

    # get basic image metainfo
    metainfo = get_metadata(imagefile, imageID=series)
    for k, v in metainfo.items():
        #log.log(LogLevel.INFO, str(k) + ' : ' + str(v))
        log.info(str(k) + ' : ' + str(v))

    if not useBF:
        # using IJ static method
        imp = IJ.openImage(imagefile)

    if useBF:
        # initialize the importer options for BioFormats
        options = ImporterOptions()
        options.setOpenAllSeries(True)
        options.setShowOMEXML(False)
        options.setConcatenate(True)
        options.setAutoscale(True)
        options.setId(imagefile)
        options.setStitchTiles(True)

        # open the ImgPlus
        imps = BF.openImagePlus(options)
        imp = imps[series]

    # apply the filter
    if filtertype != 'NONE':

        # apply filter
        #log.log(LogLevel.INFO, 'Apply Filter  : ' + filtertype)
        #log.log(LogLevel.INFO, 'Filter Radius : ' + str(filterradius))
        log.info('Apply Filter  : ' + filtertype)
        log.info('Filter Radius : ' + str(filterradius))

        # apply the filter based on the chosen type
        imp = apply_filter(imp,
                           radius=filterradius,
                           filtertype=filtertype)

    if filtertype == 'NONE':
        #log.log(LogLevel.INFO, 'No filter selected. Do nothing.')
        log.info('No filter selected. Do nothing.')

    return imp
Ejemplo n.º 3
0
    def readbf(imagefile, metainfo,
               setflatres=False,
               readpylevel=0,
               setconcat=False,
               openallseries=True,
               showomexml=False,
               autoscale=True,
               stitchtiles=True):

        # initialize the importer options
        options = ImporterOptions()
        options.setOpenAllSeries(openallseries)
        options.setShowOMEXML(showomexml)
        options.setConcatenate(setconcat)
        options.setAutoscale(autoscale)
        options.setId(imagefile)
        options.setStitchTiles(stitchtiles)

        # in case of concat=True all series set number of series = 1
        # and set pyramidlevel = 0 (1st level) since there will be only one
        # unless setflatres = True --> read pyramid levels

        series = metainfo['SeriesCount_BF']
        if setconcat and setflatres:
            series = 1
            readpylevel = 0

        metainfo['Pyramid Level Output'] = readpylevel

        # open the ImgPlus
        imps = BF.openImagePlus(options)

        # read image data using the specified pyramid level
        imp, slices, width, height, pylevel = ImageTools.getImageSeries(imps, series=readpylevel)

        metainfo['Output Slices'] = slices
        metainfo['Output SizeX'] = width
        metainfo['Output SizeY'] = height

        return imp, metainfo