def start(self): self.pt=CompuCell.Point3D() # set uniform VEGF_ext field for ECM self.tempvar=os.getcwd()+"/vasculo_steppableBasedMitosis_py_"+run_time+"_Data.txt" totaldatafilename=open(self.tempvar, "w") totaldatafilename.write("MCS\tId\tType\tVolume\tSurfaceArea\tX_Location\tY_Location\tVEGF165\tVEGF121\tTotalVEGF\tCXCL10\tCCL2\tGrowing\tArrested\tQuiescent\tApoptotic\tTotal Cell Number\n") #first row, tab delimited totaldatafilename.close() for x in range(self.dim.x): for y in range(self.dim.y): CompuCell.getConcentrationField(self.simulator,"VEGF_ext").set(self.pt,.05) for cell in self.cellList: if cell.type==1: # endothelial stalk cells cell.targetVolume=30 cell.lambdaVolume=6.0 cell.targetSurface=4*sqrt(cell.targetVolume) cell.lambdaSurface=4.0 if cell.type==2: # macrophage/inflammatory cells cell.targetVolume=40 cell.lambdaVolume=6.0 cell.targetSurface=4*sqrt(cell.targetVolume) cell.lambdaSurface=4.0 if cell.type==3: # mural/VSMC cells cell.targetVolume=50 cell.lambdaVolume=6.0 cell.targetSurface=4*sqrt(cell.targetVolume) cell.lambdaSurface=4.0 if cell.type==4: # endothelial tip cells cell.targetVolume=30 cell.lambdaVolume=6.0 cell.targetSurface=5*sqrt(cell.targetVolume) cell.lambdaSurface=8.0
def step(self, mcs): pass # for cell in self.cellList: # cell.targetVolume+=1 # alternatively if you want to make growth a function of chemical concentration uncomment lines below and comment lines above O2field = CompuCell.getConcentrationField(self.simulator, "OXYGEN") MMPfield = CompuCell.getConcentrationField(self.simulator, "MMP") pt = CompuCell.Point3D() for cell in self.cellList: pt.x = int(cell.xCOM) pt.y = int(cell.yCOM) pt.z = int(cell.zCOM) O2Conc = O2field.get(pt) MMPConc = MMPfield.get(pt) if O2Conc < 0: print('--------~~~~~~~~~-----> O2 VERY LOW') print '------///------>', cell.targetVolume, O2Conc, MMPConc if cell.type == self.NORM and MMPConc > 1: print 'MMP CONC IS CRAZY!' # raw_input('!') cell.targetVolume -= 0.5 cell.lambdaVolume = 2 # raw_input('!-->removing a NORM cell') else: # if True: if cell.type == self.TPROL and O2Conc < 0: cell.type = self.TMIGR continue # O2Conc = np.abs(O2Conc) cell.targetVolume += 0.01 * O2Conc / ( 0.05 + O2Conc ) # you can use here any fcn of concentrationAtCOM
def step(self,mcs): pass # for cell in self.cellList: # cell.targetVolume+=1 # alternatively if you want to make growth a function of chemical concentration uncomment lines below and comment lines above O2field=CompuCell.getConcentrationField(self.simulator,"OXYGEN") MMPfield=CompuCell.getConcentrationField(self.simulator,"MMP") pt=CompuCell.Point3D() for cell in self.cellList: pt.x=int(cell.xCOM) pt.y=int(cell.yCOM) pt.z=int(cell.zCOM) O2Conc=O2field.get(pt) MMPConc=MMPfield.get(pt) if O2Conc < 0: print('--------~~~~~~~~~-----> O2 VERY LOW') print '------///------>',cell.targetVolume, O2Conc, MMPConc if cell.type == self.NORM and MMPConc > 1: print 'MMP CONC IS CRAZY!' # raw_input('!') cell.targetVolume -= 0.5 cell.lambdaVolume = 2 # raw_input('!-->removing a NORM cell') else: # if True: if cell.type == self.TPROL and O2Conc < 0: cell.type = self.TMIGR continue # O2Conc = np.abs(O2Conc) cell.targetVolume+=0.01*O2Conc / (0.05 + O2Conc) # you can use here any fcn of concentrationAtCOM
def step(self,mcs): fieldVEGF2=CompuCell.getConcentrationField(self.simulator,self.fieldNameVEGF2) fieldGlucose=CompuCell.getConcentrationField(self.simulator,self.fieldNameGlucose) print mcs for cell in self.cellList: #print cell.volume #NeoVascular if cell.type == self.NEOVASCULAR: totalArea = 0 # pt=CompuCell.Point3D() # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) # VEGFConcentration=fieldVEGF2.get(pt) VEGFConcentration=fieldVEGF2[int(round(cell.xCOM)),int(round(cell.yCOM)),int(round(cell.zCOM))] # cellNeighborList=CellNeighborListAuto(self.nTrackerPlugin,cell) cellNeighborList=self.getCellNeighbors(cell) for neighborSurfaceData in cellNeighborList: #Check to ensure cell neighbor is not medium if neighborSurfaceData.neighborAddress: if neighborSurfaceData.neighborAddress.type == self.VASCULAR or neighborSurfaceData.neighborAddress.type == self.NEOVASCULAR: #sum up common surface area of cell with its neighbors totalArea+=neighborSurfaceData.commonSurfaceArea #print " commonSurfaceArea:",neighborSurfaceData.commonSurfaceArea #print totalArea if totalArea < 45: #Growth rate equation cell.targetVolume+=2.0*VEGFConcentration/(0.01 + VEGFConcentration) print "totalArea", totalArea,"cell growth rate: ", 2.0*VEGFConcentration/(0.01 + VEGFConcentration),"cell Volume: ", cell.volume #Proliferating Cells if cell.type == self.PROLIFERATING: # pt=CompuCell.Point3D() # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) # GlucoseConcentration=fieldGlucose.get(pt) GlucoseConcentration=fieldGlucose[int(round(cell.xCOM)),int(round(cell.yCOM)),int(round(cell.zCOM))] # Proliferating Cells become Necrotic when GlucoseConcentration is low if GlucoseConcentration < 0.001 and mcs>1000: cell.type = self.NECROTIC #set growth rate equation -- fastest cell cycle is 24hours or 1440 mcs--- 32voxels/1440mcs= 0.022 voxel/mcs cell.targetVolume+=0.022*GlucoseConcentration/(0.05 + GlucoseConcentration) #print "growth rate: ", 0.044*GlucoseConcentration/(0.05 + GlucoseConcentration), "GlucoseConcentration", GlucoseConcentration #Necrotic Cells if cell.type == self.NECROTIC: #sNecrotic Cells shrink at a constant rate cell.targetVolume-=0.1
def step(self, mcs): global e MMPsecretor = self.getFieldSecretor("MMP") Isecretor = self.getFieldSecretor("I") GFsecretor = self.getFieldSecretor("GF") self.fieldNameMMP = 'MMP' self.fieldNameI = 'I' fieldMMP = CompuCell.getConcentrationField(self.simulator, self.fieldNameMMP) fieldI = CompuCell.getConcentrationField(self.simulator, self.fieldNameI) for cell in self.cellList: if cell.type == self.CANCER: x = random.randint(0, 4) MMPc = fieldMMP[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] Ic = fieldI[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] if mcs > 5: A = 2 - (2 * (-MMPc + 2 * Ic)) I1 = A else: A = x I1 = x MMPsecretor.secreteOutsideCellAtBoundaryOnContactWith( cell, A, [self.C1]) Isecretor.secreteOutsideCellAtBoundaryOnContactWith( cell, I1, [self.C1]) MMPsecretor.secreteOutsideCellAtBoundaryOnContactWith( cell, A, [self.LAMININ]) Isecretor.secreteOutsideCellAtBoundaryOnContactWith( cell, I1, [self.LAMININ]) GFsecretor.uptakeInsideCell(cell, 0.1, 0.1) if cell.type == self.L_LYSED: GFsecretor.secreteInsideCell(cell, 0.5) MMPsecretor.uptakeInsideCell(cell, 1.0, 1.0) Isecretor.uptakeInsideCell(cell, 0.5, 1.0) if cell.type == self.C_LYSED: GFsecretor.secreteInsideCellAtBoundary(cell, 1.0) MMPsecretor.uptakeInsideCell(cell, 1.5, 1.0) Isecretor.uptakeInsideCell(cell, 0.5, 1.0) if cell.type == self.C1: GFsecretor.secreteInsideCellAtBoundaryOnContactWith( cell, 2.5, [self.C_LYSED])
def step(self, mcs): #collagen degradation clCell = self.potts.createCell() clCell.type = self.C_LYSED llCell = self.potts.createCell() llCell.type = self.L_LYSED state = {} self.fieldNameMMP = 'MMP' self.fieldNameI = 'I' fieldMMP = CompuCell.getConcentrationField(self.simulator, self.fieldNameMMP) fieldI = CompuCell.getConcentrationField(self.simulator, self.fieldNameI) global var lysed_id = [] for cell in self.cellList: state = {} cellDict = CompuCell.getPyAttrib(cell) if cell.type == self.C1 or cell.type == self.LAMININ or cell.type == self.NC1: MMPc = fieldMMP[cell.xCOM, cell.yCOM, cell.zCOM] Ic = fieldI[cell.xCOM, cell.yCOM, cell.zCOM] if Ic > 0.0005: T1 = (MMPc / Ic) if T1 >= var: cell.type = self.C_LYSED lysed_id.append(cell) for cell in lysed_id: cellDict = CompuCell.getPyAttrib(cell) if hasattr(cell, "mcsL") == True: cell.targetvolume -= 0.005 cell.lambdaVolume = 20.0 else: cellDict = CompuCell.getPyAttrib(cell) mcs = self.simulator.getStep() mcsL = mcs cellDict["mcsL"] = mcsL mcs = self.simulator.getStep() for cell in self.cellList: cellDict = CompuCell.getPyAttrib(cell) if cell.type == self.C_LYSED: for val in cellDict.items(): cd1 = val[1] if cell.type == self.C_LYSED and mcs == (cd1 + 20): cell.type = self.NC1
def step(self, mcs): field = CompuCell.getConcentrationField(self.simulator, "Firstinhibitor") fielt = CompuCell.getConcentrationField(self.simulator, "Sactivator") fiell = CompuCell.getConcentrationField(self.simulator, "Secondinhibitor") comPt = CompuCell.Point3D() # concentrationAI=field.get(comPt) #concentrationA=fielt.get(comPt) for cell in self.cellList: if cell.type == self.UD or cell.type == self.G: if mcs > 0 and field[ cell.xCOM, cell.yCOM, cell.zCOM] < 0.5 and fiell[ cell.xCOM, cell.yCOM, cell.zCOM] > 0.5 and fielt[cell.xCOM, cell.yCOM, cell.zCOM] > 20: cell.type = self.OF if mcs > 0 and fiell[ cell.xCOM, cell.yCOM, cell.zCOM] < 0.5 and field[ cell.xCOM, cell.yCOM, cell.zCOM] > 0.5 and fielt[cell.xCOM, cell.yCOM, cell.zCOM] > 20: cell.type = self.OS if mcs > 0 and fiell[ cell.xCOM, cell.yCOM, cell.zCOM] < 0.5 and field[ cell.xCOM, cell.yCOM, cell.zCOM] < 0.5 and fielt[cell.xCOM, cell.yCOM, cell.zCOM] > 20: if random() < 0.5: cell.type = self.OS else: cell.type = self.OF #concentration=field[int(round(cell.xCOM)),int(round(cell.yCOM)),int(round(cell.zCOM))] #type here the code that will run every _frequency MCS for cell in self.cellList: currentCellPosition = cell.xCM / float(cell.volume) currentCellPositiony = cell.yCM / float(cell.volume) firstinhi = field[cell.xCOM, cell.yCOM, cell.zCOM] secondinhi = fiell[cell.xCOM, cell.yCOM, cell.zCOM] sactivator = fielt[cell.xCOM, cell.yCOM, cell.zCOM] print("id=", cell.id, "posx= ", currentCellPosition, "posy= ", currentCellPositiony, "Fi= ", firstinhi, "Si= ", secondinhi, "Sac= ", sactivator)
def step(self, mcs): fieldMMP = CompuCell.getConcentrationField(self.simulator, self.fieldNameMMP) fieldI = CompuCell.getConcentrationField(self.simulator, self.fieldNameI) fieldGF = CompuCell.getConcentrationField(self.simulator, self.fieldNameGF) comPt = CompuCell.Point3D() state = {} global c global ck global mcsOut global c_value global varii for cell in self.cellList: #collagen fibre elongation if cell.type == self.C1 and mcs < 5: cell.targetVolume += 0.8 cell.lambdaVolume = 20.0 if cell.type == self.CANCER: neighborList = self.getCellNeighborDataList(cell) k = neighborList.commonSurfaceAreaWithCellTypes( cell_type_list=[3]) s = cell.surface g = (s - k) / 40 GFc = fieldGF[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] cell.targetVolume += varii * ( (g / 4 + (GFc / 7)) / 3) #Growth rate cell.lambdaVolume = 20.0 #this term can be changed in correlation with stiffness of neighbors, as a fn of neighbor type,no etc if int(round(cell.xCOM)) > 97 or int(round( cell.xCOM)) < 3 or int(round(cell.yCOM)) > 97 or int( round(cell.yCOM)) < 3: self.deleteCell(cell) c += 1 if c == 1: mcsOut = mcs ck = c if ck != 0 and mcs % 5 == 0: c_value.append(ck)
def getMinConcentrationFieldAtCellId(self, fieldName, cellId): cell = self.getCellWithId(cellId) chemField = CompuCell.getConcentrationField(self.simulator, fieldName) pixelList = CellPixelList(self.pixelTrackerPlugin, cell) minConc = 1000000 for pixelData in pixelList: pt = pixelData.pixel conc = chemField.get(pt) minConc = min(minConc, conc) return minConc
def getConcentrationFieldAtCell(self, fieldName, cell): chemField = CompuCell.getConcentrationField(self.simulator, fieldName) pt = CompuCell.Point3D() pt.x = int(round(cell.xCOM)) pt.y = int(round(cell.yCOM)) pt.z = int(round(cell.zCOM)) # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) return chemField.get(pt)
def getMinConcentrationFieldAtCellId(self, fieldName, cellId): cell = self.getCellWithId(cellId) chemField=CompuCell.getConcentrationField(self.simulator,fieldName) pixelList=CellPixelList(self.pixelTrackerPlugin,cell) minConc = 1000000 for pixelData in pixelList: pt=pixelData.pixel conc = chemField.get(pt) minConc = min(minConc, conc) return minConc
def getConcentrationFieldAtCell(self, fieldName, cell): chemField=CompuCell.getConcentrationField(self.simulator,fieldName) pt=CompuCell.Point3D() pt.x=int(round(cell.xCOM)) pt.y=int(round(cell.yCOM)) pt.z=int(round(cell.zCOM)) # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) return chemField.get(pt)
def start(self): if self.hinder_anterior_cells: self.gene_product_field = CompuCell.getConcentrationField(self.simulator,'EN_GENE_PRODUCT') self.gene_product_secretor = self.getFieldSecretor('EN_GENE_PRODUCT') for cell in self.cellList: # THIS BLOCK HAS BEEN JUSTIFIED OUTSIDE OF EARLIER 'IF' STATEMENT (sdh) self.stripe_y = self.initial_stripe if cell.yCOM < self.stripe_y+self.stripe_width/2 and cell.yCOM > self.stripe_y-self.stripe_width/2: cell.type = 2 # EN cell if self.hinder_anterior_cells == True: self.gene_product_secretor.secreteInsideCell(cell, 1)
def start(self): if self.hinder_anterior_cells == True: self.gene_product_field = CompuCell.getConcentrationField(self.simulator,"EN_GENE_PRODUCT") self.gene_product_secretor = self.getFieldSecretor("EN_GENE_PRODUCT") for cell in self.cellList: self.stripe_y = 375 if cell.yCOM < self.stripe_y+5 and cell.yCOM > self.stripe_y-5: #cellDict["En_ON"] = True cell.type = 2 if self.hinder_anterior_cells == True: self.gene_product_secretor.secreteInsideCell(cell, 1)
def start(self): if self.hinder_anterior_cells == True: self.gene_product_field = CompuCell.getConcentrationField(self.simulator,"EN_GENE_PRODUCT") self.gene_product_secretor = self.getFieldSecretor("EN_GENE_PRODUCT") for cell in self.cellList: # THIS BLOCK HAS BEEN JUSTIFIED OUTSIDE OF EARLIER "IF" STATEMENT (sdh) self.stripe_y = 645 #375 if cell.yCOM < self.stripe_y+5 and cell.yCOM > self.stripe_y-5: # cellDict["En_ON"] = True cell.type = 2 # EN cell if self.hinder_anterior_cells == True: self.gene_product_secretor.secreteInsideCell(cell, 1)
def step(self,mcs): field=CompuCell.getConcentrationField(self.simulator,"FGF") for cell in self.cellList: if cell.type==self.CONDENSING and mcs < 1500: #Condensing cell concentration=field[int(round(cell.xCOM)),int(round(cell.yCOM)),int(round(cell.zCOM))] cell.targetVolume+=0.1*concentration # increase cell's target volume if mcs > 1500: #removing all cells cell.targetVolume-=1 # increase cell's target volume if cell.targetVolume<0.0: cell.targetVolume=0.0
def start(self): if self.hinder_anterior_cells == True: self.gene_product_field = CompuCell.getConcentrationField( self.simulator, "EN_GENE_PRODUCT") self.gene_product_secretor = self.getFieldSecretor( "EN_GENE_PRODUCT") for cell in self.cellList: # THIS BLOCK HAS BEEN JUSTIFIED OUTSIDE OF EARLIER "IF" STATEMENT (sdh) self.stripe_y = 645 #375 if cell.yCOM < self.stripe_y + 5 and cell.yCOM > self.stripe_y - 5: # cellDict["En_ON"] = True cell.type = 2 # EN cell if self.hinder_anterior_cells == True: self.gene_product_secretor.secreteInsideCell(cell, 1)
def outputField(self, _fieldName, _fileName): field = CompuCell.getConcentrationField(self.simulator, _fieldName) if field: try: fileHandle = open(_fileName, "w") except IOError: print "Could not open file ", _fileName, " for writing. Check if you have necessary permissions" print "dim.x=", self.dim.x for i in xrange(self.dim.x): for j in xrange(self.dim.y): for k in xrange(self.dim.z): fileHandle.write("%d\t%d\t%d\t%f\n" % (x, y, z, field[x, y, z]))
def step(self, mcs): field = CompuCell.getConcentrationField(self.simulator, "FGF") for cell in self.cellList: if cell.type == self.CONDENSING and mcs < 1500: #Condensing cell concentration = field[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] cell.targetVolume += 0.1 * concentration # increase cell's target volume if mcs > 1500: #removing all cells cell.targetVolume -= 1 # increase cell's target volume if cell.targetVolume < 0.0: cell.targetVolume = 0.0
def step(self, mcs): field = CompuCell.getConcentrationField(self.simulator, "FGF") comPt = CompuCell.Point3D() for cell in self.cellList: if cell.type == self.CONDENSING: # get the coordinates of the current cells loation comPt.x = int(round(cell.xCOM)) comPt.y = int(round(cell.yCOM)) comPt.z = int(round(cell.zCOM)) # use the point to get the concentration at this location conc = field.get(comPt) cell.targetVolume += 0.1 * conc
def step(self,mcs): fileName="diffusion_output/FGF_"+str(mcs)+".dat" field=CompuCell.getConcentrationField(self.simulator,"FGF") if field: try: import CompuCellSetup fileHandle,fullFileName=CompuCellSetup.openFileInSimulationOutputDirectory(fileName,"w") except IOError: print "Could not open file ", fileName," for writing. Check if you have necessary permissions" for i,j,k in self.everyPixel(): fileHandle.write("%d\t%d\t%d\t%f\n"%(i,j,k,field[i,j,k])) fileHandle.close()
def step(self,mcs): print "INSIDE MITOSIS STEPPABLE" self.fieldNeoVasc=CompuCell.getConcentrationField(self.simulator,self.fieldNameExternalVEGF) self.fieldNeoVascSol=CompuCell.getConcentrationField(self.simulator,self.fieldNameSolubleVEGF) cells_to_divide=[] for cell in self.cellList: vasculo_attributes=CompuCell.getPyAttrib(cell) if cell.type==1: if cell.volume>55: cells_to_divide.append(cell) if cell.type==3: if cell.volume>90: cells_to_divide.append(cell) if cell.type==2: if cell.volume>75: cells_to_divide.append(cell) for cell in cells_to_divide: # to change mitosis mode leave one of the below lines uncommented self.divideCellRandomOrientation(cell)
def step(self, mcs): # for cell in self.cellList: # cell.targetVolume+=1 # alternatively if you want to make growth a function of chemical concentration uncomment lines below and comment lines above # field=CompuCell.getConcentrationField(self.simulator,"PUT_NAME_OF_CHEMICAL_FIELD_HERE") # pt=CompuCell.Point3D() field = CompuCell.getConcentrationField(self.simulator, "R") ##### comPt = CompuCell.Point3D() ##### for cell in self.cellList: if cell.type == self.P: ##### comPt.x = int(cell.xCOM) comPt.y = int(cell.yCOM) comPt.z = int(cell.zCOM) concentrationAtCOM = field.get(comPt) cell.targetVolume += 0.01 * concentrationAtCOM # you can use here any fcn of concentrationAtCOM
def step(self, mcs): field = CompuCell.getConcentrationField(self.simulator, "Sactivator") comPt = CompuCell.Point3D() meanCon = 0.0 for cell in self.cellList: if cell.id == 1: comPt.x = int(round(cell.xCOM)) comPt.y = int(round(cell.yCOM)) comPt.z = int(round(cell.zCOM)) con = field.get(comPt) meanCon += con # get concentration at comPt self.Activator.addDataPoint("Activator", mcs, meanCon)
def start(self): #initial condition for diffusion field self.field = CompuCell.getConcentrationField(self.simulator, "FGF") # import numpy as np # self.fieldNP = np.zeros(shape=(self.dim.x,self.dim.y,self.dim.z),dtype=np.float32) # fieldNP[:]=field #a bit slow - will write faster version secrConst = 10 for x, y, z in self.everyPixel(1, 1, 1): cell = self.cellField[x, y, z] if cell and cell.type == 1: # notice for steady state solver we do not add secretion const to existing concentration # Also notice that secretion has to be negative (if we want positive secretion). This is how the solver is coded self.field[x, y, z] = -secrConst else: # for steady state solver all field pixels which do not secrete or uptake must me set to 0.0. This is how the solver works: # non-zero value of the field at the pixel indicates secretion rate self.field[x, y, z] = 0.0
def step(self, mcs): antibioticField = CompuCell.getConcentrationField( self.simulator, 'Antibiotic') for cell in self.cellList: if cell.type != self.MEDIUM: # get concentration at cells COM cellCOM = CompuCell.Point3D() cellCOM.x = int(round(cell.xCOM)) cellCOM.y = int(round(cell.yCOM)) cellCOM.z = int(round(cell.zCOM)) antibioticConcentration = antibioticField.get(cellCOM) # calculate damage based on concentration and ARF cellDict = CompuCell.getPyAttrib(cell) cellDict["Damage"] += ( 1 - cellDict["ARF"]) * antibioticConcentration * DAMAGE_FACTOR if cellDict["Damage"] >= 1: # too much damage -> die cell.targetVolume = 0 cell.lambdaVolume = 100
def start(self): #initial condition for diffusion field self.field=CompuCell.getConcentrationField(self.simulator,"FGF") # import numpy as np # self.fieldNP = np.zeros(shape=(self.dim.x,self.dim.y,self.dim.z),dtype=np.float32) # fieldNP[:]=field #a bit slow - will write faster version secrConst=10 for x,y,z in self.everyPixel(1,1,1): cell=self.cellField[x,y,z] if cell and cell.type==1: # notice for steady state solver we do not add secretion const to existing concentration # Also notice that secretion has to be negative (if we want positive secretion). This is how the solver is coded self.field[x,y,z]=-secrConst else: # for steady state solver all field pixels which do not secrete or uptake must me set to 0.0. This is how the solver works: # non-zero value of the field at the pixel indicates secretion rate self.field[x,y,z]=0.0
def step(self, mcs): field = CompuCell.getConcentrationField(self.simulator, "Oxygen") FiPyInteractor = FiPyInterface.FiPyInterfaceBase( 2) #dimension of lattice (currently, 2D only works) FiPyInteractor.fillArray3D(self.solver.phi._getArray(), field) doNotDiffuseVec = FiPyInteractor.getDoNoDiffuseVec() self.solver.setDoNotDiffuse(doNotDiffuseVec) self.solver.iterateDiffusion() pt = CompuCell.Point3D(0, 0, 0) print '\n', field.get(pt), sumField = 0 for i in xrange(self.dim.x): for j in xrange(self.dim.y): for k in xrange(self.dim.z): pt.x = i pt.y = j pt.z = k sumField += field.get(pt) print sumField
def step(self,mcs): field=CompuCell.getConcentrationField(self.simulator,"Oxygen") FiPyInteractor = FiPyInterface.FiPyInterfaceBase(2) #dimension of lattice (currently, 2D only works) FiPyInteractor.fillArray3D(self.solver.phi._getArray(),field) doNotDiffuseVec = FiPyInteractor.getDoNoDiffuseVec() self.solver.setDoNotDiffuse(doNotDiffuseVec) self.solver.iterateDiffusion() pt=CompuCell.Point3D(0,0,0) print '\n', field.get(pt), sumField = 0 for i in xrange(self.dim.x): for j in xrange(self.dim.y): for k in xrange(self.dim.z): pt.x=i pt.y=j pt.z=k sumField += field.get(pt) print sumField
def step(self, mcs): fieldVEGF2 = CompuCell.getConcentrationField(self.simulator, self.fieldNameVEGF2) fieldGlucose = CompuCell.getConcentrationField(self.simulator, self.fieldNameGlucose) print mcs for cell in self.cellList: #print cell.volume #NeoVascular if cell.type == self.NEOVASCULAR: totalArea = 0 # pt=CompuCell.Point3D() # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) # VEGFConcentration=fieldVEGF2.get(pt) VEGFConcentration = fieldVEGF2[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] # cellNeighborList=CellNeighborListAuto(self.nTrackerPlugin,cell) cellNeighborList = self.getCellNeighbors(cell) for neighborSurfaceData in cellNeighborList: #Check to ensure cell neighbor is not medium if neighborSurfaceData.neighborAddress: if neighborSurfaceData.neighborAddress.type == self.VASCULAR or neighborSurfaceData.neighborAddress.type == self.NEOVASCULAR: #sum up common surface area of cell with its neighbors totalArea += neighborSurfaceData.commonSurfaceArea #print " commonSurfaceArea:",neighborSurfaceData.commonSurfaceArea #print totalArea if totalArea < 45: #Growth rate equation cell.targetVolume += 2.0 * VEGFConcentration / ( 0.01 + VEGFConcentration) print "totalArea", totalArea, "cell growth rate: ", 2.0 * VEGFConcentration / ( 0.01 + VEGFConcentration), "cell Volume: ", cell.volume #Proliferating Cells if cell.type == self.PROLIFERATING: # pt=CompuCell.Point3D() # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) # GlucoseConcentration=fieldGlucose.get(pt) GlucoseConcentration = fieldGlucose[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] # Proliferating Cells become Necrotic when GlucoseConcentration is low if GlucoseConcentration < 0.001 and mcs > 1000: cell.type = self.NECROTIC #set growth rate equation -- fastest cell cycle is 24hours or 1440 mcs--- 32voxels/1440mcs= 0.022 voxel/mcs cell.targetVolume += 0.022 * GlucoseConcentration / ( 0.05 + GlucoseConcentration) #print "growth rate: ", 0.044*GlucoseConcentration/(0.05 + GlucoseConcentration), "GlucoseConcentration", GlucoseConcentration #Necrotic Cells if cell.type == self.NECROTIC: #sNecrotic Cells shrink at a constant rate cell.targetVolume -= 0.1
def step(self, mcs): fieldVEGF2 = CompuCell.getConcentrationField(self.simulator, self.fieldNameVEGF2) fieldGlucose = CompuCell.getConcentrationField(self.simulator, self.fieldNameGlucose) # if mcs == 10: # if mcs == 5000: # if mcs == 7000: # if mcs == 9000: # if mcs == 11000: # if mcs == 14000: # if mcs == 1000 or mcs == 5000 or mcs == 7000 or mcs == 9000 or mcs == 11000 or mcs==14000: # if mcs == 12000 or mcs == 16000: # hyper-fraction scheme if mcs == 12000 or mcs == 13000 or mcs == 14000 or mcs == 15000 or mcs == 16000: DCF = 10 dX = self.dim.x * DCF / float(1000) #change unit into mm dY = self.dim.y * DCF / float(1000) dZ = self.dim.z * DCF / float(1000) # radSource = RTM.RadiationSource('testInputSource') # radSource.PlaneSource(0,0,dZ/4.0,dX/100.0,dY/100.0,'e-',1000,0) # radTransport = RTM.RadiationTransport(self.dim,self.cellList,DCF)# importing tissue and cell geometry from CC3D # radTransport.Run("gui",radSource.GetSourceID()) # check geometry and radiation source radSource = RTM.RadiationSource('testInputSource') radSource.PlaneSource_MRT(0, 0, dZ / 2.0, dX / 2.0, dY / 20.0, 'e-', 1000, 1000) # radSource.PlaneSource(0,0,dZ/2.0,dX/2.0,dY/20.0,'e-',1000,500) radTransport = RTM.RadiationTransport( self.dim, self.cellList, DCF) # importing tissue and cell geometry from CC3D runMode = 'gui' + ' ' + self.simulationID print 'the runMode is: ', runMode # radTransport.Run("gui",radSource.GetSourceID()) # check geometry and radiation source # radSource.PlaneSource(0,0,dZ/2.0,dX/2.0,dY/20.0,'e-',1000,5000) radTransport.Run( runMode, radSource.GetSourceID()) # check geometry and radiation source simResult = RTM.CellSimulationResult(self.simulationID) simResult.ReadTransportTally(self.pDose) for cell in self.cellList: alpha = 0.25 # alpha value for quantifying effective energy beta = 0.03 # beta value for quantifying effective energy E1 = 0 # mean state energy of S1 state E3 = 48.47 # mean state energy of S2 state sigma = 6.96 # sigma of state energy distribution cellDose, cellDSB, normalized_dose, normalized_DSB = simResult.GetCellDose( cell.id) # print 'The dose for cell: ',cell.id, ' is: ',cellDose # print 'The DSB for cell: ', cell.id, 'is: ' , cellDSB # print 'The normalized dose for cell: ', cell.id, 'is: ', normalized_dose # print 'The normalized DSB for cell: ', cell.id, 'is: ', normalized_DSB delta_E = alpha * cellDSB # here we just consider the direct effect x = -abs(E1 + delta_E - E3) / 2 / sigma print 'delta energy is ', x p_total = 2 * stats.norm.cdf(x, 0, 1) if E1 + delta_E - E3 >= 0: p_total = 1 # boundary condition print 'the total jumping probability is: ', p_total jumpingProbabilityPerMCS = p_total if cellDose != 0: if random.random() < jumpingProbabilityPerMCS: cell.type = self.NECROTIC # if so, cell dies due to radiation killing numberOfTumorCells = 0 numberOfVascularCells = 0 numberOfNeovascularCells = 0 numberOfNecroticCells = 0 for cell in self.cellList: #print cell.volume #NeoVascular if cell.type == self.VASCULAR: numberOfVascularCells = numberOfVascularCells + 1 if cell.type == self.NEOVASCULAR: numberOfNeovascularCells = numberOfNeovascularCells + 1 totalArea = 0 # pt=CompuCell.Point3D() # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) # VEGFConcentration=fieldVEGF2.get(pt) VEGFConcentration = fieldVEGF2[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] # cellNeighborList=CellNeighborListAuto(self.nTrackerPlugin,cell) cellNeighborList = self.getCellNeighbors(cell) for neighborSurfaceData in cellNeighborList: #Check to ensure cell neighbor is not medium if neighborSurfaceData.neighborAddress: if neighborSurfaceData.neighborAddress.type == self.VASCULAR or neighborSurfaceData.neighborAddress.type == self.NEOVASCULAR: #sum up common surface area of cell with its neighbors totalArea += neighborSurfaceData.commonSurfaceArea #print " commonSurfaceArea:",neighborSurfaceData.commonSurfaceArea #print totalArea if totalArea < 45: #Growth rate equation cell.targetVolume += 2.0 * VEGFConcentration / ( 0.01 + VEGFConcentration) print "totalArea", totalArea, "cell growth rat& voxel/MCS \\e: ", 2.0 * VEGFConcentration / ( 0.01 + VEGFConcentration), "cell Volume: ", cell.volume #Proliferating Cells if cell.type == self.PROLIFERATING: numberOfTumorCells = numberOfTumorCells + 1 # tallying the tumor cells # pt=CompuCell.Point3D() # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) # GlucoseConcentration=fieldGlucose.get(pt) GlucoseConcentration = fieldGlucose[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] # Proliferating Cells become Necrotic when GlucoseConcentration is low if GlucoseConcentration < 0.001 and mcs > 1000: cell.type = self.NECROTIC #set growth rate equation -- fastest cell cycle is 24hours or 1440 mcs--- 32voxels/1440mcs= 0.022 voxel/mcs cell.targetVolume += 0.022 * GlucoseConcentration / ( 0.05 + GlucoseConcentration) #print "growth rate: ", 0.044*GlucoseConcentration/(0.05 + GlucoseConcentration), "GlucoseConcentration", GlucoseConcentration #Necrotic Cells if cell.type == self.NECROTIC: #sNecrotic Cells shrink at a constant rate numberOfNecroticCells = numberOfNecroticCells + 1 cell.targetVolume -= 0.1 self.numberOfTumorCellList.append(numberOfTumorCells) self.numberOfVascularCellList.append(numberOfVascularCells) self.numberOfNeovascularCellList.append(numberOfNeovascularCells) self.numberOfNecroticCellList.append(numberOfNecroticCells) self.pW.addDataPoint("Tumor Cells", mcs, numberOfTumorCells) self.pW.addDataPoint("Vascular Cells", mcs, numberOfVascularCells) self.pW.addDataPoint("Neovascular Cells", mcs, numberOfNeovascularCells) self.pW.addDataPoint("Necrotic Cells", mcs, numberOfNecroticCells)
from PySteppables import *
def start(self): #initial condition for diffusion field field = CompuCell.getConcentrationField(self.simulator, "FGF") field[26:28, 26:28, 0:5] = 2000.0
def start(self): # initial condition for diffusion field field = CompuCell.getConcentrationField(self.simulator, "FGF") field[26:28, 26:28, 0:5] = 2000.0
def step(self,mcs): fieldNeoVasc=CompuCell.getConcentrationField(self.simulator,self.fieldNameExternalVEGF) fieldNeoVascSol=CompuCell.getConcentrationField(self.simulator,self.fieldNameSolubleVEGF) fieldAntiVasc=CompuCell.getConcentrationField(self.simulator,self.fieldNameCXCL10) fieldProVasc=CompuCell.getConcentrationField(self.simulator,self.fieldNameCCL2) ECapoptosisratevariable=20000 ICapoptosisratevariable=100000 #PBMC cytotox MCapoptosisratevariable=100000 #SMC cytotox totalNum = 0 print "Start Volume Steppable" for cell in self.cellList: totalNum+=1 vasculo_attributes=CompuCell.getPyAttrib(cell) if cell.type==1: Growing = 0 Arrested = 0 Quiescent = 0 Apoptotic = 0 totalArea = 0 pt=CompuCell.Point3D() pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) VEGFextconcentration=fieldNeoVasc.get(pt) VEGFsolconcentration=fieldNeoVascSol.get(pt) CXCL10concentration=fieldAntiVasc.get(pt) CCL2concentration=fieldProVasc.get(pt) VEGFconcentration=VEGFextconcentration+VEGFsolconcentration cellNeighborList=CellNeighborListAuto(self.nTrackerPlugin,cell) for neighborSurfaceData in cellNeighborList: #Check to ensure cell neighbor is not medium or other cell types if neighborSurfaceData.neighborAddress: if neighborSurfaceData.neighborAddress.type == 1 or neighborSurfaceData.neighborAddress.type == 4 or neighborSurfaceData.neighborAddress.type == 3: #sum up common surface area of cell with its neighbors totalArea+=neighborSurfaceData.commonSurfaceArea print 'total shared area:',totalArea print "Heparin bound VEGF concentration:",VEGFextconcentration print "Soluble VEGF concentration:",VEGFsolconcentration print "Total VEGF concentration:",VEGFconcentration print "CXCL10 concentration:",CXCL10concentration print "CCL2 concentration:",CCL2concentration if randint(1,ECapoptosisratevariable)==1: cell.type=6 Apoptotic = 1 if totalArea<26 and VEGFconcentration>0.4: #total area shared with other cells, VEGF threshold if CXCL10concentration>0.3: if CXCL10concentration>0.6: if randint(1,ECapoptosisratevariable/100)==1: cell.type=6 Apoptotic = 1 else: cell.targetVolume-=0.001 cell.targetSurface=4*sqrt(cell.targetVolume) #print 'Growth arrested by CXCL10' Arrested = 1 else: if VEGFconcentration>1: cell.type=4 else: cell.targetVolume+=0.8 cell.targetSurface=4*sqrt(cell.targetVolume) #print 'Growth due to VEGF' Growing = 1 else: if totalArea>45: if randint(1,ECapoptosisratevariable/10)==1: cell.type=6 Apoptotic = 1 else: #print 'Cell quiescent' Quiescent = 1 if mcs%50==0: namelist=[] namelist.append(str(mcs)) ###Current MCS namelist.append(str(cell.id)) namelist.append(str(cell.type)) namelist.append(str(cell.volume)) namelist.append(str(cell.surface)) namelist.append(str(cell.xCM/(cell.volume*lmfLength*xScale))) namelist.append(str(cell.yCM/(cell.volume*lmfLength*yScale))) namelist.append(str(VEGFextconcentration)) namelist.append(str(VEGFsolconcentration)) namelist.append(str(VEGFconcentration)) namelist.append(str(CXCL10concentration)) namelist.append(str(CCL2concentration)) namelist.append(str(Growing)) namelist.append(str(Arrested)) namelist.append(str(Quiescent)) namelist.append(str(Apoptotic)) namelist.append(str(totalNum)) totaldatafilename=open(self.tempvar, "a") totaldatafilename.write('\t'.join(namelist)) totaldatafilename.write('\n') totaldatafilename.close() if cell.type==2: randommultiplier=uniform(0.8,1.2) #if mcs>2000: # and mcs<12000: ## add delays/adjustments in proliferation cell.targetVolume+=(0.01*randommultiplier) #Inflammatory Cell Proliferation cell.targetSurface=4*sqrt(cell.targetVolume) if randint(1,ICapoptosisratevariable)==1: cell.type=6 if cell.type==3: randommultiplier=uniform(0.8,1.2) #if mcs>2000: ## delay in mural proliferation cell.targetVolume+=(0.01*randommultiplier) ##Mural Cell Proliferation cell.targetSurface=4*sqrt(cell.targetVolume) totalECArea = 0 pt=CompuCell.Point3D() pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) cellNeighborList=CellNeighborListAuto(self.nTrackerPlugin,cell) for neighborSurfaceData in cellNeighborList: #Check to ensure cell neighbor is not medium or other cell types if neighborSurfaceData.neighborAddress: if neighborSurfaceData.neighborAddress.type == 1: #or neighborSurfaceData.neighborAddress.type == 4: #sum up common surface area of cell with its neighbors totalECArea+=neighborSurfaceData.commonSurfaceArea # print 'total EC area:',totalECArea # print "Heparin bound VEGF concentration:",VEGFextconcentration # print "Soluble VEGF concentration:",VEGFsolconcentration # print "Total VEGF concentration:",VEGFconcentration if totalECArea>5: cell.targetVolume+=(0.02*randommultiplier) #Mural Cell Proliferation cell.targetSurface=4*sqrt(cell.targetVolume) # print 'VSMC Growth due to VEGF' if randint(1,MCapoptosisratevariable)==1: cell.type=6 if cell.type==6: print "test",cell.targetVolume if cell.targetVolume>1: cell.targetVolume-=0.5 else: cell.targetVolume=0 cell.targetSurface=4*sqrt(cell.targetVolume) print "test2" #print "emd test" #if mcs>1000: if cell.type==4: totalArea = 0 freeArea = cell.surface pt=CompuCell.Point3D() pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) cellNeighborList=CellNeighborListAuto(self.nTrackerPlugin,cell) for neighborSurfaceData in cellNeighborList: #Check to ensure cell neighbor is not medium or other cell types if neighborSurfaceData.neighborAddress: if neighborSurfaceData.neighborAddress.type == 1 or neighborSurfaceData.neighborAddress.type == 4: #sum up common surface area of cell with its neighbors totalArea+=neighborSurfaceData.commonSurfaceArea freeArea-=totalArea #print 'total free area:',freeArea if freeArea<0.001: cell.type=1