コード例 #1
0
    def moveCell(self, cell, shiftVector):
        #we have to make two list of pixels :
        pixelsToDelete=[] #used to hold pixels to delete
        pixelsToMove=[] #used to hold pixels to move
        
        # If we try to reassign pixels in the loop where we iterate over pixel data we will corrupt the container so in the loop below all we will do is to populate the two list mentioned above
        pixelList=self.getCellPixelList(cell)
        pt=CompuCell.Point3D()
        print " Moving ",pixelList.numberOfPixels()," pixels of cell.id=",cell.id," . Shift vector=",shiftVector
        for pixelTrackerData in pixelList:
            pt.x = pixelTrackerData.pixel.x + shiftVector.x
            pt.y = pixelTrackerData.pixel.y + shiftVector.y
            pt.z = pixelTrackerData.pixel.z + shiftVector.z
            # here we are making a copy of the cell 
            print "adding pt=",pt
            pixelsToDelete.append(CompuCell.Point3D(pixelTrackerData.pixel))
            
            if self.checkIfInTheLattice(pt):
                pixelsToMove.append(CompuCell.Point3D(pt))
                # self.cellField.set(pt,cell)
         
        # Now we will move cell
        for pixel in pixelsToMove:
#             self.cellField.set(pixel,cell)
             self.cellField[pixel.x,pixel.y,pixel.z]=cell
             
        # Now we will delete old pixels    
        pixelList=self.getCellPixelList(cell)
        pt=CompuCell.Point3D()
        
        self.mediumCell=CompuCell.getMediumCell()
        print " Deleting ",len(pixelsToDelete)," pixels of cell.id=",cell.id
        for pixel in pixelsToDelete:            
            self.cellField[pixel.x,pixel.y,pixel.z]=self.mediumCell
    def moveCell(self, cell, shiftVector):
        #we have to make two list of pixels :
        pixelsToDelete = []  #used to hold pixels to delete
        pixelsToMove = []  #used to hold pixels to move

        # If we try to reassign pixels in the loop where we iterate over pixel data we will corrupt the container so in the loop below all we will do is to populate the two list mentioned above
        pixelList = self.getCellPixelList(cell)
        pt = CompuCell.Point3D()
        print " Moving ", pixelList.numberOfPixels(
        ), " pixels of cell.id=", cell.id, " . Shift vector=", shiftVector
        for pixelTrackerData in pixelList:
            pt.x = pixelTrackerData.pixel.x + shiftVector.x
            pt.y = pixelTrackerData.pixel.y + shiftVector.y
            pt.z = pixelTrackerData.pixel.z + shiftVector.z
            # here we are making a copy of the cell
            print "adding pt=", pt
            pixelsToDelete.append(CompuCell.Point3D(pixelTrackerData.pixel))

            if self.checkIfInTheLattice(pt):
                pixelsToMove.append(CompuCell.Point3D(pt))
                # self.cellField.set(pt,cell)

        # Now we will move cell
        for pixel in pixelsToMove:
            #             self.cellField.set(pixel,cell)
            self.cellField[pixel.x, pixel.y, pixel.z] = cell

        # Now we will delete old pixels
        pixelList = self.getCellPixelList(cell)
        pt = CompuCell.Point3D()

        self.mediumCell = CompuCell.getMediumCell()
        print " Deleting ", len(pixelsToDelete), " pixels of cell.id=", cell.id
        for pixel in pixelsToDelete:
            self.cellField[pixel.x, pixel.y, pixel.z] = self.mediumCell
コード例 #3
0
    def  deleteCell(self,cell):
#         pixelsToDelete=self.getCopyOfCellPixels(cell,SteppableBasePy.CC3D_FORMAT) # returns list of Point3D
        pixelsToDelete=self.getCopyOfCellPixels(cell,SteppableBasePy.TUPLE_FORMAT) # returns list of tuples
        
        
        self.mediumCell=CompuCell.getMediumCell()    
        for pixel in pixelsToDelete:            
            print "CELL.volume=",cell.volume
            self.cellField[pixel[0],pixel[1],pixel[2]]=self.mediumCell
    def deleteCell(self, cell):
        #         pixelsToDelete=self.getCopyOfCellPixels(cell,SteppableBasePy.CC3D_FORMAT) # returns list of Point3D
        pixelsToDelete = self.getCopyOfCellPixels(
            cell, SteppableBasePy.TUPLE_FORMAT)  # returns list of tuples

        self.mediumCell = CompuCell.getMediumCell()
        for pixel in pixelsToDelete:
            print "CELL.volume=", cell.volume
            self.cellField[pixel[0], pixel[1], pixel[2]] = self.mediumCell
コード例 #5
0
    def cut(self,x0,y0,dx,dy):
        medium=CompuCell.getMediumCell() #get medium
        deleteCells = []
        for xx in range(int(dx)):
            x = int(x0-dx/2 + xx + .5)
            for yy in range(int(dy)):
                y = int(y0-dy/2 + yy + .5)
                for z in range(self.dim.z):
                    cell=self.cellField[x,y,z]
                    if cell:
                        cell.targetVolume-=1      #decrease cell target volume by 1
                        if (-1<cell.targetVolume<0): deleteCells.append(cell)
                    self.cellField[x,y,z]=medium  #replacing cell pixel by medium
        for cell in deleteCells:  #making sure cells are deleted
            self.deleteCell(cell)
#
#
##
コード例 #6
0
    def start(self):
        radi = self.dim.x/2
        # Assign Property for Cell ID = 1
        cells_to_die=[]
        for cell in self.cellListByType(1):
            cell.targetVolume = tVol
            cell.lambdaVolume = 5
        # Basal Membrane Generation
        radi = int(self.dim.x/2)
        pt=CompuCell.Point3D(0,0,0)
        Wall = self.potts.createCellG(pt) # the arguments are (type,pt,xSize,ySize,zSize)  
        Wall.type = 2
        totalNumOfSeg = 15
        segm = []   
        cellsToDelete=[]
        for pty in range(0,self.dim.y):
            for ptx in range(0,self.dim.x):
                for ptz in range(0,self.dim.z):
                    pt.y=pty
                    pt.x=ptx
                    pt.z=ptz        
                    # Generate Tube structure
                    if pty>= radi:
                        if ((ptx-radi)**2+(ptz-radi)**2)<=radi**2 and ((ptx-radi)**2+(ptz-radi)**2)>=(radi-5)**2:
                            overwrittenCell=self.cellField.get(pt)  

                            self.cellField.set(pt,Wall)
                            self.cleanDeadCells()
                            
                            ang = math.atan2(ptx-radi,ptz-radi)*(180./math.pi)+180
                            segN= int(ang/(360/totalNumOfSeg))
                            if segN ==15:
                                segN = 0
                            segm.append([segN,pt])
                        
                        elif ((ptx-radi)**2+(ptz-radi)**2)>radi**2:
                            self.cellField.set(pt,CompuCell.getMediumCell())
                            self.cleanDeadCells()
                    # Generate Semi-Sphere Sturcture ((Bottom of the crypt)
                 
                    elif pty < radi:
                        if ((ptx-radi)**2+(pty-radi)**2+(ptz-radi)**2)<=radi**2 and ((ptx-radi)**2+(pty-radi)**2+(ptz-radi)**2)>=(radi-5)**2:
                            self.cellField.set(pt,Wall)
                            self.cleanDeadCells()
                        elif ((ptx-radi)**2+(pty-radi)**2+(ptz-radi)**2)>radi**2:
                            overwrittenCell=self.cellField.get(pt)
                            if pt.x!=0 and pt.y!=0 and pt.z!=0: # this line is essential because you do not wan to remove wall cell which sits at (0,0,0)
                                self.cellField.set(pt,CompuCell.getMediumCell())
                                self.cleanDeadCells()
        # now we can overwrite (0,0,0) with medium
        pt.x=0
        pt.y=0
        pt.z=0
        self.cellField.set(pt,CompuCell.getMediumCell())
        self.divideCellOrientationVectorBased(Wall,0,0,1)
        for divN in range(0,3):        
            cell_to_divide=[]    
            # iterating over cells of type 2        
            for cell in self.cellListByType(2):
                cell_to_divide.append(cell)
            for cell in cell_to_divide:
                DiviVectorX = (cell.xCOM-radi)
                DiviVectorZ = (cell.zCOM-radi) 
                self.divideCellOrientationVectorBased(cell,-DiviVectorZ,0,DiviVectorX) 
        for divN in range(0,4):
            cell_to_divide=[]    
            # iterating over cells of type 2        
            for cell in self.cellListByType(2):
                cell_to_divide.append(cell)
            for cell in cell_to_divide:
                self.divideCellOrientationVectorBased(cell,0,1,0)   
        # Assign property for Cell type = 2
        for cell in self.cellListByType(2): 
            cell.targetVolume = cell.volume
            cell.lambdaVolume = 10000000
        cells_to_die=[]
        for cell in self.cellList:
            if cell.type == 1:                    
                # Program Cell Death
                # Set up threshold to kill cells when cells go above the threshold
                if cell.yCOM > self.dim.y-10:
                    cells_to_die.append(cell)
                cellNeighborList=self.getCellNeighbors(cell) # generates list of neighbors of cell 'cell'
                wallflag=0
                # Kill cells when the cells not touching BM
                for neighbor in cellNeighborList:
                    # neighborSurfaceData.neighborAddress is a pointer to one of 'cell' neighbors stired in cellNeighborList
                    #IMPORTANT: cell may have Medium (NULL pointer) as a neighbor. therefore before accessing neighbor we first check if it is no Medium
                    if neighbor.neighborAddress: 
                        # Detect the cells touching BM
                        if neighbor.neighborAddress.type == 2:
                            wallflag=1
                if wallflag==0:
                    # Delete the cells without contacting BM
                    cells_to_die.append(cell)
                   
        # Cell Killing program
        for cell in cells_to_die:    
            cell.targetVolume = 0
            self.deleteCell(cell)
            # The next line araises the dead cell register      
            self.cleanDeadCells()

        self.BreakCells()# call new BreakCells() to generate apical and basal cells from Epi cells
コード例 #7
0
   #Cell type-id and type-name:
   self.typeIdTypeNameDict # {0:"Medium", 1:"CELL_TYPE_1", ...}
   self.typeIdTypeNameDict[cell.type] # current cell's type name
   len(self.typeIdTypeNameDict) # number of cell types + medium
   
   #Cell from id:
   cell=self.inventory.attemptFetchingCellById(id)
   
   #Distance between cells:
   D = self.distanceBetweenCells(cell,cell2)       # D = sqrt(dx**2+dy**2+dz**2)
   V = self.distanceVectorBetweenCells(cell,cell2) # [dx,dy,dz]
 #
 Access/Modify Cell Lattice:
   pt=CompuCell.Point3D(x,y,z) # defines a lattice vector
   
   medium=CompuCell.getMediumCell() #get Medium cell
   
   cell=self.cellField.get(pt) # get cell that is on pt [self.cellField.get(pt.x,pt.y,pt.z)]
   cell=self.cellField[x,y,0]
   
   # to create a brand new cell
   newcell=self.potts.createCellG(pt)
   newcell.type=1 # don’t forget to assign a type to the new cell
   cell=self.potts.createCell()
   
   self.cellField.set(pt,cell) # to create an extension of that cell
   self.cellField[x:x+4,y:y+4,0]=cell
 #
 SBML solver:
   #Loading/adding SBML
   self.addSBMLToCellTypes(_modelFile='',_modelName='',_types=[],_stepSize=1.0,_initialConditions={})
コード例 #8
0
 def start(self):
     self.pixelAssigned=False
     self.mediumCell=CompuCell.getMediumCell()   
     self.boundaryArray=self.boundaryMonitorPlugin.getBoundaryArray()
     print 'self.boundaryArray=',self.boundaryArray
     print 'dir(self.boundaryArray)=',dir(self.boundaryArray)