Skip to content
Snippets Groups Projects
Commit 7ceaefe3 authored by Roman Belousov's avatar Roman Belousov
Browse files

`State.cell_*()` functions brought to the same result form

parent e29c0141
No related branches found
No related tags found
No related merge requests found
......@@ -195,17 +195,15 @@ class State:
def cell_positions(self):
"""Return cell positions"""
return np.asarray([
np.mean([
return {
cell_id: np.mean([
self.voxel_coordinates(voxel)
for voxel in cell.voxel_ids
], axis = 0) for cell in self.cells.values()
])
], axis = 0) for cell_id, cell in self.cells.items()
}
def cell_fates(self):
"""Return cell fates"""
return np.asarray(
[cell.type_id for cell in self.cells.values()], dtype=int
)
return {cell_id: cell.type_id for cell_id, cell in self.cells.items()}
def cell_gyration_tensors(self):
"""Return gyration tensors for each cell"""
return {
......
......@@ -7,11 +7,11 @@ from . import ECM
def sorting_score(state):
"""Calculate the sorting score of a state"""
if len(state.cells) == 0: return np.nan
fates = state.cell_fates()
fates = np.asarray(list(state.cell_fates().values()), dtype = int)
epi = fates == 1
pre = fates == 2
pos = state.cell_positions()
pos = np.asarray(list(state.cell_positions().values()))
pos -= np.mean(pos, axis = 0)
rcom = np.linalg.norm(pos, axis = 1)
scores = np.sign([pair[0] - pair[1] for pair in itertools.product(rcom[pre], rcom[epi])])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment