Skip to content
Snippets Groups Projects

Update README.md

Merged encinass1u requested to merge Student into main
1 file
+ 75
0
Compare changes
  • Side-by-side
  • Inline
 
import numpy as np
 
import pickle
 
import random
 
import matplotlib.pyplot as ptl
 
import copy
 
from matplotlib import pyplot as plt
 
import random
 
from scipy import ndimage
 
from bio2mslib.inout.inout import WriteData as WD
 
import os
 
from Gts_selection import L, Lx, Ly
 
from bio2mslib.analysis.models import CellModels as DM
 
from matplotlib.pyplot import figure
 
 
#Declaring saving paths for results
 
ls_images=[]
 
results_path = os.getcwd()+os.sep+"Single_cell"
 
path_simulation_gif =os.getcwd()+os.sep+"Single_cell"
 
path_simulation = results_path+os.sep+"prolif_migr"
 
if os.path.isdir(path_simulation) == False :
 
os.mkdir(path_simulation)
 
 
#Reopening choosen surface
 
with open('Gts_Sample_100.cvs', 'rb') as csv_file:
 
Gts = pickle.load(csv_file)
 
 
# #Visual preentation in image of the matrix
 
# im1 = plt.imshow(Gts, cmap="bone")
 
# plt.show()
 
#Gs is ground seeded, a copy of the choosen surface to seed the cells,
 
Gs = copy.deepcopy(Gts)
 
 
#uni_cell is the seeding of a single cell inside the treated surface.
 
uni_cell = Gs[(86,8)]
 
Gs[(86,8)] = 1
 
 
#Variable deffinition for PDE proliferation & migration model
 
Cd = 1*10**-5 #Cell density
 
NO2 = 10**2 #nutrient concentration
 
Cdmax = 10**7 #maximum cell density
 
Dm = 0.001 #Cell motility coefficient
 
CRgrw = 1 #rate of cell growth
 
CRNO2 =10**-8 #Consumption rate of nutrients
 
DNO2 = 2*10**-5
 
dt = 1 #time step
 
time_lapse = 0.1
 
 
Gscopy = copy.deepcopy(Gs)
 
Laplace = ndimage.laplace(Gs)
 
#Migration
 
iter = 0
 
while iter<= 15:
 
for mi in range(1, len(Lx)-1):
 
for mj in range(1, len(Ly)-1):
 
x = random.randint(-1,1)#horizontal value for the movement of the cell
 
y = random.randint(-1,1)#vertival value for the movement of the cell
 
if Gs[mi,mj]==1 and (x != 0 or y!= 0) and ((mi+x)<len(Lx)) and ((mj+y)< len(Ly)):
 
Gs[mi+x,mj+y]= 1
 
Gs[mi,mj]=0
 
#Proliferation after migration
 
Gs[mi,mj] = Gscopy[mi,mj] + dt*Dm*Laplace[mi,mj]*(1-(Gscopy[mi,mj]/Cdmax))+CRgrw*1*Gscopy[mi,mj]*(1-(Gscopy[mi,mj]/Cdmax))
 
if Gs[mi,mj]>0 and Gs[mi,mj]!=0.7 and Gs[mi,mj]!=0.5 :
 
Gs[mi,mj]=1
 
zoom = True
 
im2 = plt.imshow(Gs, cmap="bone", norm = None)
 
plt.show()
 
name = 'Single_cell_SMAT_sample'+str(iter)+'.png'
 
plt.imsave(os.path.join(path_simulation, name), Gs, cmap="bone")
 
filename = name
 
ls_images.append(filename)
 
iter+=1
 
 
WD().create_gif_from_images(files_path=results_path+os.sep+"prolif_migr",results_path=path_simulation_gif,filename='Cell_behavior_SMAT.gif', time_lapse= time_lapse, deleteOriginFiles=0)
 
 
Loading