Skip to content

Commit

Permalink
fix recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Apr 29, 2024
1 parent 579f85d commit aeabf7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
32 changes: 19 additions & 13 deletions src/napatrackmater/Trackmate.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(
mask: np.ndarray = None,
fourier=True,
autoencoder_model=None,
enhance_trackmate_xml:bool=True,
enhance_trackmate_xml: bool = True,
num_points=2048,
batch_size=1,
compute_with_autoencoder=False,
Expand All @@ -67,7 +67,7 @@ def __init__(
self.oneat_csv_file = oneat_csv_file
self.oneat_threshold_cutoff = oneat_threshold_cutoff
self.latent_features = latent_features

if image is not None:
self.image = image.astype(np.uint8)
else:
Expand All @@ -81,7 +81,9 @@ def __init__(
self.autoencoder_model = autoencoder_model

if self.autoencoder_model is not None:
self.pretrainer = Trainer(accelerator=self.accelerator, devices=self.devices)
self.pretrainer = Trainer(
accelerator=self.accelerator, devices=self.devices
)
else:
self.pretrainer = None
self.enhance_trackmate_xml = enhance_trackmate_xml
Expand Down Expand Up @@ -501,7 +503,11 @@ def _create_generations(self, all_source_ids: list):

if len(list(self.oneat_dividing_tracks.keys())) > 1:
for cell_id in list(self.oneat_dividing_tracks.keys()):
if cell_id in all_source_ids and cell_id not in root_splits and cell_id not in root_leaf:
if (
cell_id in all_source_ids
and cell_id not in root_splits
and cell_id not in root_leaf
):
root_splits.append(cell_id)

return root_root, root_splits, root_leaf
Expand Down Expand Up @@ -596,7 +602,6 @@ def _iterate_dividing_recursive(
tracklet_count = self._unique_tracklet_count(
tracklet_count_taken, tracklet_count
)
print(next_gen_count, tracklet_count, len(target_cells), sorted_root_splits)
tracklet_count_taken.append(tracklet_count)
self._iterate_dividing_recursive(
root_leaf,
Expand Down Expand Up @@ -676,9 +681,9 @@ def _iterate_dividing(self, root_root, root_leaf, root_splits):
def _unique_tracklet_count(self, tracklet_count_taken, tracklet_count):

while tracklet_count in tracklet_count_taken:
tracklet_count += 1
tracklet_count += 1
if tracklet_count not in tracklet_count_taken:
break
break
return tracklet_count

def _iterate_split_down(self, root_root, root_leaf, root_splits):
Expand Down Expand Up @@ -1710,7 +1715,9 @@ def _get_xml_data(self):
self.channel_xml_name = new_name + ".xml"
self.channel_xml_path = os.path.dirname(self.xml_path)
self._create_channel_tree()
if (self.autoencoder_model is not None or self.enhance_trackmate_xml )and self.seg_image is not None:
if (
self.autoencoder_model is not None or self.enhance_trackmate_xml
) and self.seg_image is not None:
self.master_xml_content = self.xml_content
self.master_xml_tree = et.parse(self.xml_path)
self.master_xml_root = self.master_xml_tree.getroot()
Expand Down Expand Up @@ -1833,7 +1840,9 @@ def _get_xml_data(self):
and self.edges_csv_path is not None
):
self._get_attributes()
if (self.autoencoder_model or self.enhance_trackmate_xml) and self.seg_image is not None:
if (
self.autoencoder_model or self.enhance_trackmate_xml
) and self.seg_image is not None:
print("Getting clouds")

self._assign_cluster_class()
Expand Down Expand Up @@ -2398,7 +2407,6 @@ def _compute_phenotypes(self):
current_motion_angle_x,
current_acceleration,
current_distance_cell_mask,

current_radial_angle_z,
current_radial_angle_y,
current_radial_angle_x,
Expand Down Expand Up @@ -3108,8 +3116,6 @@ def get_largest_size(timed_cell_size):
return largest_size




def compute_cell_size(seg_image):
ndim = len(seg_image.shape)
timed_cell_size = {}
Expand All @@ -3131,7 +3137,7 @@ def compute_cell_size(seg_image):
timed_cell_size[str(i)] = float(largest_size.feret_diameter_max)
except ValueError as e:
print(f"Skipping at index {i}: {e}")

continue

return timed_cell_size
Expand Down
4 changes: 2 additions & 2 deletions src/napatrackmater/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = version = "5.1.5"
__version_tuple__ = version_tuple = (5, 1, 5)
__version__ = version = "5.1.6"
__version_tuple__ = version_tuple = (5, 1, 6)

0 comments on commit aeabf7c

Please sign in to comment.