Skip to content

Commit 93799f8

Browse files
authored
Fix the pseudotrack creation (#312)
* fix the creation of pseudotracks * ruff
1 parent 8e557ac commit 93799f8

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

examples/DynaCLR/DynaCLR-classical-sampling/create_pseudo_tracks.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99

1010
# %% create training and validation dataset
1111
# TODO: Modify path to the input data
12-
input_data_path = "/training_data.zarr"
13-
# TODO: Modify path to the output data
14-
track_data_path = "/training_data_tracks.zarr"
15-
12+
input_track_path = "/hpc/projects/intracellular_dashboard/organelle_dynamics/2025_07_24_A549_SEC61_TOMM20_G3BP1_ZIKV/1-preprocess/label-free/3-track/2025_07_24_A549_SEC61_TOMM20_G3BP1_ZIKV_cropped.zarr"
13+
output_track_path = "/hpc/projects/organelle_phenotyping/models/SEC61_TOMM20_G3BP1_Sensor/time_interval/dynaclr_gfp_rfp_ph_2D/classical/data/2025_07_24_A549_SEC61_TOMM20_G3BP1_ZIKV_classical_fake_tracks.zarr"
1614
# TODO: Modify the channel name to the one you are using for the segmentation mask
17-
segmentation_channel_name = "Nucl_mask"
15+
segmentation_channel_name = "nuclei_prediction_labels_labels"
1816
# TODO: Modify the z-slice to the one you are using for the segmentation mask
19-
Z_SLICE = 30
17+
Z_SLICE = 0
2018
# %%
2119
"""
2220
Add csvs with fake tracking to tracking data.
@@ -67,38 +65,33 @@ def save_track_df(track_df, well_id, pos_name, out_path):
6765
def main():
6866
# Load the input segmentation data
6967
zarr_input = open_ome_zarr(
70-
input_data_path,
71-
layout="hcs",
72-
mode="r+",
68+
input_track_path,
69+
mode="r",
7370
)
7471
chan_names = zarr_input.channel_names
75-
assert (
76-
segmentation_channel_name in chan_names
77-
), "Channel name not found in the input data"
72+
assert segmentation_channel_name in chan_names, (
73+
"Channel name not found in the input data"
74+
)
7875

7976
# Create the empty store for the tracking data
8077
position_names = []
8178
for ds, position in zarr_input.positions():
8279
position_names.append(tuple(ds.split("/")))
8380

8481
create_empty_plate(
85-
store_path=track_data_path,
82+
store_path=output_track_path,
8683
position_keys=position_names,
87-
channel_names=segmentation_channel_name,
84+
channel_names=[segmentation_channel_name],
8885
shape=(1, 1, 1, *position.data.shape[3:]),
8986
chunks=position.data.chunks,
9087
scale=position.scale,
9188
)
92-
89+
#
9390
# Populate the tracking data
94-
with open_ome_zarr(track_data_path, layout="hcs", mode="r+") as track_store:
91+
with open_ome_zarr(output_track_path, layout="hcs", mode="r+") as track_store:
9592
# Create progress bar for wells and positions
9693
for well_id, well_data in tqdm(zarr_input.wells(), desc="Processing wells"):
97-
for pos_name, pos_data in tqdm(
98-
well_data.positions(),
99-
desc=f"Processing positions in {well_id}",
100-
leave=False,
101-
):
94+
for pos_name, pos_data in well_data.positions():
10295
data = pos_data.data
10396
T, C, Z, Y, X = data.shape
10497
track_df_all = pd.DataFrame()
@@ -110,7 +103,7 @@ def main():
110103
track_pos["0"][0, 0, 0] = seg_mask
111104
track_df = create_track_df(seg_mask, time)
112105
track_df_all = pd.concat([track_df_all, track_df])
113-
save_track_df(track_df_all, well_id, pos_name, track_data_path)
106+
save_track_df(track_df_all, well_id, pos_name, output_track_path)
114107
zarr_input.close()
115108

116109

0 commit comments

Comments
 (0)