def remove_small_objects():

    folder = '/media/julian/Daten/neuraldata/cremi_2016/'
    file = 'cremi.splA.raw_neurons.crop.crop_10-200-200_110-712-712.disttransf.h5'
    names = ('labels',)
    keys = ('labels',)

    ifp = ImageFileProcessing(
        folder,
        file, asdict=True,
        image_names=names,
        keys=keys)

    ifp.startlogger(filename=None)

    # Find all relevant labels
    ifp.addfromfile('{}largeobjects.h5'.format(folder), image_ids=(0,))

    for lbl in ifp.label_image_iterator(
            'labels', 'largeobjects', accumulate=True, labellist=ifp.get_image('largeobjects')):
        ifp.logging('Label {} done!', lbl)

    ifp.getlabel(0, ids='largeobjects', targetids='background')

    ifp.write(filename='largeobjectimage.h5')

    ifp.logging('')
    ifp.stoplogger()
def remove_small_objects():

    folder = '/media/julian/Daten/neuraldata/cremi_2016/'
    file = 'cremi.splA.raw_neurons.crop.crop_10-200-200_110-712-712.disttransf.h5'
    names = ('labels', )
    keys = ('labels', )

    ifp = ImageFileProcessing(folder,
                              file,
                              asdict=True,
                              image_names=names,
                              keys=keys)

    ifp.startlogger(filename=None)

    # Find all relevant labels
    ifp.addfromfile('{}largeobjects.h5'.format(folder), image_ids=(0, ))

    for lbl in ifp.label_image_iterator(
            'labels',
            'largeobjects',
            accumulate=True,
            labellist=ifp.get_image('largeobjects')):
        ifp.logging('Label {} done!', lbl)

    ifp.getlabel(0, ids='largeobjects', targetids='background')

    ifp.write(filename='largeobjectimage.h5')

    ifp.logging('')
    ifp.stoplogger()
__author__ = 'jhennies'


if __name__ == '__main__':

    yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml'

    ifp = ImageFileProcessing(
        yaml=yamlfile,
        yamlspec={'image_path': 'intermedfolder', 'image_file': 'largeobjfile', 'image_names': 'largeobjname'},
        asdict=True,
        keys=('largeobj',)
    )
    params = ifp.get_params()
    thisparams = params['localmax_on_disttransf']
    ifp.addfromfile(params['intermedfolder']+params['largeobjmfile'], image_names=params['largeobjmnames'][0], ids='largeobjm')

    ifp.startlogger(filename=ifp.get_params()['intermedfolder'] + 'locmax_on_disttransf.log', type='a')

    # ifp.code2log(__file__)
    ifp.code2log(inspect.stack()[0][1])
    ifp.logging('')

    ifp.logging('yamlfile = {}', yamlfile)
    ifp.logging('ifp.get_data().keys() = {}', ifp.get_data().keys())
    ifp.logging('ifp.shape() = {}', ifp.shape())

    # Boundary distance transform
    # a) Boundaries
    ifp.logging('Finding boundaries ...')
    ifp.pixels_at_boundary(
Пример #4
0
if __name__ == '__main__':

    yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml'

    ifp = ImageFileProcessing(yaml=yamlfile,
                              yamlspec={
                                  'image_path': 'intermedfolder',
                                  'image_file': 'largeobjfile',
                                  'image_names': 'largeobjname'
                              },
                              asdict=True,
                              keys=('largeobj', ))
    params = ifp.get_params()
    thisparams = params['localmax_on_disttransf']
    ifp.addfromfile(params['intermedfolder'] + params['largeobjmfile'],
                    image_names=params['largeobjmnames'][0],
                    ids='largeobjm')

    ifp.startlogger(filename=ifp.get_params()['intermedfolder'] +
                    'locmax_on_disttransf.log',
                    type='a')

    # ifp.code2log(__file__)
    ifp.code2log(inspect.stack()[0][1])
    ifp.logging('')

    ifp.logging('yamlfile = {}', yamlfile)
    ifp.logging('ifp.get_data().keys() = {}', ifp.get_data().keys())
    ifp.logging('ifp.shape() = {}', ifp.shape())

    # Boundary distance transform
if __name__ == '__main__':

    yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml'

    ifp = ImageFileProcessing(yaml=yamlfile,
                              yamlspec={
                                  'image_path': 'intermedfolder',
                                  'image_file': 'locmaxfile',
                                  'image_names': ('locmaxnames', 0, 2)
                              },
                              asdict=True,
                              keys=('disttransf', 'locmax'))
    params = ifp.get_params()
    thisparams = params['paths_within_labels']
    ifp.addfromfile(params['intermedfolder'] + params['largeobjfile'],
                    image_names=params['largeobjname'],
                    ids='largeobj')

    ifp.startlogger(filename=params['intermedfolder'] +
                    'paths_within_labels.log',
                    type='a')

    # ifp.code2log(__file__)
    ifp.code2log(inspect.stack()[0][1])
    ifp.logging('')

    ifp.logging('yamlfile = {}', yamlfile)
    ifp.logging('ifp.get_data().keys() = {}', ifp.get_data().keys())
    ifp.logging('ifp.shape() = {}', ifp.shape())
    ifp.logging('{}', ifp.amax())
        yamlfile = os.path.dirname(
            os.path.abspath(__file__)) + '/parameters.yml'

        ifp = ImageFileProcessing(yaml=yamlfile,
                                  yamlspec={
                                      'image_path': 'intermedfolder',
                                      'image_file': 'locmaxfile',
                                      'image_names': ('locmaxnames', 1, 3)
                                  },
                                  asdict=True,
                                  keys=('disttransf', 'locmax'))
        params = ifp.get_params()
        thisparams = params['paths_of_partners']
        ifp.addfromfile(params['intermedfolder'] + params['largeobjmfile'],
                        image_names=params['largeobjmnames'],
                        ids=[
                            'largeobjm', 'mergeids_small', 'mergeids_random',
                            'mergeids_all'
                        ])
        ifp.addfromfile(params['intermedfolder'] + params['largeobjfile'],
                        image_names=params['largeobjname'],
                        ids='largeobj')

        ifp.startlogger(filename=params['intermedfolder'] +
                        'paths_of_partners.log',
                        type='a')

        # ifp.code2log(__file__)
        ifp.code2log(inspect.stack()[0][1])
        ifp.logging('')

        ifp.logging('yamlfile = {}', yamlfile)
if __name__ == '__main__':

    try:

        yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml'

        ifp = ImageFileProcessing(
            yaml=yamlfile,
            yamlspec={'image_path': 'intermedfolder', 'image_file': 'locmaxfile', 'image_names': ('locmaxnames', 1, 3)},
            asdict=True,
            keys=('disttransf', 'locmax')
        )
        params = ifp.get_params()
        thisparams = params['paths_of_partners']
        ifp.addfromfile(params['intermedfolder']+params['largeobjmfile'], image_names=params['largeobjmnames'],
                        ids=['largeobjm', 'mergeids_small', 'mergeids_random', 'mergeids_all'])
        ifp.addfromfile(params['intermedfolder']+params['largeobjfile'], image_names=params['largeobjname'], ids='largeobj')

        ifp.startlogger(filename=params['intermedfolder'] + 'paths_of_partners.log', type='a')

        # ifp.code2log(__file__)
        ifp.code2log(inspect.stack()[0][1])
        ifp.logging('')

        ifp.logging('yamlfile = {}', yamlfile)
        ifp.logging('ifp.get_data().keys() = {}', ifp.get_data().keys())
        ifp.logging('ifp.shape() = {}', ifp.shape())
        ifp.logging('ifp.amax() = {}', ifp.amax())

        hfp = Hdf5Processing()
        c = 0
    return paths


if __name__ == '__main__':

    yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml'

    ifp = ImageFileProcessing(
        yaml=yamlfile,
        yamlspec={'image_path': 'intermedfolder', 'image_file': 'locmaxfile', 'image_names': ('locmaxnames', 0, 2)},
        asdict=True,
        keys=('disttransf', 'locmax')
    )
    params = ifp.get_params()
    thisparams = params['paths_within_labels']
    ifp.addfromfile(params['intermedfolder']+params['largeobjfile'], image_names=params['largeobjname'], ids='largeobj')

    ifp.startlogger(filename=params['intermedfolder'] + 'paths_within_labels.log', type='a')

    # ifp.code2log(__file__)
    ifp.code2log(inspect.stack()[0][1])
    ifp.logging('')

    ifp.logging('yamlfile = {}', yamlfile)
    ifp.logging('ifp.get_data().keys() = {}', ifp.get_data().keys())
    ifp.logging('ifp.shape() = {}', ifp.shape())
    ifp.logging('{}', ifp.amax())

    hfp = Hdf5Processing()
    c = 0
    for lblo in ifp.label_bounds_iterator('largeobj', 'curlabel', ids=('locmax', 'disttransf'), targetids=('curlocmax', 'curdisttransf'),