Exemplo n.º 1
0
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]
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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 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]
Exemplo n.º 6
0
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 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 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 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
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
    ]
Exemplo n.º 12
0
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]