Skip to content
Snippets Groups Projects
Commit d43d5710 authored by pswain's avatar pswain
Browse files

renamed dunder routines in indexing

parent 75686e0c
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,7 @@ def validate_lineage(
"""
if lineage.ndim == 2:
# [trap, mother, daughter] becomes [[trap, mother], [trap, daughter]]
lineage = _assoc_indices_to_3d(lineage)
lineage = assoc_indices_to_3d(lineage)
if how == "mothers":
c_index = 0
elif how == "daughters":
......@@ -123,7 +123,7 @@ def index_isin(x: np.ndarray, y: np.ndarray) -> np.ndarray:
return x_bool
def _assoc_indices_to_3d(ndarray: np.ndarray):
def assoc_indices_to_3d(ndarray: np.ndarray):
"""
Convert the last column to a new row and repeat first column's values.
......@@ -153,6 +153,16 @@ def _assoc_indices_to_3d(ndarray: np.ndarray):
return result
def assoc_indices_to_2d(array: np.ndarray):
"""Convert indices to 2d."""
result = array
if len(array):
result = np.concatenate(
(array[:, 0, :], array[:, 1, 1, np.newaxis]), axis=1
)
return result
###################################################################
......@@ -250,16 +260,6 @@ def validate_association(
return valid_association, valid_indices
def _3d_index_to_2d(array: np.ndarray):
"""Revert _assoc_indices_to_3d."""
result = array
if len(array):
result = np.concatenate(
(array[:, 0, :], array[:, 1, 1, np.newaxis]), axis=1
)
return result
def compare_indices(x: np.ndarray, y: np.ndarray) -> np.ndarray:
"""
Fetch two 2-D indices and return a binary 2-D matrix
......
......@@ -10,8 +10,8 @@ from agora.io.cells import Cells
from agora.io.signal import Signal
from agora.io.writer import Writer
from agora.utils.indexing import (
_3d_index_to_2d,
_assoc_indices_to_3d,
assoc_indices_to_2d,
assoc_indices_to_3d,
)
from agora.utils.merge import merge_lineage
from postprocessor.core.abc import get_parameters, get_process
......@@ -133,19 +133,19 @@ class PostProcessor(ProcessABC):
record = self.signal.get_raw(self.targets["merging_picking"]["merger"])
merges = self.merger.run(record)
# get lineages from cells object attached to picker
lineage = _assoc_indices_to_3d(self.picker.cells.mothers_daughters)
lineage = assoc_indices_to_3d(self.picker.cells.mothers_daughters)
if merges.any():
# update lineages and merges after merging
new_lineage, new_merges = merge_lineage(lineage, merges)
else:
new_lineage = lineage
new_merges = merges
self.lineage = _3d_index_to_2d(new_lineage)
self.lineage = assoc_indices_to_2d(new_lineage)
self.writer.write(
"modifiers/merges", data=[np.array(x) for x in new_merges]
)
self.writer.write(
"modifiers/lineage_merged", _3d_index_to_2d(new_lineage)
"modifiers/lineage_merged", assoc_indices_to_2d(new_lineage)
)
# run picker
picked_indices = self.picker.run(
......
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