def plotGrowthAgainstFeedback(targetid, targetHeight, targetArea, eta,endStep, areaplot, heightplot,large = False,otherplot = None,stepsize = 5): #################################################### heightPlotStatus = False areaPlotStatus = True #################################################### radialGrowthData = [] orthoradialGrowthData = [] sumAbsRadialOrthoradialData = [] absSumGrowthData = [] #################################################### for step in range(1, endStep,stepsize): if not os.path.isfile("qdObject_step=%03d.obj"%step): return ################################################ percentStep = int((step)/endStep*100) sys.stdout.write('\r'+"step : "+ str(counter) +" "+"#"*percentStep+' '*(100-percentStep)+"%d%%"%percentStep) sys.stdout.flush() ################################################ cell1 = sf.loadCellFromFile(step) cell2 = sf.loadCellFromFile(step+stepsize) areaGrowthPoints = plotGrowthAgainstFeedbackPoint(cell1,cell2,targetid,eta,None,color='rebeccapurple' ,large = large,otherplot = None) radialGrowthData.append(areaGrowthPoints[0]) orthoradialGrowthData.append(areaGrowthPoints[1]) sumAbsRadialOrthoradialData.append(areaGrowthPoints[2]) absSumGrowthData.append(areaGrowthPoints[3]) ################################################ gc.collect() return [radialGrowthData, orthoradialGrowthData,sumAbsRadialOrthoradialData,absSumGrowthData]
def plotAspectRatio(targetid,othertargetid, targetsurfacearea, startStep=1,stepsize= 1,largerCondition =True ,maxarea = None, areastep = 10, startarea = None, endarea = 850): import numpy as np import matplotlib.pyplot as plt import os ######################################################################## # faceidarray for Primordia if not os.path.isfile("qdObject_step=001.obj"): return [0.,0.,0.,0.,0.,0.,0.,0.,0.] cell = sf.loadCellFromFile(1,resetids=True) initialTissueSurfaceArea = sf.getSurfaceArea(cell) ####################################################################### # Starting the Calculation ####################################################################### ####################################################################### laststep = 1 plotargs = {"markersize": 10, "capsize": 10,"elinewidth":3,"markeredgewidth":2} ####################################################################### primordialroundnessArray = [] primordialBoundaryroundnessArray = [] othertissueroundnessArray = [] tissueSurfaceAreaArray = [] if not startarea:#no startarea given startarea = int(initialTissueSurfaceArea) ####################################################################### listsurfacearea = np.linspace(startarea,endarea,10) ################################################### for steparea in listsurfacearea: step,tissueSurfaceArea = sf.getTimeStep(steparea, endStep, laststep, stepsize = 10) ######################################################################## if not os.path.isfile("qdObject_step=%03d.obj"%step):#check if file exists break cell = sf.loadCellFromFile(step,resetids=True) ################################################ primordialfaces = sf.getPrimordiaFaces(cell,targetid, large = False) primordialfaceids = [f.getID() for f in primordialfaces] primordialBoundaryfaces = sf.getPrimordiaBoundaryFaceList(cell,targetid,large= True) primordialBoundaryfaceids = [f.getID() for f in primordialBoundaryfaces] othertissuefacelist = sf.getPrimordiaFaces(cell,othertargetid, large=False)+\ sf.getPrimordiaBoundaryFaceList(cell,othertargetid,large= True)#getMeristemFaces(cell,primordialfaceids+primordialBoundaryfaceids) ################################################ ######################################################################## # calculate the roundness ######################################################################## primordiaRoundness = calculateMeanAspectRatio(primordialfaces) primordialBoundaryRoundness = calculateMeanAspectRatio(primordialBoundaryfaces) othertissueRoundness = calculateMeanAspectRatio(othertissuefacelist) ###################################################### tissueSurfaceAreaArray.append(tissueSurfaceArea) primordialroundnessArray.append(primordiaRoundness) primordialBoundaryroundnessArray.append(primordialBoundaryRoundness) othertissueroundnessArray.append(othertissueRoundness) ######################################################################## laststep = step ######################################################################## print tissueSurfaceArea, step return [tissueSurfaceAreaArray,primordialroundnessArray, primordialBoundaryroundnessArray,othertissueroundnessArray]
def plotHeightSurface(numOfLayer, endStep,eta,startStep=0,stepsize= 1,maxarea = None, areastep = 20, startarea = None, endarea = 850,resetids = False): import numpy as np import matplotlib.pyplot as plt import os ######################################################################## # faceidarray for Primordia if not os.path.isfile("qdObject_step=001.obj"): return [0.,0.,0.,0.,0.,0.,0.,0.,0.] cell = sf.loadCellFromFile(1) initialTissueSurfaceArea = sf.getSurfaceArea(cell) ####################################################################### # Starting the Calculation ###################################################################### ####################################################################### laststep = 1 plotargs = {"markersize": 10, "capsize": 10,"elinewidth":3,"markeredgewidth":2} ####################################################################### heightArray = [] tissueSurfaceAreaArray = [] timeArray = [] dhdAArray = [] volumeArray = [] radiusMeanArray = [] radiusVarArray = [] ################################################### if not startarea:#no startarea given startarea = int(initialTissueSurfaceArea) ################################################### listsurfacearea = np.linspace(startarea,endarea,15) for steparea in listsurfacearea: step,tissueSurfaceArea = sf.getTimeStep(steparea, endStep, laststep, stepsize = 10) step2,tissueSurfaceArea2 = sf.getTimeStep(steparea+areastep, endStep, step, stepsize = 10) if step == step2:break ######################################################################## if not (os.path.isfile("qdObject_step=%03d.obj"%step) or os.path.isfile("qdObject_step=%03d.obj"%step2) ):#check if file exists break cell = sf.loadCellFromFile(step,resetids = resetids) cell2 = sf.loadCellFromFile(step2,resetids = resetids) ################################################ radiusArray = getMeanRadius(cell) ################################################ radiusMeanArray.append(np.mean(radiusArray)) radiusVarArray.append(np.std(radiusArray)) volumeArray.append(cell.getNonConvexVolume())#getting the volume of the tissue tissueSurfaceAreaArray.append(tissueSurfaceArea) height = getTissueHeight(cell) height2 = getTissueHeight(cell2) heightArray.append(height) timeArray.append(step) ######################################################################## dhdA = (height2-height)/(tissueSurfaceArea2-tissueSurfaceArea) dhdAArray.append(dhdA) ######################################################################## print step, tissueSurfaceArea, height ######################################################################## return [tissueSurfaceAreaArray, heightArray, timeArray,dhdAArray,volumeArray,radiusMeanArray, radiusVarArray]
def plotGrowthAgainstFeedback(targetid, targetHeight, targetArea, eta,endStep, areaplot, heightplot,large = False,otherplot = None,stepsize = 10,areastep = 10): #################################################### heightPlotStatus = False areaPlotStatus = True cell1Status = False cell2Status = False #################################################### radialGrowthData = [] orthoradialGrowthData = [] sumAbsRadialOrthoradialData = [] absSumGrowthData = [] #################################################### for step in range(1, endStep+1,stepsize): if not os.path.isfile("qdObject_step=%03d.obj"%step): return ################################################ cell = sf.loadCellFromFile(step) ################################################ ################################################ #cell 1 ################################################ tissueSurfaceArea = sf.getSurfaceArea(cell) if (tissueSurfaceArea > (targetArea-areastep)) and not cell1Status: for calstep in range(step-1,step-stepsize-1,-1): cell = sf.loadCellFromFile(calstep) tissueSurfaceArea = sf.getSurfaceArea(cell) if (tissueSurfaceArea <= (targetArea-areastep)): cell1 = sf.loadCellFromFile(calstep) cell1Status = True break ################################################ #cell 2 ################################################ if (tissueSurfaceArea > (targetArea)) and not cell2Status: for calstep in range(step-1,step-stepsize-1,-1): cell = sf.loadCellFromFile(calstep) tissueSurfaceArea = sf.getSurfaceArea(cell) if (tissueSurfaceArea <= targetArea): cell2 = sf.loadCellFromFile(calstep) cell2Status = True break if cell1Status and cell2Status: areaGrowthPoints = plotGrowthAgainstFeedbackPoint(cell1,cell2,targetid,eta,areaplot,color='rebeccapurple' ,large = large,otherplot = otherplot) radialGrowthData.append(areaGrowthPoints[0]) orthoradialGrowthData.append(areaGrowthPoints[1]) sumAbsRadialOrthoradialData.append(areaGrowthPoints[2]) absSumGrowthData.append(areaGrowthPoints[3]) break ################################################ if not (heightPlotStatus or areaPlotStatus): return ################################################ gc.collect() return [radialGrowthData, orthoradialGrowthData,sumAbsRadialOrthoradialData,absSumGrowthData]
def getGrowthRatio(numOfLayer, targetid, endStep, startStep=1, stepsize=5): if not os.path.isfile("qdObject_step=001.obj"): return [0., 0., 0., 0., 0., 0., 0., 0., 0.] cell = sf.loadCellFromFile(1) ######################################################################## meanprimordiaArray = [] meanrestArray = [] timeArray = [] ######################################################################## fitlen = 50 finalstep = startStep + stepsize * fitlen for step in range(startStep, finalstep, stepsize): ######################################################################## if not os.path.isfile( "qdObject_step=%03d.obj" % step): #check if file exists break cell = sf.loadCellFromFile(step) ################################################ primordiafacelist = sf.getPrimordiaFaces(cell, targetid, large=False) primordiaarea = 0. for face in primordiafacelist: primordiaarea += face.getAreaOfFace() ################################################ tissueSurfaceArea = sf.getSurfaceArea(cell) ################################################ primordialface = sf.getFace(cell, targetid) restoftissuearea = tissueSurfaceArea - primordiaarea ################################################ numOfPrimordialcell = len(primordiafacelist) numOfrestofcell = cell.countFaces() - 1 - numOfPrimordialcell ################################################ meanprimordiafacearea = primordiaarea / numOfPrimordialcell meanrestoftissuefacearea = restoftissuearea / (numOfrestofcell) ################################################ meanprimordiaArray.append(meanprimordiafacearea) meanrestArray.append(meanrestoftissuefacearea) timeArray.append(step - 1) ################################################ logfastarea = np.log(meanprimordiaArray) logslowarea = np.log(meanrestArray) ################################################ fastareafit, m = sop.curve_fit( fitLinFunc, timeArray[:fitlen], logfastarea[:fitlen], bounds=([-np.inf, logfastarea[0] - 0.000001], [+np.inf, logfastarea[0]])) slowareafit, m = sop.curve_fit( fitLinFunc, timeArray[:fitlen], logslowarea[:fitlen], bounds=([-np.inf, logslowarea[0] - 0.000001], [+np.inf, logslowarea[0]])) ################################################ return fastareafit[0] / slowareafit[0]
def plotAverageGrowthRate(endStep,areaDerivativePlot, faceAreaDerivativePlot,targetid, startStep=1,norm=True, fastid = 0,azim = -60, elev = 50,stepsize = 1): import matplotlib.colors as colors import matplotlib.cm as cmx import math ###################################################### # Getting the first step ###################################################### if not os.path.isfile("qdObject_step=%03d.obj"%startStep): return cell = sf.loadCellFromFile(startStep) ###################################################### # dict of area ###################################################### dAreaCellDict = {} areaCellDict= {} surfaceAreaArray = np.zeros(endStep-startStep) faces = qd.CellFaceIterator(cell) face = faces.next() surfaceAreaArray[0] = cell.getSurfaceArea() ###################################################### stepcounter = 0 while face != None: if face.getID() == 1 : face = faces.next() continue areaCellDict[face.getID()] = np.zeros(int(math.ceil((float(endStep)-startStep)/stepsize))+1) dAreaCellDict[face.getID()] = np.zeros(int(math.ceil((float(endStep)-startStep)/stepsize))) areaCellDict[face.getID()][stepcounter] = face.getAreaOfFace() face =faces.next() ###################################################### # Gathering face area ###################################################### stepcounter += 1 ######################################## for i in range(startStep+stepsize,endStep+stepsize,stepsize): if not os.path.isfile("qdObject_step=%03d.obj"%i):#check if file exists break cell = sf.loadCellFromFile(i) ###################################### getAreaGrowthData(cell, areaCellDict, surfaceAreaArray,dAreaCellDict,stepcounter) ###################################################### stepcounter += 1 ###################################################### ######################## # plotting ######################## plotFaceAreaDerivative(faceAreaDerivativePlot,cell,dAreaCellDict,targetid,azim = azim, elev = elev) ######################## return
def plotPrincipalGrowthAxis(endStep, targetface, startStep = 0, numOfLayer=8,step = None, alpha = 0.8, Length=1.0,azim = -70, elev=50,saveDirectory = '.'): import matplotlib.colors as colors import matplotlib.cm as cmx #import the libraries from mpl_toolkits.mplot3d import Axes3D import matplotlib as mpl from mpl_toolkits.mplot3d.art3d import Poly3DCollection import numpy as np import matplotlib.pyplot as plt #limits of the plot jet = cm = plt.get_cmap('viridis') maxvalue = 1.#np.pi/2 minvalue = 0.#-1.*np.pi cNorm = colors.Normalize(vmin=minvalue, vmax=maxvalue) scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet) ######################################################### radius = (numOfLayer>1)*(np.sqrt(3.)*(numOfLayer-1)-Length)+Length#the radius of circle to be projected on #plotting part fig = plt.figure(frameon=False,figsize=(10,8)) fig.subplots_adjust(left=0, right=1, bottom=0, top=1) ax = Axes3D(fig) ax.set_xlim((-0.7*radius,0.7*radius)) ax.set_ylim((-0.7*radius,0.7*radius)) ax.set_zlim((-0.,1.4*radius)) ax.axis('off') ax.xaxis.pane.set_edgecolor('black') ax.yaxis.pane.set_edgecolor('black') scalarMap._A = [] clrbar = plt.colorbar(scalarMap,shrink=0.5, aspect=10) clrbar.set_label("Angle", fontsize = 20) ######################################################################## # Getting the Form Matrix Difference # ######################################################################## cell0 = sf.loadCellFromFile(startStep) formMatrix0 = getCurrentFormMatrix(cell0) for step in range(startStep+1,endStep+1): percentStep = int((step-startStep)/float(endStep - startStep)*100) sys.stdout.write('\r'+"step : "+ str(step) +" "+"#"*percentStep+' '*(100-percentStep)+"%d%%"%percentStep) sys.stdout.flush() ################################################################## cell = sf.loadCellFromFile(step) formMatrix = getCurrentFormMatrix(cell) ## Calculating the difference ## diffmatrix = matrixDifference(formMatrix0,formMatrix) ## Plot the growth direction ax = plotGrowthDirection(cell, diffmatrix, ax, step,targetface=targetface,azim = azim, elev = elev,saveDirectory = saveDirectory) plt.close() return
def plotUnitVec(endstep, startstep=0, numOfLayer=8, directory='.'): import matplotlib.colors as colors import matplotlib.cm as cmx # Getting Initial Area ###################################################### # Gathering face area ###################################################### totalMeanFaceArea = [] m0determinantArray = [] counter = startstep for i in range(startstep, endstep + 1): if not os.path.isfile( "qdObject_step=%03d.obj" % i): #check if file exists break percentStep = int( (counter - startstep) / float(endstep - startstep) * 100) sys.stdout.write('\r' + "step : " + str(counter) + " " + "#" * percentStep + ' ' * (100 - percentStep) + "%d%%" % percentStep) sys.stdout.flush() cell = sf.loadCellFromFile(i) cell.setParameters() facearea = 0. tfmDet = 0. latdev.plotUnitVectors(cell, numOfLayer, step=i, save=True, directory=directory) counter += 1 return
def plotVolume(endStep, startStep, targetarea, volplot1, volplot2, surfaceplot, stepsize=5): #################################################### volumeArray = [] surfaceAreaArray = [] timeArray = [] #################################################### for step in range(startStep, endStep + 1, stepsize): if not os.path.isfile("qdObject_step=%03d.obj" % step): return ################################################ cell = sf.loadCellFromFile(step) ################################################ tissueSurfaceArea = sf.getSurfaceArea(cell) tissueVolume = cell.getCartesianVolume() ################################################ if (tissueSurfaceArea > targetarea): break ################################################ volumeArray.append(tissueVolume) surfaceAreaArray.append(tissueSurfaceArea) timeArray.append(step) ################################################ ################################################ volplot1.plot(timeArray, volumeArray, linewidth=3, c='k') volplot2.plot(surfaceAreaArray, volumeArray, linewidth=3, c='k') surfaceplot.plot(timeArray, surfaceAreaArray, linewidth=3, c='k') ################################################ return
def plotEnergy(endstep, eta): energyarray = [] for i in range(endstep + 1): if not os.path.isfile( "qdObject_step=%03d.obj" % i): #check if file exists break cell = sf.loadCellFromFile(i) cell.setOmega(.1) cell.setAlpha(1.) cell.setBeta(0.) cell.setGamma(0.0126) cell.setZeta(0.) cell.setSigma(0.) cell.setPressure(0.) cell.setConvexAngleThreshold(360) cell.setParameters() energyarray.append(cell.getEnergyCartesianVolume()) #print eta,i, energyarray[-1], cell.getFirstTerm(), cell.getCartesianVolume(), cell.getBendingEnergy() tempfig = plt.figure(20) tax = tempfig.add_subplot(111) tax.plot(energyarray) #print energyarray os.chdir('..') tempfig.savefig('energy_eta=%.3f.png' % etacurrent, transparent='True') plt.close(20) return
def getTimeStep(targetArea, endStep, startStep=1, stepsize=10): #################################################### for step in range(startStep, endStep + 1, stepsize): if not os.path.isfile("qdObject_step=%03d.obj" % step): return endStep, 0. ################################################ cell = sf.loadCellFromFile(step) ################################################ tissueSurfaceArea = sf.getSurfaceArea(cell) if (tissueSurfaceArea > targetArea): gc.collect() for calstep in range(step - 1, step - stepsize - 1, -1): cell = sf.loadCellFromFile(calstep) tissueSurfaceArea = sf.getSurfaceArea(cell) if (tissueSurfaceArea <= targetArea): gc.collect() cell = sf.loadCellFromFile(calstep + 1) tissueSurfaceArea = sf.getSurfaceArea(cell) return calstep + 1, tissueSurfaceArea ################################################ gc.collect() return endStep, tissueSurfaceArea
def getFaceAreaArray(totalstep): # Preparing the facearea dictionary step = 0 cell = sf.loadCellFromFile(step) facearea = {} faces = qd.CellFaceIterator(cell) face = faces.next() while face != None: if face.getID() == 1: face = faces.next() continue """if sf.checkExternalFace(face): face = faces.next() continue """ facearea[face.getID()] = [] face = faces.next() ############################################# # Loading the cells for steps till totalstep ############################################# for step in range(totalstep + 1): cell = sf.loadCellFromFile(step) cell.setParameters() cell.calculateStrain() ######################################################## faces = qd.CellFaceIterator(cell) face = faces.next() while face != None: if face.getID() == 1: face = faces.next() continue """if sf.checkExternalFace(face): face = faces.next() continue """ facearea[face.getID()].append(face.getAreaOfFace()) face = faces.next() return facearea
def plotFeedbackCorrection(targetid, targetsurfacearea,endStep = 2000, startStep=1,stepsize= 20,maxarea = None, areastep = 10,resetids = False, saveName = None): import numpy as np import matplotlib.pyplot as plt import os ######################################################################## # faceidarray for Primordia if not os.path.isfile("qdObject_step=001.obj"): return [0.,0.,0.,0.,0.,0.,0.,0.,0.] ######################################################################## # getting the time step for computation ######################################################################## step,tissueSurfaceArea = sf.getTimeStep(targetsurfacearea, endStep, startStep, stepsize = stepsize,resetids = resetids) ####################################################################### # Starting the Calculation ####################################################################### cell = sf.loadCellFromFile(step,resetids = resetids)#loading cell ####################################################################### targetface = sf.getFace(cell, targetid)#getting top priomrdial face cell.calculateStressStrain()#calculating stress and strain cell.setRadialOrthoradialVector(targetface)#setting the rad/orthorad vectors ####################################################################### # calculating the rad/orthorad Component of Correction terms ####################################################################### cell.setRadialOrthoradialFeedbackCorrection() cell.setRadialOrthoradialStress() cell.setPrincipalDeformationVector() cell.setPrincipalDeformationFeedbackCorrection() ####################################################################### # Plotting ####################################################################### sf.plotRadialOrthoradialFeedbackCorrectionSurface(cell, numOfLayer, azim = -60, elev = 60, name =saveName+"_feedbackcorrection_radialOrthoradial") sf.plotTracePrincipalDeformationFeedbackCorrectionSurface(cell,numOfLayer, azim = -60, elev = 60, name =saveName+"_feedbackcorrection_trace") sf.plotPrincipalDeformationFeedbackCorrectionSurface(cell, numOfLayer, azim = -60, elev = 60, name =saveName+"_feedbackcorrection_principalDeformation") sf.plotStressSurface(cell, numOfLayer, azim = -60, elev = 60, name =saveName+"_stressSurface_principal") return
def plotStressAgainstFeedback(targetid, targetHeight, targetArea, eta, endStep, areaplot, heightplot, large=False, otherplot=None, savefig=None, stepsize=20): #################################################### heightPlotStatus = False areaPlotStatus = True #################################################### #################################################### for step in range(1, endStep + 1, stepsize): if not os.path.isfile("qdObject_step=%03d.obj" % step): return ################################################ cell = sf.loadCellFromFile(step) ################################################ if heightPlotStatus: primordialHeight = calculatePrimiordiaHeight(cell, targetid, large=large) if (primordialHeight > targetHeight): for calstep in range(step - 1, step - 11, -1): cell = sf.loadCellFromFile(calstep) primordialHeight = calculatePrimiordiaHeight(cell, targetid, large=large) if (primordialHeight <= targetHeight): heightStressPoints = plotStressAgainstFeedbackPoint( cell, targetid, eta, heightplot, color='salmon', large=large, savefig=savefig) heightPlotStatus = False break ################################################ if (areaPlotStatus): tissueSurfaceArea = sf.getSurfaceArea(cell) if (tissueSurfaceArea > targetArea): for calstep in range(step - 1, step - stepsize - 1, -1): cell = sf.loadCellFromFile(calstep) tissueSurfaceArea = sf.getSurfaceArea(cell) if (tissueSurfaceArea <= targetArea): areaStressPoints = plotStressAgainstFeedbackPoint( cell, targetid, eta, areaplot, color='rebeccapurple', large=large, otherplot=otherplot, savefig=savefig) areaPlotStatus = False break ################################################ if not (heightPlotStatus or areaPlotStatus): gc.collect() return areaStressPoints ################################################ gc.collect() return
color = colors[counter] ######################################################## percentStep = int((counter) / float(totalfolders) * 100) sys.stdout.write('\r' + "step : " + str(counter) + " " + "#" * percentStep + ' ' * (100 - percentStep) + "%d%%" % percentStep) sys.stdout.flush() ########################################################### #plotting and Saving ########################################################### os.chdir(folder) step, tissueSurfaceArea = getTimeStep(targetArea, endStep, startStep, stepsize=stepsize) cell = sf.loadCellFromFile(step) plotSurface(cell, ax, color, surface, zorder=10 - counter) legenditems.append( Line2D([0], [0], color=color, label=r"$\eta=%d$" % etacurrent, lw='3')) os.chdir("..") gc.collect() counter += 1 ax.legend(handles=legenditems) ax.view_init(azim=azim, elev=elev) if surface: fig.savefig(saveDirectory + r"/plot_surface_surf_eta=%d_%d.png" % (targeteta[0], targeteta[1]), transparent=True, bbox_inches="tight") fig.savefig(saveDirectory + r"/plot_surface_surf_eta=%d_%d.eps" %
def plotMinGaussianCurvaturePrimodiaHeight(numOfLayer, targetid, endstep, fastkappa, mincurvatureplot, heightplot, color): import numpy as np import matplotlib.pyplot as plt ######################################################################## # Loading the Cell # ######################################################################## ####################################################################### # Checking if the files exists if not going to step down ####################################################################### meanGaussianCurvature = [] primodialheight = [] for step in range(1, endStep + 1): if not os.path.isfile( "qdObject_step=%03d.obj" % step): #check if file exists break cell = sf.loadCellFromFile(step) ######################################################################## # Starting the Calcuation of Curvature # ######################################################################## gaussianCurvature = [] meanpointx = [] meanpointy = [] meanpointz = [] ########## edge = getEdge(cell, 211, 210) edgenext = edge ####grabbing the origin of edge#### vertexDest = edge.Dest() meanpointx.append(vertexDest.getXcoordinate()) meanpointy.append(vertexDest.getYcoordinate()) meanpointz.append(vertexDest.getZcoordinate()) # Get the Gaussian Curvature gaussianCurvature.append(vertexDest.getGaussianCurvature()) while True: edgenext = edgenext.Rprev() vertexDest = edgenext.Dest() meanpointx.append(vertexDest.getXcoordinate()) meanpointy.append(vertexDest.getYcoordinate()) meanpointz.append(vertexDest.getZcoordinate()) gaussianCurvature.append(vertexDest.getGaussianCurvature()) ######################################################## edgenext = edgenext.Lnext() vertexDest = edgenext.Dest() meanpointx.append(vertexDest.getXcoordinate()) meanpointy.append(vertexDest.getYcoordinate()) meanpointz.append(vertexDest.getZcoordinate()) gaussianCurvature.append(vertexDest.getGaussianCurvature()) ######################################################## edgenext = edgenext.Lnext() vertexDest = edgenext.Dest() meanpointx.append(vertexDest.getXcoordinate()) meanpointy.append(vertexDest.getYcoordinate()) meanpointz.append(vertexDest.getZcoordinate()) gaussianCurvature.append(vertexDest.getGaussianCurvature()) ############################################################### edgenext = edgenext.Rprev() vertexDest = edgenext.Dest() meanpointx.append(vertexDest.getXcoordinate()) meanpointy.append(vertexDest.getYcoordinate()) meanpointz.append(vertexDest.getZcoordinate()) gaussianCurvature.append(vertexDest.getGaussianCurvature()) ######################################################## edgenext = edgenext.Lnext() vertexDest = edgenext.Dest() meanpointx.append(vertexDest.getXcoordinate()) meanpointy.append(vertexDest.getYcoordinate()) meanpointz.append(vertexDest.getZcoordinate()) gaussianCurvature.append(vertexDest.getGaussianCurvature()) ############################################################# if edgenext.Org().getID() == edge.Org().getID(): break facetarget = sf.getFace(cell, targetid) targetx = facetarget.getXCentralised() targety = facetarget.getYCentralised() targetz = facetarget.getZCentralised() meanx = np.mean(meanpointx) meany = np.mean(meanpointy) meanz = np.mean(meanpointz) height = np.sqrt((meanx - targetx)**2 + (meany - targety)**2 + (meanz - targetz)**2) ########################################################################## primodialheight.append(height) meanGaussianCurvature.append(np.mean(np.array(gaussianCurvature))) ################################################################################# # Plotting ################################################################################# timestep = range(len(primodialheight)) #print primodialheight, meanGaussianCurvature # Min Gaussian curvature mincurvatureplot.plot(timestep, meanGaussianCurvature, c=color, lw=3) ################################### # Height of Primodia heightplot.plot(timestep, primodialheight, c=color, lw=3) ######################################################## return
def getGrowthRateStress(numOfLayer, endStep, eta, startStep=0, stepsize=1, maxarea=None, areastep=20, startarea=None, endarea=850, resetids=False): import numpy as np import matplotlib.pyplot as plt import os ######################################################################## # faceidarray for Primordia if not os.path.isfile("qdObject_step=001.obj"): return [0., 0., 0., 0., 0., 0., 0., 0., 0.] cell = sf.loadCellFromFile(1) initialTissueSurfaceArea = sf.getSurfaceArea(cell) ####################################################################### topFaceID = 3 * numOfLayer * ( numOfLayer - 1) + 2 #the id of cell at the top of the dome ####################################################################### # Starting the Calculation ###################################################################### ####################################################################### laststep = 1 plotargs = { "markersize": 10, "capsize": 10, "elinewidth": 3, "markeredgewidth": 2 } ####################################################################### heightArray = [] tissueSurfaceAreaArray = [] tissueSurfaceAreaArray2 = [] timeArray = [] timeArray2 = [] dhdAArray = [] volumeArray = [] radiusMeanArray = [] radiusVarArray = [] topdistance = [] ################################################################ absStressDict = {} stressRadialDict = {} stressOrthoradialDict = {} growthRateDict = {} tipDistanceDict = {} dictArray = [ absStressDict, stressRadialDict, stressOrthoradialDict, growthRateDict, tipDistanceDict ] ################################################### if not startarea: #no startarea given startarea = int(initialTissueSurfaceArea) ################################################### listsurfacearea = np.linspace(startarea, endarea, 15) for steparea in listsurfacearea: step, tissueSurfaceArea = getTimeStep(steparea, endStep, laststep, stepsize=10) step2, tissueSurfaceArea2 = getTimeStep(steparea + areastep, endStep, step, stepsize=10) if step == step2: break ######################################################################## if not (os.path.isfile("qdObject_step=%03d.obj" % step) or os.path.isfile( "qdObject_step=%03d.obj" % step2)): #check if file exists break cell = sf.loadCellFromFile(step, resetids=resetids) cell2 = sf.loadCellFromFile(step2, resetids=resetids) ################################################ topFace = sf.getFace(cell2, topFaceID) ################################################ cell2.calculateStressStrain() cell2.setRadialOrthoradialVector(topFace) cell2.setRadialOrthoradialStress() ################################################ dTissueSurfaceArea = tissueSurfaceArea2 - tissueSurfaceArea ################################################ #computing the cell growth rate ################################################ faces = qd.CellFaceIterator(cell2) face2 = faces.next() while face2 != None: faceid = face2.getID() face1 = sf.getFace(cell, faceid) ############################################ if face1 == None: absstress = np.abs(face2.getStressEigenValue1()) + np.abs( face2.getStressEigenValue2()) stressRadial = face2.getRadialStress() stressOrthoradial = face2.getOrthoradialStress() tipdistance = getFaceDistance(face2, topFace) growthrate = np.nan ############################################ addToDict(face2, dictArray, [ absstress, stressRadial, stressOrthoradial, growthrate, tipdistance ]) ############################################ face2 = faces.next() continue ############################################ facearea1 = face1.getAreaOfFace() facearea2 = face2.getAreaOfFace() ############################################ # checking if face2 has recently divided # if face divided recently, facearea is # divided in near half ############################################ if (facearea2 - facearea1) < -0.3 * facearea1: # if this is true, then face1 has # seen drastic area decrease # which would mean cell division growthrate = np.nan else: ############################################ #if no recent division ############################################ dfacearea = facearea2 - facearea1 growthrate = dfacearea / (facearea1 * dTissueSurfaceArea) ############################################ absstress = np.abs(face2.getStressEigenValue1()) + np.abs( face2.getStressEigenValue2()) stressRadial = face2.getRadialStress() stressOrthoradial = face2.getOrthoradialStress() tipdistance = getFaceDistance(face2, topFace) ############################################ addToDict(face2, dictArray, [ absstress, stressRadial, stressOrthoradial, growthrate, tipdistance ]) ############################################ face2 = faces.next() ############################################ ################################################ height = getTissueHeight(cell) heightArray.append(height) timeArray.append(step) timeArray2.append(step2) tissueSurfaceAreaArray.append(tissueSurfaceArea) tissueSurfaceAreaArray2.append(tissueSurfaceArea2) ######################################################################## print step2, tissueSurfaceArea, height ######################################################################## return [ tissueSurfaceAreaArray, tissueSurfaceAreaArray2, heightArray, timeArray, timeArray2, dictArray ]
def plotMeanStressGrowth(numOfLayer, targetid,endStep,eta, meanstress, meandilation, color,startStep=0,stepsize= 1,largerCondition =True ,maxarea = None, areastep = 20, startarea = None, endarea = 850,resetids = True): import numpy as np import matplotlib.pyplot as plt import os ######################################################################## # faceidarray for Primordia if not os.path.isfile("qdObject_step=001.obj"): return [0.,0.,0.,0.,0.,0.,0.,0.,0.] cell = sf.loadCellFromFile(1,resetids=resetids) initialTissueSurfaceArea = sf.getSurfaceArea(cell) ####################################################################### # Starting the Calculation ####################################################################### ####################################################################### laststep = 1 plotargs = {"markersize": 10, "capsize": 10,"elinewidth":3,"markeredgewidth":2} ####################################################################### orthoradialStressArray = [] radialStressArray = [] radialGrowthArray = [] orthoradialGrowthArray = [] meanstressEigenvalue1Array = [] meanstressEigenvalue2Array = [] meangrowthEigenvalue1Array = [] meangrowthEigenvalue2Array = [] meangaussianCurvatureArray = [] ################################################### # save standard deviations of the stress and growth ################################################### radialStressSDArray = [] orthoradialStressSDArray = [] radialGrowthSDArray = [] orthoradialGrowthSDArray = [] meanstressEigenvalue1SDArray = [] meanstressEigenvalue2SDArray = [] meangrowthEigenvalue1SDArray = [] meangrowthEigenvalue2SDArray = [] ################################################### tissueSurfaceAreaArray = [] primordiaAreaArray = [] boundaryAreaArray = [] heightArray = [] ################################################### if not startarea:#no startarea given startarea = int(initialTissueSurfaceArea) ################################################### listsurfacearea = np.linspace(startarea,endarea,10) #print listsurfacearea #for steparea in range(startarea, endarea, int(areastep)): for steparea in listsurfacearea: step,tissueSurfaceArea = sf.getTimeStep(steparea, endStep, laststep, stepsize = 10,resetids = resetids) ######################################################################## step2,tissueSurfaceArea2 = sf.getTimeStep(steparea+areastep, endStep, step, stepsize = 10,resetids = resetids) ######################################################################## if not os.path.isfile("qdObject_step=%03d.obj"%step):#check if file exists break cell = sf.loadCellFromFile(step,resetids=resetids) cell2 = sf.loadCellFromFile(step2,resetids=resetids) ################################################ cell.calculateStressStrain() ################################################ primordialface = sf.getFace(cell, targetid) ################################################ cell.setRadialOrthoradialVector(primordialface) cell.setRadialOrthoradialStress() ################################################ sf.calculateDilation(cell,cell2) ######################################################################## # Starting the Calculation of mean growth and mean stress on boundary ######################################################################## # mean stress ######################################################################## faceList = sf.getPrimordiaBoundaryFaceList(cell,targetid,large= large) primordiafacelist = sf.getPrimordiaFaces(cell, targetid, large = False) primordiaarea = 0. for face in primordiafacelist: primordiaarea += face.getAreaOfFace() ###################################################### #radialDict, orthoradialDict = getRadialOrthoradialDict(cell,targetid,large = large) ###################################################### radialStress = [] orthoradialStress = [] radialGrowth = [] orthoradialGrowth = [] stressEigenvalue1Array = [] stressEigenvalue2Array = [] growthEigenvalue1Array = [] growthEigenvalue2Array = [] gaussianCurvatureArray = [] dTissueSurfaceArea = tissueSurfaceArea2-tissueSurfaceArea boundaryarea = 0. for face in faceList: boundaryarea += face.getAreaOfFace() ####################################################### radstress, orthstress,stresseigenvalue1, stresseigenvalue2 = getRadialOrthoradialStress(face) radGrowth, orthGrowth, growtheigenvalue1, growtheigenvalue2 = getRadialOrthoradialGrowth(face) ####################################################### radialStress.append(radstress) orthoradialStress.append(orthstress) radialGrowth.append(radGrowth) orthoradialGrowth.append(orthGrowth) stressEigenvalue1Array.append(stresseigenvalue1) stressEigenvalue2Array.append(stresseigenvalue2) growthEigenvalue1Array.append(growtheigenvalue1) growthEigenvalue2Array.append(growtheigenvalue2) gaussianCurvatureArray.append(sf.getFaceWeightedGaussianCurvature(face)) ###################################################### radialStressArray.append(np.mean(radialStress)) orthoradialStressArray.append(np.mean(orthoradialStress)) radialGrowthArray.append(np.mean(radialGrowth)) orthoradialGrowthArray.append(np.mean(orthoradialGrowth)) tissueSurfaceAreaArray.append(tissueSurfaceArea) primordiaAreaArray.append(primordiaarea) boundaryAreaArray.append(boundaryarea) ###################################################### height = getPrimordiaHeight(cell,targetid) heightArray.append(height) ###################################################### meanstressEigenvalue1Array.append(np.mean(stressEigenvalue1Array)) meanstressEigenvalue2Array.append(np.mean(stressEigenvalue2Array)) meangrowthEigenvalue1Array.append(np.mean(growthEigenvalue1Array)) meangrowthEigenvalue2Array.append(np.mean(growthEigenvalue2Array)) meangaussianCurvatureArray.append(np.mean(gaussianCurvatureArray)) ####################################################### # calculating the standard deviation ####################################################### meanstressEigenvalue1SDArray.append(np.std(stressEigenvalue1Array)) meanstressEigenvalue2SDArray.append(np.std(stressEigenvalue2Array)) meangrowthEigenvalue1SDArray.append(np.std(growthEigenvalue1Array)) meangrowthEigenvalue2SDArray.append(np.std(growthEigenvalue2Array)) radialStressSDArray.append(np.std(radialStress)) orthoradialStressSDArray.append(np.std(orthoradialStress)) radialGrowthSDArray.append(np.std(radialGrowth)) orthoradialGrowthSDArray.append(np.std(orthoradialGrowth)) #meanstress.errorbar(tissueSurfaceArea, np.mean(radialStress), # yerr = np.std(radialStress)/float(len(radialStress)),fmt='o',label = r":$\sigma_{r}$",c=color,**plotargs) #meanstress.errorbar(tissueSurfaceArea, np.mean(orthoradialStress), # yerr = np.std(orthoradialStress)/float(len(orthoradialStress)),fmt='<',label = r":$\sigma_{o}$",c=color,**plotargs) ######################################################################## # mean dilation ######################################################################## #meandilation.errorbar(tissueSurfaceArea, np.mean(radialGrowth), # yerr = np.std(radialGrowth)/float(len(radialGrowth)),fmt='o',label = r":$g_{r}$",c=color,**plotargs) #meandilation.errorbar(tissueSurfaceArea, np.mean(orthoradialGrowth), # yerr = np.std(orthoradialGrowth)/float(len(orthoradialGrowth)),fmt='<',label = r":$g_{o}$",c=color,**plotargs) ######################################################################## laststep = step ######################################################################## print tissueSurfaceArea, tissueSurfaceArea2,dTissueSurfaceArea, step , step2 ######################################################################## return [tissueSurfaceAreaArray, radialStressArray, orthoradialStressArray, radialGrowthArray, orthoradialGrowthArray, primordiaAreaArray, heightArray, meanstressEigenvalue1Array, meanstressEigenvalue2Array, meangrowthEigenvalue1Array, meangrowthEigenvalue2Array, boundaryAreaArray, radialStressSDArray, orthoradialStressSDArray, radialGrowthSDArray, orthoradialGrowthSDArray, meanstressEigenvalue1SDArray, meanstressEigenvalue2SDArray, meangrowthEigenvalue1SDArray, meangrowthEigenvalue2SDArray, meangaussianCurvatureArray ]
def plotMeanGrowthRate(step, numOfLayer=8, eta=0, targetface=10, alpha=0.8, Length=1.0, save=False, azim=-70, elev=50): import matplotlib.colors as colors import matplotlib.cm as cmx #import the libraries from mpl_toolkits.mplot3d import Axes3D import matplotlib as mpl from mpl_toolkits.mplot3d.art3d import Poly3DCollection import numpy as np import matplotlib.pyplot as plt #limits of the plot radius = (numOfLayer > 1) * (np.sqrt(3.) * (numOfLayer - 1) - Length) + Length #the radius of circle to be projected on #plotting part fig = plt.figure(frameon=False, figsize=(10, 8)) #fig = plt.figure(frameon=False) fig.subplots_adjust(left=0, right=1, bottom=0, top=1) ax = Axes3D(fig) ax.set_xlim((-0.7 * radius, 0.7 * radius)) ax.set_ylim((-0.7 * radius, 0.7 * radius)) ax.set_zlim((-0., 1.4 * radius)) ax.axis('off') ax.xaxis.pane.set_edgecolor('black') ax.yaxis.pane.set_edgecolor('black') #ax.xaxis.pane.fill = False #ax.yaxis.pane.fill = False #ax.zaxis.pane.fill = False ####################################################################### # Checking if the files exists if not going to step down try: #cell = qd.objReadCell("qdObject_step=%03d.obj"%step) cell = sf.loadCellFromFile(step) #print "success" except: #print " exception reached" step -= 1 #sys.stdout.write("step : ", step , os.getcwd()) #sys.stdout.flush() #print "step : ", step , os.getcwd() plotMeanGrowthRate(step, azim=azim, elev=elev, eta=eta, save=save) return #print "Step : ", step ######################################################################## # Loading the step-1 step # ######################################################################## completeFaceArray = getFaceAreaArray(step) rateDict = {} for key in completeFaceArray: value = np.array(completeFaceArray[key]) rateDict[key] = np.mean(np.array(getRates(value))) #################################################################################### # PLotting the faces now #################################################################################### cell = qd.objReadCell("qdObject_step=%03d.obj" % step) # Flipping the Face ID after Loading to cell so that the face id before and after matches faces = qd.CellFaceIterator(cell) facecount = cell.countFaces() face = faces.next() while face != None: faceid = face.getID() face.setID(facecount - faceid + 1) #print face.getID() face = faces.next() ###################################################### #settig target Form Matrix : #TMF step corresponds to coordinate step #### cell = sf.setTargetFormMatrix(cell, step) cell.setParameters() #calculating forces, stress-matrix and strain-matrix #cell.calculateVertexForce() cell.calculateStrain() ######## ######## ######## ######## ######## # Plotting the Cell # ######## ######## ######## ######## ######## ######### Color Map jet = cm = plt.get_cmap('viridis') maxvalue = 0.006 minvalue = 0. #print "Max value", maxvalue, " minvalue", minvalue cNorm = colors.Normalize(vmin=minvalue, vmax=maxvalue) scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet) faces = qd.CellFaceIterator(cell) ################### face = faces.next() xcenarray = [] ycenarray = [] zcenarray = [] counter = 0 while (face != None): if face.getID() == 1: face = faces.next() continue faceid = face.getID() #grabbing face id xlist = [] ylist = [] zlist = [] xproj = [] yproj = [] zproj = [] #print "== Face ID : ", faceid, "==" xmean = face.getXCentralised() ymean = face.getYCentralised() zmean = face.getZCentralised() edges = qd.FaceEdgeIterator(face) edge = edges.next() while edge != None: ####grabbing the origin of edge#### #centralised coordiante vertex = edge.Org() #print vertex.getID() xCoord1 = vertex.getXcoordinate() yCoord1 = vertex.getYcoordinate() zCoord1 = vertex.getZcoordinate() xlist.append(xCoord1) ylist.append(yCoord1) zlist.append(zCoord1) edge = edges.next() xlist.append(xlist[0]) ylist.append(ylist[0]) zlist.append(zlist[0]) verts = [zip(xlist, ylist, zlist)] #adding to 3d plot xcenarray.append(face.getXCentralised()) ycenarray.append(face.getYCentralised()) zcenarray.append(face.getZCentralised()) #print "face ID : ", face.getID(), " ratio : ", ratio #ratio = (face.getStrainTrace()+minTrace)/(minTrace+maxTrace) """if sf.checkExternalFace(face): ratio = 0. color = scalarMap.to_rgba(ratio) else: """ ratio = rateDict[face.getID()] #print ratio color = scalarMap.to_rgba(ratio) #print ratio #print face.getZCentralised(), alpha_fac #ax.add_collection3d(arrow(xcen-0.5,ycen-0.5,zcen-0.5,xcen+0.5,ycen+0.5,zcen+0.5)) pc = Poly3DCollection(verts, alpha=alpha, facecolor=color, linewidths=1, zorder=0) pc.set_edgecolor('k') ax.add_collection3d(pc) ax.scatter(xcenarray[-1], ycenarray[-1], zcenarray[-1], c='r') face = faces.next() #if face.getID() == 1: break #plt.clf() ax.view_init(azim=azim, elev=elev) scalarMap._A = [] ax.set_title("Mean Growth Rate Step %d" % step) cbar_ax = fig.add_axes([0.873, 0.2, 0.04, 0.55]) clrbar = plt.colorbar( scalarMap, cax=cbar_ax) #,orientation='horizontal',cax = cbar_ax) clrbar.ax.tick_params(labelsize=20) clrbar.set_label("Growth Rate step", fontsize=30) #ax.set_title("Time %d : Magnitude of Strain : Max %.4f ; Min %.4f"%(step,maxTrace,minTrace), fontsize = 20) #print xcenarray-0.5 #plt.close("all") if save: saveDirectory = "../meanGrowthRate" import os if not os.path.exists(saveDirectory): os.makedirs(saveDirectory) plt.savefig(saveDirectory + r"/meanGrowthRate_eta=%.3f_time=%03d.png" % (eta, step), transparent=True) plt.close() return
def plotAverageFaceArea(endstep,areaplot,ax2 ,ax3,m0plot,m0log,color,startstep=1,norm=False,fastid = 0,targetid = 135): import matplotlib.colors as colors import matplotlib.cm as cmx # Getting Initial Area ###################################################### # Gathering face area ###################################################### totalMeanFaceArea = [] m0determinantArray = [] slowmeanarray = [] fastmeanarray = [] ################################################ # Getting neighbours of the fast growing face ################################################ cell = sf.loadCellFromFile(0) faceidarray = getNeighbourFaces(cell,targetid) ################################################ for i in range(startstep,endstep+1): if not os.path.isfile("qdObject_step=%03d.obj"%i):#check if file exists break cell = sf.loadCellFromFile(i) cell.setParameters() facearea = 0. tfmDet = 0. ###################################### slowfacearea = 0. fastfacearea = 0. faces = qd.CellFaceIterator(cell) face = faces.next() numfaces = 0. fastnum = 0. while face != None: if face.getID() == 1 : face = faces.next() continue tfmDet += face.getTargetFormMatrixDeterminant() #print face.getID(), area0 facearea+= face.getAreaOfFace() if np.isnan(face.getAreaOfFace()): print "Step :", i, "face ID : ", face.getID() ################################################### # Saving in slow and fast array ################################################### if face.getID() in faceidarray: fastfacearea += face.getAreaOfFace() fastnum += 1 else: slowfacearea += face.getAreaOfFace() numfaces += 1. face = faces.next() totalMeanFaceArea.append(facearea/numfaces) m0determinantArray.append(tfmDet/numfaces) slowmeanarray.append(slowfacearea/(numfaces - fastnum)) fastmeanarray.append(fastfacearea/fastnum) ###################################################### # plotting ###################################################### time = np.arange(startstep, len(totalMeanFaceArea)+startstep) ax2.plot(time,totalMeanFaceArea,color = color) import math logMeanArea = [math.log(i) for i in totalMeanFaceArea] ax3.plot(time,logMeanArea,color = color) m0plot.plot(time,m0determinantArray,color = color) logm0 = [] for i in m0determinantArray: try: math.log(i) except ValueError: print os.getcwd(), 7*" ",i logm0.append(0) else: logm0.append(math.log(i)) m0log.plot(time,logm0,color = color) #ax2.fill_between(range(len(fastfaceareamean)),fastfaceareamean-fastfaceareastd,fastfaceareamean+fastfaceareastd,alpha = 0.5) #ax2.plot(range(len(fastfaceareamean)),fastfaceareamean) #ax2.fill_between(range(len(slowfaceareamean)),slowfaceareamean-slowfaceareastd,slowfaceareamean+slowfaceareastd,alpha = 0.5) #ax2.plot(range(len(slowfaceareamean)),slowfaceareamean) #ax2.plot(range(len(value)),value,c = scalarMap.to_rgba(key)) #ax1.set_xlim(0,100) #plt.show() return [totalMeanFaceArea, m0determinantArray, fastmeanarray, slowmeanarray]
def plotMinGaussianCurvaturePrimodiaHeight(numOfLayer, targetid,endStep,eta, mincurvatureplot, heightplot,ax3,ax4,ax5,ax6,ax7, color,startStep=0,stepsize= 1,largerCondition = False,maxarea = None,resetids = True): import numpy as np import matplotlib.pyplot as plt import os ######################################################################## # faceidarray for Primordia if not os.path.isfile("qdObject_step=000.obj"): return [0.,0.,0.,0.,0.,0.,0.,0.,0.] cell = sf.loadCellFromFile(0,resetids = resetids) faceList = sf.getPrimordiaFaces(cell,targetid, large = largerCondition) faceidarray = [xface.getID() for xface in faceList] primordialFaceNum = len(faceList) slowFaceNum = cell.countFaces()-primordialFaceNum- 1. #print largerCondition, faceidarray ####################################################################### # Checking if the files exists if not going to step down ####################################################################### meanGaussianCurvature = [] primodialheight = [] primodialAreaArray = [] tissueSurfaceAreaArray = [] surfaceAreaRatio = [] sphericityArray = [] tissueVolumeArray = [] timestep = [] ###################################################### # Gathering face area ###################################################### m0determinantArray = [] slowarray = [] fastarray = [] ####################################################################### # Starting the Calculation ####################################################################### ##################################### #Getting initial area of primodial ##################################### if not os.path.isfile("qdObject_step=001.obj"): return [0.,0.,0.,0.,0.,0.,0.,0.,0.] cell = sf.loadCellFromFile(1,resetids = resetids) ################################# # face area data ################################# tfmdet, slowfacearea, fastfacearea,areaPrimodia = getFaceAreaData(cell,faceidarray) ################################################################## areaInitialPrimodia = areaPrimodia ####################################################################### for step in range(startStep,endStep+1,stepsize): if not os.path.isfile("qdObject_step=%03d.obj"%step):#check if file exists break cell = sf.loadCellFromFile(step,resetids = resetids) ################################# # face area data ################################# tfmdet, slowfacearea, fastfacearea,areaPrimodia = getFaceAreaData(cell,faceidarray) m0determinantArray.append(tfmdet) ################################################################################ # saving the mean area ################################################################################ slowarray.append(slowfacearea/slowFaceNum) fastarray.append(fastfacearea/primordialFaceNum) ######################################################################## # Starting the Calcuation of Primordial Height & Curvature # ######################################################################## gaussianCurvature = [] meanpointx = [] meanpointy = [] meanpointz = [] tissueSurfaceArea = sf.getSurfaceArea(cell) tissueVolume = cell.getCartesianVolume() sphericity = (np.pi**(1./3.)*(2.**(1./2.)*3*tissueVolume)**(2./3.))/(tissueSurfaceArea) ######################################################################## # Getting the primordial boundary ######################################################################## facetarget = sf.getFace(cell, targetid) ########################################## # Vertex on primordial boundary ########################################## vertexList = getPrimordiaBoundaryVertexList(cell, targetface=targetid,large = largerCondition) vertexNum = len(vertexList) #################################################### # Calculation of primordial height starts here # This is for smaller primordia #################################################### meanx = 0. meany = 0. meanz = 0. for vert in vertexList:#while edge.Dest().getID() != targetedge.Dest().getID(): meanx,meany,meanz = addMeanVertex(vert,meanx,meany,meanz) gaussianCurvature.append(vert.getGaussianCurvature()) ###################################### targetx = facetarget.getXCentralised() targety = facetarget.getYCentralised() targetz = facetarget.getZCentralised() meanx /= vertexNum meany /= vertexNum meanz /= vertexNum height = np.sqrt((meanx-targetx)**2+(meany-targety)**2+(meanz-targetz)**2) ########################################################################## primodialheight.append(height) tissueSurfaceAreaArray.append(tissueSurfaceArea) primodialAreaArray.append(areaPrimodia) surfaceAreaRatio.append((areaPrimodia/(tissueSurfaceArea))) sphericityArray.append(sphericity) meanGaussianCurvature.append(np.mean(np.array(gaussianCurvature))) tissueVolumeArray.append(tissueVolume) timestep.append(step-1.) ################################################################################# # Plotting ################################################################################# # calculating the plotlen if maxarea: plotlen = ppf.getPlotlenMaxArea(tissueSurfaceAreaArray,maxarea) #print timestep, primodialheight, meanGaussianCurvature # Min Gaussian curvature #print timestep mincurvatureplot.plot(tissueSurfaceAreaArray[:plotlen],meanGaussianCurvature[:plotlen],c=color,lw = 1.5) ################################### # Height of Primodia heightplot.plot(tissueSurfaceAreaArray[:plotlen], primodialheight[:plotlen], c=color,lw = 1.5) ################################### # primordial area vs surface area ax3.plot(tissueSurfaceAreaArray[:plotlen], primodialAreaArray[:plotlen], c = color, lw = 1.5) ################################### # surface area vs time ax4.plot(timestep[:plotlen],tissueSurfaceAreaArray[:plotlen], c = color, lw = 1.5) #print timestep, primodialheight, meanGaussianCurvature # Min Gaussian curvature #print timestep mincurvatureplot.plot(tissueSurfaceAreaArray,meanGaussianCurvature,c=color,lw = 1.5) ################################### # Height of Primodia heightplot.plot(tissueSurfaceAreaArray, primodialheight, c=color,lw = 1.5) ################################### # primordial area vs surface area ax3.plot(tissueSurfaceAreaArray, primodialAreaArray, c = color, lw = 1.5) ################################### # surface area vs time ax4.plot(timestep,tissueSurfaceAreaArray, c = color, lw = 1.5) ######################################################## #ax3.plot(primodialAreaArray,meanGaussianCurvature,c=color,lw =1.5) #ax4.plot(primodialAreaArray,primodialheight,c=color,lw = 1.5) ######################################################## #ax5.plot(surfaceAreaRatio,meanGaussianCurvature,c=color,lw =1.5) #ax6.plot(surfaceAreaRatio,primodialheight,c=color,lw = 1.5) ######################################################## #ax7.plot(timestep, sphericityArray,c=color,lw = 1.5) return [primodialheight, meanGaussianCurvature,primodialAreaArray, tissueSurfaceAreaArray,tissueVolumeArray, sphericityArray,m0determinantArray, fastarray, slowarray,timestep]
def plotAverageFaceArea(endstep, areaplot, ax2, ax3, ax4, ax5, m0plot, m0log, color, startstep=1, norm=False, fastid=0): import matplotlib.colors as colors import matplotlib.cm as cmx # Getting Initial Area ###################################################### # Gathering face area ###################################################### totalMeanFaceArea = [] m0determinantArray = [] for i in range(startstep, endstep + 1): if not os.path.isfile( "qdObject_step=%03d.obj" % i): #check if file exists break cell = sf.loadCellFromFile(i) cell.setParameters() facearea = 0. tfmDet = 0. ###################################### faces = qd.CellFaceIterator(cell) face = faces.next() numfaces = 0. while face != None: if face.getID() == 1: face = faces.next() continue tfmDet += face.getTargetFormMatrixDeterminant() #print face.getID(), area0 facearea += face.getAreaOfFace() if np.isnan(face.getAreaOfFace()): print "Step :", i, "face ID : ", face.getID() numfaces += 1. face = faces.next() totalMeanFaceArea.append(facearea / numfaces) m0determinantArray.append(tfmDet / numfaces) #print facearea ###################################################### # making plot ###################################################### ######################## # plotting ######################## #areaplot.fill_between(range(len(fastfaceareamean)),fastfaceareamean-fastfaceareastd,fastfaceareamean+fastfaceareastd,alpha = 0.3,color = color) #areaplot.plot(range(len(fastfaceareamean)),fastfaceareamean,color = color) #areaplot.fill_between(range(len(slowfaceareamean)),slowfaceareamean-slowfaceareastd,slowfaceareamean+slowfaceareastd,alpha = 0.5,color = color) #areaplot.plot(range(len(slowfaceareamean)),slowfaceareamean,color = color) time = np.arange(startstep, len(totalMeanFaceArea) + startstep) ax2.plot(time, totalMeanFaceArea, color=color) import math logMeanArea = [math.log(i) for i in totalMeanFaceArea] ax3.plot(time, logMeanArea, color=color) ax4.plot(np.log(time[1:]), np.log(logMeanArea[1:])) ax5.plot(np.log(time[1:]), totalMeanFaceArea[1:]) m0plot.plot(time, m0determinantArray, color=color) logm0 = [math.log(i) for i in m0determinantArray] m0log.plot(time, logm0, color=color) #ax2.fill_between(range(len(fastfaceareamean)),fastfaceareamean-fastfaceareastd,fastfaceareamean+fastfaceareastd,alpha = 0.5) #ax2.plot(range(len(fastfaceareamean)),fastfaceareamean) #ax2.fill_between(range(len(slowfaceareamean)),slowfaceareamean-slowfaceareastd,slowfaceareamean+slowfaceareastd,alpha = 0.5) #ax2.plot(range(len(slowfaceareamean)),slowfaceareamean) #ax2.plot(range(len(value)),value,c = scalarMap.to_rgba(key)) #ax1.set_xlim(0,100) #plt.show() return [totalMeanFaceArea, m0determinantArray]
def plotHeightGrowthScatter(numOfLayer, targetid, endStep, eta, stressscatter, growthscatter, stressscatter1, growthscatter1, anisotropyplot, color='r', maxeta=20, startStep=0, stepsize=1, largerCondition=True, maxarea=None, areastep=20, cloud=False, startarea=None, resetids=True, endarea=850): import numpy as np import matplotlib.pyplot as plt import os ######################################################################## # faceidarray for Primordia if not os.path.isfile("qdObject_step=001.obj"): return [0., 0., 0., 0., 0., 0., 0., 0., 0.] cell = sf.loadCellFromFile(1, resetids=resetids) initialTissueSurfaceArea = sf.getSurfaceArea(cell) ####################################################################### # Starting the Calculation ####################################################################### laststep = 1 plotargs = { "markersize": 10, "capsize": 10, "elinewidth": 3, "markeredgewidth": 2 } ####################################################################### orthoradialStressArray = [] radialStressArray = [] radialGrowthArray = [] orthoradialGrowthArray = [] tissueSurfaceAreaArray = [] primordiaAreaArray = [] heightArray = [] meanstressEigenvalue1Array = [] meanstressEigenvalue2Array = [] meangrowthEigenvalue1Array = [] meangrowthEigenvalue2Array = [] meanstressdiffarray = [] areadiffarray = [] if not startarea: #no startarea given startarea = int(initialTissueSurfaceArea) for steparea in range(startarea, endarea, int(areastep)): step, tissueSurfaceArea = getTimeStep(steparea, endStep, laststep, stepsize=5, resetids=resetids) ######################################################################## step2, tissueSurfaceArea2 = getTimeStep(steparea + areastep, endStep, step, stepsize=5, resetids=resetids) ######################################################################## if not os.path.isfile( "qdObject_step=%03d.obj" % step): #check if file exists break cell = sf.loadCellFromFile(step, resetids=resetids) cell2 = sf.loadCellFromFile(step2, resetids=resetids) ################################################ cell.calculateStressStrain() ################################################ primordialface = sf.getFace(cell, targetid) ################################################ cell.setRadialOrthoradialVector(primordialface) cell.setRadialOrthoradialStress() ################################################ sf.calculateDilation(cell, cell2) ######################################################################## # Starting the Calculation of mean growth and mean stress on boundary ######################################################################## # mean stress ######################################################################## faceList = sf.getPrimordiaBoundaryFaceList(cell, targetid, large=large) primordiafacelist = sf.getPrimordiaFaces(cell, targetid, large=False) primordiaarea = 0. for face in primordiafacelist: primordiaarea += face.getAreaOfFace() ###################################################### #radialDict, orthoradialDict = getRadialOrthoradialDict(cell,targetid,large = large) ###################################################### stressEigenvalue1Array = [] stressEigenvalue2Array = [] growthEigenvalue1Array = [] growthEigenvalue2Array = [] stressdiffarray = [] growthdiffarray = [] dTissueSurfaceArea = tissueSurfaceArea2 - tissueSurfaceArea height = getPrimordiaHeight(cell, targetid) height2 = getPrimordiaHeight(cell2, targetid) dhdA = (height2 - height) / dTissueSurfaceArea for face in faceList: radstress, orthstress, stresseigenvalue1, stresseigenvalue2 = getRadialOrthoradialStress( face) radGrowth, orthGrowth, growtheigenvalue1, growtheigenvalue2 = getRadialOrthoradialGrowth( face) stressEigenvalue1Array.append(stresseigenvalue1) stressEigenvalue2Array.append(stresseigenvalue2) growthEigenvalue1Array.append(growtheigenvalue1) growthEigenvalue2Array.append(growtheigenvalue2) stressdiffarray.append(stresseigenvalue2 - stresseigenvalue1) growthdiffarray.append(growtheigenvalue2 - growtheigenvalue1) ####################################################### # plotting ####################################################### meanstresseigen1 = np.mean(stressEigenvalue1Array) meanstresseigen2 = np.mean(stressEigenvalue2Array) meangrowtheigenvalue1 = np.mean(growthEigenvalue1Array) meangrowtheigenvalue2 = np.mean(growthEigenvalue2Array) sigma2 = max(meanstresseigen1, meanstresseigen2) sigma1 = min(meanstresseigen1, meanstresseigen2) g2 = max(meangrowtheigenvalue1, meangrowtheigenvalue2) g1 = min(meangrowtheigenvalue1, meangrowtheigenvalue2) ####################################################### stressscatter.scatter(sigma2 - sigma1, dhdA, c=color, marker='o', alpha=0.7, zorder=maxeta - eta) growthscatter.scatter(g2 - g1, dhdA, c=color, marker='o', alpha=0.7, zorder=maxeta - eta) ####################################################### stressscatter1.scatter(np.mean(stressdiffarray), dhdA, c=color, marker='o', alpha=0.7, zorder=maxeta - eta) growthscatter1.scatter(np.mean(growthdiffarray), dhdA, c=color, marker='o', alpha=0.7, zorder=maxeta - eta) ####################################################### anisotropyplot.scatter(np.mean(stressdiffarray), dhdA, c=color, marker='o', alpha=0.7, zorder=maxeta - eta) meanstressdiffarray.append(np.mean(stressdiffarray)) areadiffarray.append(dhdA) ######################################################################## laststep = step ######################################################################## print tissueSurfaceArea, tissueSurfaceArea2, dTissueSurfaceArea, step, step2 ######################################################################## if cloudCondition: points = np.vstack((meanstressdiffarray, areadiffarray)).T hull_pts = ConvexHull(points) hull_pts = points[hull_pts.vertices] hull_pts = np.vstack((hull_pts, hull_pts[0])).T interpolatex, interpolatey = interpolatedata(hull_pts) anisotropyplot.plot(interpolatex, interpolatey, c=color, ls='--', lw=2) ######################################################################## return [meanstressdiffarray, areadiffarray]
def plotPrincipalStress(numOfLayer, targetid, endStep, eta, meanstressplot, color, startStep=0, stepsize=1, largerCondition=True, maxarea=None, areastep=20, startarea=None, endarea=850): import numpy as np import matplotlib.pyplot as plt import os ######################################################################## # faceidarray for Primordia if not os.path.isfile("qdObject_step=001.obj"): return [0., 0., 0., 0., 0., 0., 0., 0., 0.] cell = sf.loadCellFromFile(1) initialTissueSurfaceArea = sf.getSurfaceArea(cell) ####################################################################### # Starting the Calculation ####################################################################### laststep = 1 plotargs = { "markersize": 10, "capsize": 10, "elinewidth": 3, "markeredgewidth": 2 } ####################################################################### tissueSurfaceAreaArray = [] meanstressEigenvalue1Array = [] meanstressEigenvalue2Array = [] heightArray = [] primordialAreaArray = [] radialStressArray = [] orthoradialStressArray = [] if not startarea: #no startarea given startarea = int(initialTissueSurfaceArea) for steparea in range(startarea, endarea, int(areastep)): step, tissueSurfaceArea = getTimeStep(steparea, endStep, laststep, stepsize=10) ######################################################################## if not os.path.isfile( "qdObject_step=%03d.obj" % step): #check if file exists break cell = sf.loadCellFromFile(step) ################################################ cell.calculateStressStrain() ################################################ primordialface = sf.getFace(cell, targetid) ################################################ cell.setRadialOrthoradialVector(primordialface) cell.setRadialOrthoradialStress() ################################################ ######################################################################## # Starting the Calculation of mean growth and mean stress on boundary ######################################################################## # mean stress ######################################################################## faceList = sf.getPrimordiaBoundaryFaceList(cell, targetid, large=large) height = getPrimordiaHeight(cell, targetid) ############################################### primordiafacelist = sf.getPrimordiaFaces(cell, targetid, large=False) primordiaarea = 0. for face in primordiafacelist: primordiaarea += face.getAreaOfFace() ###################################################### #radialDict, orthoradialDict = getRadialOrthoradialDict(cell,targetid,large = large) ###################################################### stressEigenvalue1Array = [] stressEigenvalue2Array = [] radialStress = [] orthoradialStress = [] for face in faceList: radstress = face.getRadialStress() orthstress = face.getOrthoradialStress() stresseigenvalue1 = face.getStressEigenValue1() stresseigenvalue2 = face.getStressEigenValue2() radialStress.append(radstress) orthoradialStress.append(orthstress) ####################################################### stressEigenvalue1Array.append(stresseigenvalue1) stressEigenvalue2Array.append(stresseigenvalue2) ###################################################### tissueSurfaceAreaArray.append(tissueSurfaceArea) heightArray.append(height) ###################################################### meanstressEigenvalue1Array.append(np.mean(stressEigenvalue1Array)) meanstressEigenvalue2Array.append(np.mean(stressEigenvalue2Array)) radialStressArray.append(np.mean(radialStress)) orthoradialStressArray.append(np.mean(orthoradialStress)) primordialAreaArray.append(primordiaarea) ######################################################################## laststep = step ######################################################################## return [ tissueSurfaceAreaArray, meanstressEigenvalue1Array, meanstressEigenvalue2Array, np.add(meanstressEigenvalue1Array, meanstressEigenvalue2Array), np.subtract(meanstressEigenvalue2Array, meanstressEigenvalue1Array), heightArray, primordialAreaArray, radialStressArray, orthoradialStressArray ]