def copyVesselnetworkAndComputeFlow(gvdst, gv, bloodflowparams): '''gdst = group where the data is placed in, does not create a 'vesse' folder in it but writes nodes, edges directly; gv = source vessel group ''' myutils.buildLink(gvdst, 'CLASS', gv) myutils.buildLink(gvdst, 'SOURCE', gv) # first we need to copy some of the vessel data gvedst = gvdst.create_group('edges') gvndst = gvdst.create_group('nodes') gvedst.attrs['COUNT'] = gv['edges'].attrs['COUNT'] gvndst.attrs['COUNT'] = gv['nodes'].attrs['COUNT'] if (gv.attrs.__contains__('CLASS')): #special things if it is lattice based if (gv.attrs['CLASS'] == 'GRAPH'): gv.copy('lattice', gvdst) gvedst.attrs['CLASS'] = 'GRAPH' for name in ['lattice_pos', 'roots']: gv['nodes'].copy(name, gvndst) if (gv.attrs['CLASS'] == 'REALWORLD'): gvedst.attrs['CLASS'] = 'REALWORLD' for name in [ 'world_pos', 'roots', 'bc_node_index', 'bc_type', 'bc_value' ]: gv['nodes'].copy(name, gvndst) for name in ['radius', 'node_a_index', 'node_b_index']: gv['edges'].copy(name, gvedst) # then we recompute blood flow because the alorithm has changed and we may or may not want hematocrit if bloodflowparams['includePhaseSeparationEffect'] == True: pressure, flow, shearforce, hematocrit, flags = _ku.calc_vessel_hydrodynamics( gv, return_flags=True, bloodflowparams=bloodflowparams) gvedst.create_dataset('flow', data=flow, compression=9) gvedst.create_dataset('shearforce', data=shearforce, compression=9) gvedst.create_dataset('hematocrit', data=hematocrit, compression=9) gvedst.create_dataset('flags', data=flags, compression=9) gvndst.create_dataset('pressure', data=pressure, compression=9) else: print("Computing without phase seperation effect") pressure, flow, shearforce, hematocrit, flags = _ku.calc_vessel_hydrodynamics( gv, return_flags=True, bloodflowparams=bloodflowparams) gvedst.create_dataset('flow', data=flow, compression=9) gvedst.create_dataset('shearforce', data=shearforce, compression=9) gvedst.create_dataset('hematocrit', data=hematocrit, compression=9) gvedst.create_dataset('flags', data=flags, compression=9) gvndst.create_dataset('pressure', data=pressure, compression=9)
def enlarge_vessels(factor, gv_filename, bloodflowparams): '''gvdst = group where the data is placed in, does not create a 'vesse' folder in it but writes nodes, edges directly; gv = source vessel group ''' inFile = h5files.open(gv_filename, 'r') gv = inFile['vessels'] fac_as_percent = int(np.ceil(float(factor) * 100 - 100)) dest_file = h5files.open( myutils.strip_from_end(gv_filename, '.h5') + '_growth_by_%02i.h5' % fac_as_percent, 'a') dest_file.attrs.create('enlargeFactor', data=fac_as_percent) gvdst = dest_file.create_group('vessels') gvdst.attrs['CLASS'] = 'GRAPH' myutils.buildLink(gvdst, 'SOURCE', gv) # first we need to copy some of the vessel data gvedst = gvdst.create_group('edges') gvndst = gvdst.create_group('nodes') gvedst.attrs['COUNT'] = gv['edges'].attrs['COUNT'] gvndst.attrs['COUNT'] = gv['nodes'].attrs['COUNT'] gv.copy('lattice', gvdst) for name in [ 'lattice_pos', 'roots', 'nodeflags', 'gf', 'bc_conductivity_value', 'bc_node_index', 'bc_type', 'bc_value' ]: gv['nodes'].copy(name, gvndst) for name in ['radius', 'node_a_index', 'node_b_index', 'flags']: if name == 'radius': radii = gv['edges/' + name] radii = factor * np.asarray(radii) gvedst.create_dataset(name, data=radii) else: gv['edges'].copy(name, gvedst) # then we recompute blood flow because the alorithm has changed and we may or may not want hematocrit (pressure, flow, shearforce, hematocrit, flags) = krebsutils.calc_vessel_hydrodynamics( gvdst, return_flags=True, bloodflowparams=bloodflowparams) # then we save the new data to complete the network copy gvedst.create_dataset('flow', data=flow, compression=9) gvedst.create_dataset('shearforce', data=shearforce, compression=9) gvedst.create_dataset('hematocrit', data=hematocrit, compression=9) gvndst.create_dataset('pressure', data=pressure, compression=9)
def copyVesselnetworkAndComputeFlow(gvdst, gv, bloodflowparams): '''gdst = group where the data is placed in, does not create a 'vesse' folder in it but writes nodes, edges directly; gv = source vessel group ''' if gv.attrs['CLASS'] == 'GRAPH': gvdst.attrs['CLASS'] = 'GRAPH' myutils.buildLink(gvdst, 'SOURCE', gv) # first we need to copy some of the vessel data gvedst = gvdst.create_group('edges') gvndst = gvdst.create_group('nodes') gvedst.attrs['COUNT'] = gv['edges'].attrs['COUNT'] gvndst.attrs['COUNT'] = gv['nodes'].attrs['COUNT'] gv.copy('lattice',gvdst) for name in ['lattice_pos', 'roots','bc_conductivity_value','bc_node_index','bc_type','bc_value']: gv['nodes'].copy(name, gvndst) for name in ['radius', 'node_a_index', 'node_b_index']: gv['edges'].copy(name, gvedst) if gv.attrs['CLASS'] == 'REALWORLD': gvdst.attrs['CLASS'] = 'REALWORLD' myutils.buildLink(gvdst, 'SOURCE', gv) # first we need to copy some of the vessel data gvedst = gvdst.create_group('edges') gvndst = gvdst.create_group('nodes') gvedst.attrs['COUNT'] = gv['edges'].attrs['COUNT'] gvndst.attrs['COUNT'] = gv['nodes'].attrs['COUNT'] #gv.copy('lattice',gvdst) for name in ['world_pos', 'roots','bc_conductivity_value','bc_node_index','bc_type','bc_value']: gv['nodes'].copy(name, gvndst) for name in ['radius', 'node_a_index', 'node_b_index']: gv['edges'].copy(name, gvedst) # then we recompute blood flow because the alorithm has changed and we may or may not want hematocrit pressure, flow, shearforce, hematocrit, flags = krebsutils.calc_vessel_hydrodynamics_(gv, calc_hematocrit=True, return_flags = True, override_hematocrit= True, bloodflowparams = bloodflowparams,storeCalculationInHDF=False) # then we save the new data to complete the network copy gvedst.create_dataset('flow' , data = flow , compression = 9) gvedst.create_dataset('shearforce', data = shearforce , compression = 9) gvedst.create_dataset('hematocrit', data = hematocrit , compression = 9) gvedst.create_dataset('flags' , data = flags , compression = 9) gvndst.create_dataset('pressure' , data = pressure , compression = 9)