def load_images(filepath, skeys=None, recursive_search=False, logger=None): if logger is not None: logger.logging('Loading data from \n{}', filepath) else: print 'Loading data from \n{}'.format(filepath) data = IPL() data.data_from_file(filepath=filepath, skeys=skeys, recursive_search=recursive_search, nodata=True) return data
def load_images(ipl): """ These images are loaded: paths_true (paths within single label objects) paths_false (paths of merged objects which cross the merging site) featureims_true featureims_false :param ipl: :return: """ paths_true = IPL() paths_false = IPL() featureims_true = IPL() featureims_false = IPL() params = ipl.get_params() ipl.logging('Loading true paths ...') # Paths within labels (true paths) paths_true.data_from_file( filepath=params['intermedfolder'] + params['pathstruefile'], skeys='path', recursive_search=True, nodata=True ) ipl.logging('Loading false paths ...') # Paths of merges (false paths) paths_false.data_from_file( filepath=params['intermedfolder'] + params['pathsfalsefile'], skeys='path', recursive_search=True, nodata=True ) ipl.logging('Loading features for true paths ...') # Load features for true paths featureims_true.data_from_file( filepath=params['intermedfolder'] + params['featureimsfile'], nodata=True ) featureims_true.delete_items(params['largeobjmnames'][0]) ipl.logging('Loading features for false paths ...') # Load features for false paths featureims_false.data_from_file( filepath=params['intermedfolder'] + params['featureimsfile'], nodata=True ) featureims_false.delete_items(params['largeobjname']) return (paths_true, paths_false, featureims_true, featureims_false)
def load_images(ipl): """ These images are loaded: paths_true (paths within single label objects) paths_false (paths of merged objects which cross the merging site) featureims_true featureims_false :param ipl: :return: """ paths_true = IPL() paths_false = IPL() featureims_true = IPL() featureims_false = IPL() params = ipl.get_params() ipl.logging('Loading true paths ...') # Paths within labels (true paths) paths_true.data_from_file(filepath=params['intermedfolder'] + params['pathstruefile'], skeys='path', recursive_search=True, nodata=True) ipl.logging('Loading false paths ...') # Paths of merges (false paths) paths_false.data_from_file(filepath=params['intermedfolder'] + params['pathsfalsefile'], skeys='path', recursive_search=True, nodata=True) ipl.logging('Loading features for true paths ...') # Load features for true paths featureims_true.data_from_file(filepath=params['intermedfolder'] + params['featureimsfile'], nodata=True) featureims_true.delete_items(params['largeobjmnames'][0]) ipl.logging('Loading features for false paths ...') # Load features for false paths featureims_false.data_from_file(filepath=params['intermedfolder'] + params['featureimsfile'], nodata=True) featureims_false.delete_items(params['largeobjname']) return (paths_true, paths_false, featureims_true, featureims_false)
if __name__ == '__main__': yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml' hfp = IPL( yaml=yamlfile, yamlspec={'path': 'intermedfolder', 'filename': 'pathstruefile'}, castkey=None ) # hfp.logging('datastructure:\n---\n{}', hfp.datastructure2string()) params = hfp.get_params() hfp['true', 'border'] = IPL(data=hfp['largeobj', 'border_locmax', 'path']) hfp['true', 'locmax'] = IPL(data=hfp['largeobj', 'locmax', 'path']) hfp.pop('largeobj') hfp.data_from_file(filepath=params['intermedfolder'] + params['pathsfalsefile']) hfp['false', 'border'] = IPL(data=hfp['largeobjm', 'border_locmax_m', 'path']) hfp['false', 'locmax'] = IPL(data=hfp['largeobjm', 'locmaxm', 'path']) hfp.pop('largeobjm') hfp.pop('pathsim') hfp.pop('overlay') # hfp.data_from_file( # filepath=params['intermedfolder'] + params['pathsfalsefile'], # tkeys='false', # castkey=None # ) hfp.data_from_file(
from hdf5_image_processing import Hdf5ImageProcessingLib as IPL import os import numpy as np __author__ = 'jhennies' if __name__ == '__main__': yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml' ipl = IPL(yaml=yamlfile) ipl.logging('Parameters: {}', ipl.get_params()) params = ipl.get_params() ipl.data_from_file(filepath=params['datafolder'] + 'cremi.splA.raw_neurons.crop.h5', skeys='raw', tkeys='raw') ipl.crop_bounding_rect(np.s_[10:110, 200:712, 200:712], keys='raw') ipl.write(filepath=params['datafolder'] + 'cremi.splA.raw_neurons.crop.crop_10-200-200_110-712-712.h5')
resultsfolder = '/mnt/localdata02/jhennies/neuraldata/results/cremi_2016/161110_random_forest_of_paths/' yamlfile = resultsfolder + '/parameters.yml' ipl = IPL( yaml=yamlfile, yamlspec={'path': 'intermedfolder', 'filename': 'largeobjfile', 'skeys': 'largeobjname'}, recursive_search=True ) params = ipl.get_params() thisparams = params['paths_within_labels'] ipl.startlogger(filename=params['resultfolder'] + 'paths_within_labels.log', type='w') ipl.data_from_file(params['intermedfolder'] + params['locmaxfile'], skeys=params['locmaxnames'][0], recursive_search=True, integrate=True) ipl.data_from_file(params['intermedfolder'] + params['locmaxborderfile'], skeys=(params['locmaxbordernames'][0], params['locmaxbordernames'][2]), recursive_search=True, integrate=True) try: # Copy the script file and the parameters to the scriptsfolder copy(inspect.stack()[0][1], params['scriptsfolder']) copy(yamlfile, params['scriptsfolder'] + 'paths_within_labels.parameters.yml') # Write script and parameters to the logfile ipl.code2log(inspect.stack()[0][1]) ipl.logging('') ipl.yaml2log()
if __name__ == '__main__': yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml' hfp = IPL(yaml=yamlfile, yamlspec={ 'path': 'intermedfolder', 'filename': 'pathstruefile' }, tkeys='true', castkey=None) params = hfp.get_params() hfp.data_from_file(filepath=params['intermedfolder'] + params['pathsfalsefile'], tkeys='false', castkey=None) hfp.data_from_file(filepath=params['intermedfolder'] + params['locmaxfile'], skeys=('disttransf', 'disttransfm'), tkeys=('disttransf', 'disttransfm')) hfp.startlogger() try: hfp.logging('hfp datastructure:\n---\n{}---', hfp.datastructure2string(maxdepth=2)) hfp.anytask(lib.getvaluesfromcoords,
from hdf5_image_processing import Hdf5ImageProcessingLib as IPL import os import numpy as np __author__ = 'jhennies' if __name__ == '__main__': yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml' ipl = IPL( yaml=yamlfile ) ipl.logging('Parameters: {}', ipl.get_params()) params = ipl.get_params() ipl.data_from_file(filepath=params['datafolder'] + 'cremi.splA.raw_neurons.crop.h5', skeys='raw', tkeys='raw') ipl.crop_bounding_rect(np.s_[10:110, 200:712, 200:712], keys='raw') ipl.write(filepath=params['datafolder'] + 'cremi.splA.raw_neurons.crop.crop_10-200-200_110-712-712.h5')
resultsfolder = '/mnt/localdata02/jhennies/neuraldata/results/cremi_2016/161110_random_forest_of_paths/' yamlfile = resultsfolder + '/parameters.yml' ipl = IPL(yaml=yamlfile, yamlspec={ 'path': 'intermedfolder', 'filename': 'largeobjfile', 'skeys': 'largeobjname' }, recursive_search=True) params = ipl.get_params() thisparams = params['find_border_contacts'] ipl.data_from_file(params['intermedfolder'] + params['largeobjmfile'], skeys=params['largeobjmnames'][0], recursive_search=True, integrate=True) ipl.startlogger(filename=params['resultfolder'] + 'find_border_contacts.log', type='w') try: # Copy the script file and the parameters to the scriptsfolder copy(inspect.stack()[0][1], params['scriptsfolder']) copy(yamlfile, params['scriptsfolder'] + 'find_border_contacts.parameters.yml') # Write script and parameters to the logfile ipl.code2log(inspect.stack()[0][1]) ipl.logging('') ipl.yaml2log()
yamlfile = resultsfolder + '/parameters.yml' ipl = IPL( yaml=yamlfile, yamlspec={'path': 'intermedfolder', 'filename': 'pathstruefile'}, skeys='path', recursive_search=True ) # ipl.logging('datastructure:\n---\n{}', ipl.datastructure2string()) params = ipl.get_params() ipl.rename_layer('largeobj', 'true') # ipl['true', 'border'] = IPL(data=ipl['largeobj', 'border_locmax', 'path']) # ipl['true', 'locmax'] = IPL(data=ipl['largeobj', 'locmax', 'path']) # ipl.pop('largeobj') ipl.data_from_file(filepath=params['intermedfolder'] + params['pathsfalsefile'], skeys='path', recursive_search=True, integrate=True) ipl.rename_layer('largeobjm', 'false') ipl.remove_layer('path') # ipl['false', 'border'] = IPL(data=ipl['largeobjm', 'border_locmax_m', 'path']) # ipl['false', 'locmax'] = IPL(data=ipl['largeobjm', 'locmaxm', 'path']) # ipl.pop('largeobjm') # # ipl.pop('pathsim') # ipl.pop('overlay') ipl.startlogger(filename=params['resultfolder']+'features_of_paths.log', type='w') try: ipl.code2log(inspect.stack()[0][1])
return bordercontacts if __name__ == '__main__': yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml' hfp = IPL( yaml=yamlfile, yamlspec={'path': 'intermedfolder', 'filename': 'largeobjfile', 'skeys': 'largeobjname'}, tkeys='largeobj', castkey=None ) params = hfp.get_params() thisparams = params['find_border_contacts'] hfp.data_from_file(params['intermedfolder'] + params['largeobjmfile'], skeys=params['largeobjmnames'][0], tkeys='largeobjm') hfp.startlogger(filename=params['resultfolder'] + 'find_orphans.log', type='w') try: # Copy the script file and the parameters to the scriptsfolder copy(inspect.stack()[0][1], params['scriptsfolder']) copy(yamlfile, params['scriptsfolder'] + 'find_orphans.parameters.yml') # Write script and parameters to the logfile hfp.code2log(inspect.stack()[0][1]) hfp.logging('') hfp.yaml2log() hfp.logging('') hfp.logging('\nhfp datastructure: \n---\n{}', hfp.datastructure2string(maxdepth=1))
yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml' hfp = IPL(yaml=yamlfile, yamlspec={ 'path': 'intermedfolder', 'filename': 'pathstruefile' }, castkey=None) # hfp.logging('datastructure:\n---\n{}', hfp.datastructure2string()) params = hfp.get_params() hfp['true', 'border'] = IPL(data=hfp['largeobj', 'border_locmax', 'path']) hfp['true', 'locmax'] = IPL(data=hfp['largeobj', 'locmax', 'path']) hfp.pop('largeobj') hfp.data_from_file(filepath=params['intermedfolder'] + params['pathsfalsefile']) hfp['false', 'border'] = IPL(data=hfp['largeobjm', 'border_locmax_m', 'path']) hfp['false', 'locmax'] = IPL(data=hfp['largeobjm', 'locmaxm', 'path']) hfp.pop('largeobjm') hfp.pop('pathsim') hfp.pop('overlay') # # TODO: Insert code here # hfp = Hdf5ImageProcessingLib( # yaml=yamlfile, # yamlspec={'path': 'intermedfolder', 'filename': 'pathstruefile'}, # tkeys='true', # castkey=None
if __name__ == '__main__': resultsfolder = '/mnt/localdata02/jhennies/neuraldata/results/cremi_2016/161110_random_forest_of_paths/' yamlfile = resultsfolder + '/parameters.yml' ipl = IPL( yaml=yamlfile, yamlspec={'path': 'intermedfolder', 'filename': 'locmaxborderfile', 'skeys': {'locmaxbordernames': (1, 3)}}, recursive_search=True ) params = ipl.get_params() thisparams = params['paths_of_partners'] ipl.startlogger(filename=params['resultfolder'] + 'paths_of_partners.log', type='w') ipl.data_from_file(params['intermedfolder'] + params['largeobjfile'], skeys=params['largeobjname'], recursive_search=True, integrate=True) ipl.data_from_file(params['intermedfolder'] + params['largeobjmfile'], skeys=(params['largeobjmnames'][0], params['largeobjmnames'][4]), recursive_search=True, integrate=True) ipl.data_from_file(params['intermedfolder'] + params['locmaxfile'], skeys=params['locmaxnames'][1], recursive_search=True, integrate=True) try: # Copy the script file and the parameters to the scriptsfolder copy(inspect.stack()[0][1], params['scriptsfolder']) copy(yamlfile, params['scriptsfolder'] + 'paths_of_partners.parameters.yml') # Write script and parameters to the logfile ipl.code2log(inspect.stack()[0][1])
yamlspec={ 'path': 'intermedfolder', 'filename': 'locmaxborderfile', 'skeys': { 'locmaxbordernames': (0, 2) } }, tkeys=('border_locmax', 'disttransf'), castkey=None) params = hfp.get_params() thisparams = params['paths_within_labels'] hfp.startlogger(filename=params['resultfolder'] + 'paths_within_labels.log', type='w') hfp.data_from_file(params['intermedfolder'] + params['largeobjfile'], skeys=params['largeobjname'], tkeys='largeobj') hfp.data_from_file(params['intermedfolder'] + params['locmaxfile'], skeys=params['locmaxnames'][0], tkeys='locmax') try: # Copy the script file and the parameters to the scriptsfolder copy(inspect.stack()[0][1], params['scriptsfolder']) copy(yamlfile, params['scriptsfolder'] + 'paths_within_labels.parameters.yml') # Write script and parameters to the logfile hfp.code2log(inspect.stack()[0][1]) hfp.logging('') hfp.yaml2log()
if __name__ == "__main__": yamlfile = os.path.dirname(os.path.abspath(__file__)) + "/parameters.yml" yamlfile = os.path.dirname(os.path.abspath(__file__)) + "/parameters.yml" hfp = IPL(yaml=yamlfile, yamlspec={"path": "intermedfolder", "filename": "pathstruefile"}, castkey=None) # hfp.logging('datastructure:\n---\n{}', hfp.datastructure2string()) params = hfp.get_params() hfp["true", "border"] = IPL(data=hfp["largeobj", "border_locmax", "path"]) hfp["true", "locmax"] = IPL(data=hfp["largeobj", "locmax", "path"]) hfp.pop("largeobj") hfp.data_from_file(filepath=params["intermedfolder"] + params["pathsfalsefile"]) hfp["false", "border"] = IPL(data=hfp["largeobjm", "border_locmax_m", "path"]) hfp["false", "locmax"] = IPL(data=hfp["largeobjm", "locmaxm", "path"]) hfp.pop("largeobjm") hfp.pop("pathsim") hfp.pop("overlay") # # TODO: Insert code here # hfp = Hdf5ImageProcessingLib( # yaml=yamlfile, # yamlspec={'path': 'intermedfolder', 'filename': 'pathstruefile'}, # tkeys='true', # castkey=None # )
ipl = IPL(yaml=yamlfile, yamlspec={ 'path': 'intermedfolder', 'filename': 'largeobjfile', 'skeys': 'largeobjname' }, recursive_search=True) params = ipl.get_params() thisparams = params['paths_within_labels'] ipl.startlogger(filename=params['resultfolder'] + 'paths_within_labels.log', type='w') ipl.data_from_file(params['intermedfolder'] + params['locmaxfile'], skeys=params['locmaxnames'][0], recursive_search=True, integrate=True) ipl.data_from_file(params['intermedfolder'] + params['locmaxborderfile'], skeys=(params['locmaxbordernames'][0], params['locmaxbordernames'][2]), recursive_search=True, integrate=True) try: # Copy the script file and the parameters to the scriptsfolder copy(inspect.stack()[0][1], params['scriptsfolder']) copy(yamlfile, params['scriptsfolder'] + 'paths_within_labels.parameters.yml') # Write script and parameters to the logfile ipl.code2log(inspect.stack()[0][1])
if __name__ == '__main__': yamlfile = os.path.dirname(os.path.abspath(__file__)) + '/parameters.yml' hfp = IPL( yaml=yamlfile, yamlspec={'path': 'intermedfolder', 'filename': 'locmaxborderfile', 'skeys': {'locmaxbordernames': (1, 3)}}, tkeys=('border_locmax_m', 'disttransfm'), castkey=None ) params = hfp.get_params() thisparams = params['paths_of_partners'] hfp.startlogger(filename=params['resultfolder'] + 'paths_of_partners.log', type='w') hfp.data_from_file(params['intermedfolder'] + params['largeobjfile'], skeys=params['largeobjname'], tkeys='largeobj') hfp.data_from_file(params['intermedfolder'] + params['largeobjmfile'], skeys=(params['largeobjmnames'][0], params['largeobjmnames'][4]), tkeys=('largeobjm', 'change_hash')) hfp.data_from_file(params['intermedfolder'] + params['locmaxfile'], skeys=params['locmaxnames'][0], tkeys='locmaxm') try: # Copy the script file and the parameters to the scriptsfolder copy(inspect.stack()[0][1], params['scriptsfolder']) copy(yamlfile, params['scriptsfolder'] + 'paths_of_partners.parameters.yml') # Write script and parameters to the logfile hfp.code2log(inspect.stack()[0][1])