def load_timeseries_graph(dir_): from pymira import spatialgraph graph = [] time = [] for file in os.listdir(dir_): if file.endswith('.am'): #print(os.path.join("/mydir", file)) g = spatialgraph.SpatialGraph() try: g.read(os.path.join(dir_, file)) graph.append(g) t = np.float(g.get_parameter_value('Time')) time.append(t) except Exception as e: print(e) time = np.asarray(time) graph = np.asarray(graph) srtInds = time.argsort() time = time[srtInds] graph = graph[srtInds] return graph, time
def main(): #dir_ = 'C:\\Users\\simon\\Dropbox\\Mesentery\\' #f = dir_ + 'Flow2AmiraPressure.am' # dir_ = 'C:\\Users\\simon\\Dropbox\\160113_paul_simulation_results\\LS147T\\1\\' # #dir_ = 'C:\\Users\\simon\\Dropbox\\160113_paul_simulation_results\\LS147T - Post-VDA\\1\\' # #dir_ = 'C:\\Users\\simon\\Dropbox\\160113_paul_simulation_results\\SW1222\\1\\' # #dir_ = 'C:\\Users\\simon\\Dropbox\\160113_paul_simulation_results\\SW1222\\1\\' # #f = dir_+'spatialGraph_RIN.am' #dir_ = r"C:\Users\simon\Dropbox\VDA_1_lectin\Control\SW#1" #f = dir_+r'\SW1_spatialGraph_scaled.am' # pixsize = 6.98 # dir_ = r"G:\OPT\2015.11.VDA_1 study\VDA Colorectal cancer\Control\LS\LS#2" # f = dir_+r'\LS2_bg_removed_frangi_response_skeletonised_with_radius.SptGraph.am' # pixsize = 8.21 # #dir_ = r"G:\OPT\2015.11.VDA_1 study\VDA Colorectal cancer\Control\LS\LS#4" # #pixsize = 8.21 #dirs = [r"C:\Users\simon\Dropbox\VDA_1_lectin\Control\SW#2", # r"C:\Users\simon\Dropbox\VDA_1_lectin\Control\SW#3"] #fs = [r'\SW2_spatialGraph_scaled.am', # r'\SW3_spatialGraph_scaled.am'] dirs = [r'C:\Users\simon\Dropbox\VDA_1_lectin\Treated\LS#1'] fs = [r'\LS1t_vessel_seg_frangi_response_skel_with_radius.am'] pixsize = [4.78] for i,dir_ in enumerate(dirs): f = fs[i] pix = pixsize[i] from pymira import spatialgraph graph = spatialgraph.SpatialGraph() print('Reading graph...') graph.read(dir_+f) print('Graph read') if pix is not None: ofile = dir_+'\spatialGraph_scaled.am' graph.rescale_coordinates(pix,pix,pix) graph.rescale_radius(pix,ofile=ofile) stats = Statistics(graph,path=dir_) stats.do_stats(path=dir_)
# -*- coding: utf-8 -*- """ Created on Wed May 31 14:42:15 2017 @author: simon """ from pymira import spatialgraph import os dir_ = r'C:\Users\simon\Dropbox\Ben Vessel Networks' f = os.path.join(dir_, 'C2M3_vessels.am') print 'Reading graph: {}'.format(f) graph = spatialgraph.SpatialGraph() graph.read(f) print 'Graph read' editor = spatialgraph.Editor() graph = editor.largest_graph(graph) ofile = os.path.join(dir_, 'C2M3_vessels_largest_network.am') graph.write(ofile)
def main(): plt.close('all') from pymira import spatialgraph dir_ = 'C:\\Users\\simon\\Dropbox\\Mesentery\\' f = dir_ + 'ct_output.am' graph = spatialgraph.SpatialGraph() print('Reading graph...') graph.read(f) print('Graph read') points = graph.get_data('EdgePointCoordinates') npoints = points.shape[0] nEdgePoint = graph.get_data('NumEdgePoints') edgePointIndex = np.zeros(npoints, dtype='int') offset = 0 edgeCount = 0 for npCur in nEdgePoint: edgePointIndex[offset:offset + npCur] = edgeCount edgeCount += 1 offset += npCur assert offset == npoints concFieldInds = [ i for i, x in enumerate(graph.fieldNames) if 'Concentration' in x ] concFields = [graph.fieldNames[i] for i in concFieldInds] time = np.asarray( [float(x.replace('Concentration_', '')) for x in concFields]) nt = len(time) npoint = points.shape[0] conc = np.zeros((nt, npoint), dtype='float') for ci, concField in enumerate(concFieldInds): field = graph.fields[concField] if 'data' in field: conc[ci, :] = field['data'] else: conc[ci, :] = conc[ci - 1, :] print(('Data missing: {}'.format(concFields[ci]))) #nodes = [[10.,10.,10.], # [10.,20.,10.], # [30.,30.,10.]] #import pdb #pdb.set_trace() jump = 1 lim = -1 #jump*50 time = time[0:lim:jump] conc = conc[0:lim:jump, :] #conc = conc[:,0:100] #points = points[0:100,:] #edgePointIndex = edgePointIndex[0:100] inter = Interstitium() try: inter.interstitial_diffusion(points, edgePointIndex, conc, time) except KeyboardInterrupt: print('Keyboard interrupt') #inter.normalise() #pass #import pdb #pdb.set_trace() #inter.display_grid(last=False) inter.save_grid(dir_)
nodes[1], nodes[2], nodes[2], nodes[3], nodes[2], nodes[4] ] edgePoints = np.asarray(edgePoints,dtype='float') radii = np.zeros(edgePoints.shape[0]) + 0.05 nedgepoints = [6, 2, 2, 2] nedgepoints = np.asarray(nedgepoints,dtype='int') graph = spatialgraph.SpatialGraph(initialise=True,scalars=['Radii']) graph.set_definition_size('VERTEX',nodes.shape[0]) graph.set_definition_size('EDGE',edgeConn.shape[0]) graph.set_definition_size('POINT',edgePoints.shape[0]) graph.set_data(nodes,name='VertexCoordinates') graph.set_data(edgeConn,name='EdgeConnectivity') graph.set_data(nedgepoints,name='NumEdgePoints') graph.set_data(edgePoints,name='EdgePointCoordinates') graph.set_data(radii,name='Radii') ofile = 'C:\\Anaconda2\\Lib\\site-packages\\pymira\\test_graph.am' graph.write(ofile)