Skip to content
Snippets Groups Projects

Update README.md

Merged encinass1u requested to merge Student into main
1 file
+ 92
0
Compare changes
  • Side-by-side
  • Inline
+ 92
0
 
# -*- coding: utf-8 -*-
 
"""
 
Created on Thu Apr 21 13:34:54 2022
 
 
@author: encinass1u
 
"""
 
 
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
 
 
#Empty matrix size declaration
 
lengthx = 12
 
lengthy = 12
 
G= np.zeros((lengthx,lengthy))
 
ST = copy.deepcopy(G)
 
 
 
#Loop to add the \ surface
 
for i in range (0,12):
 
for j in range (0,12):
 
if (i == j):
 
ST[i,j]=0.5
 
 
#Pickle of the obtained matrix
 
with open('Cell_grid.pkl', 'wb') as csv_file:
 
pickle.dump(ST,csv_file)
 
 
with open('Cell_grid.pkl', 'rb') as csv_file:
 
data_saved = pickle.load(csv_file)
 
 
#print(data_saved)
 
 
# print(type(ST))
 
# #Visual preentation in image of the matrix
 
#im = plt.imshow(data_saved, cmap="copper_r")
 
#plt.colorbar(data_saved) #Error hereeeee
 
#plt.show()
 
#Create a copy of the initial surface to seed the cells
 
Z = copy.deepcopy(ST)
 
 
im2 = plt.imshow(Z, cmap="copper_r")
 
plt.show()
 
 
#incertion of a single cell to track its movement based on the simpspn model
 
uni_cell = Z[(5,4)]
 
Z[(5,4)] = 1
 
iter = 1
 
itermax = 5
 
im2 = plt.imshow(Z, cmap="copper_r")
 
plt.show()
 
while iter<= itermax:
 
for i in range(0,12):
 
for j in range(0,12):
 
# if Zcopy[im,jm]>= 1:
 
# Zcopyinitial = copy.deepcopy(Zcopy[im,jm])
 
 
h = random.randint(-1,1) #horizontal value for the movement of the cell
 
v = random.randint(-1,1) #vertival value for the movement of the cell
 
if Z[i,j]>=uni_cell and (h != 0 or v!= 0):
 
Z[h + i, v + j]+=1
 
Z[i,j]+= uni_cell
 
im2 = plt.imshow(Z, cmap="hot")
 
plt.show()
 
with open('Cell_migration_'+str(iter)+'.pkl', 'wb') as csv_file:
 
pickle.dump(Z,csv_file)
 
iter +=1
 
# elif Z[i,j]>0.71 and (h != 0 or v!= 0):
 
# Z[h + i, v + j]= Z[i,j]+1
 
# Z[i,j]+=1
 
# #Print the image to locate the cell each iteration.
 
# #Saving the file of pickle
 
# im2 = plt.imshow(Z, cmap="copper_r")
 
# plt.show()
 
# with open('Cell_migration_'+str(iter)+'.pkl', 'wb') as csv_file:
 
# pickle.dump(Z,csv_file)
 
# iter +=1
 
# Z[h + i, v + j]= 1
 
# Z[i,j]= 0
 
 
 
 
 
 
Loading