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'),
                                          maskvalue=0,
                                          value=0,
                                          background=0):

        ifp.logging('------------\nCurrent label {} in iteration {}',
                    lblo['label'], c)
        ifp.logging('Bounding box = {}', lblo['bounds'])
if __name__ == "__main__":

    # sys.stdout = open('/media/julian/Daten/neuraldata/isbi_2013/mc_crop_cache/log.txt', "a")

    # Parameters
    tapering_tolerance_rel = 0.5
    tapering_tolerance_abs = 5
    # object = 191

    ifp = ImageFileProcessing(
        "/media/julian/Daten/neuraldata/isbi_2013/mc_crop_cache/",
        "multicut_segmentation.h5", asdict=True, keys=('labels',))

    # for obj in [191]:
    for obj in xrange(1, ifp.amax(ids=('labels',))['labels'] + 1):

        # sys.stdout = open('/media/julian/Daten/neuraldata/isbi_2013/mc_crop_cache/log.txt', "a")

        print '_____________________________________________________________________'
        print 'Object label: ' + str(obj)

        ifp.deepcopy_entry('labels', 'disttransf')

        if True:

            # Start with one object only
            ifp.getlabel(obj, ids=('disttransf',))
            if ifp.amax(ids=('disttransf',)) == 0:
                print 'Skiping object ' + str(obj) + ': Not found.'
                # sys.exit()
        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
        # These are the labels which were merged with a respective partner
        # labellist = ifp.get_image('mergeids_all')[:, 0]
        labellist = ifp.get_image('mergeids_all')
        # labellist = [9988]
        ifp.logging('labellist = {}', labellist)
        # for lblo in ifp.label_bounds_iterator('largeobjm', 'curlabel',
        #                                       ids=('locmax', 'disttransf', 'largeobj'),
        #                                       targetids=('curlocmax', 'curdisttransf', 'curlargeobj'),
        #                                       maskvalue=0, value=0, background=0, labellist=labellist,
        #                                       forcecontinue=True):

        for lblp in ifp.labelpair_bounds_iterator('largeobj',
        ifp.logging('Starting label iterator for {} labels', len(ifp.anytask_rtrn(np.unique, ids='labels')))

        c = 0
        for lblo in ifp.label_bounds_iterator('labels', 'curlabel', ids='disttransf', targetids='curdisttransf',
                                              maskvalue=0, value=0):

            ifp.logging('------------\nCurrent label {} in iteration {}', lblo['label'], c)
            ifp.logging('Bounding box = {}', lblo['bounds'])

            local_maxima_found = find_local_maxima(ifp)

            ifp.logging('Local maxima found: {}', local_maxima_found)

            if local_maxima_found:

                if ifp.amax('locmax') != 0:

                    find_shortest_path(ifp)

                    ifp.write(filename='{0}input_{1}.h5'.format(resultfolder, lblo['label']), ids=('curdisttransf', 'curlabel', 'smoothed'))
                    ifp.write(filename='{0}paths_over_dist_{1}.h5'.format(resultfolder, lblo['label']), ids=('paths_over_dist',))

                else:

                    ifp.logging('No maxima found!')

            else:

                ifp.logging('Maxima detection not successful!')

        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
        # These are the labels which were merged with a respective partner
        # labellist = ifp.get_image('mergeids_all')[:, 0]
        labellist = ifp.get_image('mergeids_all')
        # labellist = [9988]
        ifp.logging('labellist = {}', labellist)
        # for lblo in ifp.label_bounds_iterator('largeobjm', 'curlabel',
        #                                       ids=('locmax', 'disttransf', 'largeobj'),
        #                                       targetids=('curlocmax', 'curdisttransf', 'curlargeobj'),
        #                                       maskvalue=0, value=0, background=0, labellist=labellist,
        #                                       forcecontinue=True):

        for lblp in ifp.labelpair_bounds_iterator('largeobj', 'curlabelpair',
Exemple #6
0
    # sys.stdout = open('/media/julian/Daten/neuraldata/isbi_2013/mc_crop_cache/log.txt', "a")

    # Parameters
    tapering_tolerance_rel = 0.5
    tapering_tolerance_abs = 5
    # object = 191

    ifp = ImageFileProcessing(
        "/media/julian/Daten/neuraldata/isbi_2013/mc_crop_cache/",
        "multicut_segmentation.h5",
        asdict=True,
        keys=('labels', ))

    # for obj in [191]:
    for obj in xrange(1, ifp.amax(ids=('labels', ))['labels'] + 1):

        # sys.stdout = open('/media/julian/Daten/neuraldata/isbi_2013/mc_crop_cache/log.txt', "a")

        print '_____________________________________________________________________'
        print 'Object label: ' + str(obj)

        ifp.deepcopy_entry('labels', 'disttransf')

        if True:

            # Start with one object only
            ifp.getlabel(obj, ids=('disttransf', ))
            if ifp.amax(ids=('disttransf', )) == 0:
                print 'Skiping object ' + str(obj) + ': Not found.'
                # sys.exit()
                                              ids='disttransf',
                                              targetids='curdisttransf',
                                              maskvalue=0,
                                              value=0):

            ifp.logging('------------\nCurrent label {} in iteration {}',
                        lblo['label'], c)
            ifp.logging('Bounding box = {}', lblo['bounds'])

            local_maxima_found = find_local_maxima(ifp)

            ifp.logging('Local maxima found: {}', local_maxima_found)

            if local_maxima_found:

                if ifp.amax('locmax') != 0:

                    find_shortest_path(ifp)

                    ifp.write(filename='{0}input_{1}.h5'.format(
                        resultfolder, lblo['label']),
                              ids=('curdisttransf', 'curlabel', 'smoothed'))
                    ifp.write(filename='{0}paths_over_dist_{1}.h5'.format(
                        resultfolder, lblo['label']),
                              ids=('paths_over_dist', ))

                else:

                    ifp.logging('No maxima found!')

            else:
        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'),
                                          maskvalue=0, value=0, background=0):

        ifp.logging('------------\nCurrent label {} in iteration {}', lblo['label'], c)
        ifp.logging('Bounding box = {}', lblo['bounds'])

        if ifp.amax('curlocmax') == 1:
            ps = find_shortest_path(ifp, thisparams['penaltypower'], lblo['bounds'])
            ifp.logging('Number of paths found: {}', len(ps))
            if ps:
                hfp.setdata({lblo['label']: ps}, append=True)
                ifp.write(filename='paths_over_dist_true_{}.h5'.format(lblo['label']), ids='paths_over_dist')