Skip to content

Commit 81914bb

Browse files
committed
recoil measurment
1 parent db1c083 commit 81914bb

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

src/napatrackmater/Trackmate.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def __init__(
211211
self.beforeid_key = "before_id"
212212
self.rootid_key = "root_id"
213213
self.msd_key = "msd"
214+
self.recoil_key = "recoil"
214215
self.dividing_key = "dividing_normal"
215216
self.fate_key = "fate"
216217
self.number_dividing_key = "number_dividing"
@@ -1175,7 +1176,7 @@ def get_track_dataframe(self):
11751176
"motion_angle_z", "motion_angle_y", "motion_angle_x", "acceleration",
11761177
"distance_cell_mask", "local_cell_density", "radial_angle_z", "radial_angle_y",
11771178
"radial_angle_x", "cell_axis_z", "cell_axis_y", "cell_axis_x", "track_displacement",
1178-
"total_track_distance", "max_track_distance", "track_duration", "msd"
1179+
"total_track_distance", "max_track_distance", "track_duration", "msd", "recoil"
11791180
]
11801181

11811182
for track_id in self.unique_tracks:
@@ -1262,6 +1263,11 @@ def _tracklet_and_properties(
12621263
msd = 0
12631264
if self.msd_key in all_dict_values.keys():
12641265
msd = float(all_dict_values[self.msd_key])
1266+
1267+
recoil = 0
1268+
if self.recoil_key in all_dict_values.keys():
1269+
recoil = float(all_dict_values[self.recoil_key])
1270+
12651271
acceleration = float(all_dict_values[self.acceleration_key])
12661272
motion_angle_z = float(all_dict_values[self.motion_angle_z_key])
12671273
motion_angle_y = float(all_dict_values[self.motion_angle_y_key])
@@ -1368,6 +1374,7 @@ def _tracklet_and_properties(
13681374
max_track_distance,
13691375
track_duration,
13701376
msd,
1377+
recoil
13711378
]
13721379

13731380
if compute_with_latent_features:
@@ -1427,6 +1434,7 @@ def _tracklet_and_properties(
14271434
max_track_distance,
14281435
track_duration,
14291436
msd,
1437+
recoil
14301438
]
14311439
if compute_with_latent_features:
14321440
current_value_list.extend(latent_shape_features)
@@ -2455,8 +2463,10 @@ def _compute_phenotypes(self):
24552463

24562464
msd = tracklet_properties[:, 26]
24572465

2458-
if tracklet_properties.shape[1] > 26:
2459-
latent_shape_features = tracklet_properties[:, 27:]
2466+
recoil = tracklet_properties[:, 27]
2467+
2468+
if tracklet_properties.shape[1] > 27:
2469+
latent_shape_features = tracklet_properties[:, 28:]
24602470
else:
24612471
latent_shape_features = []
24622472

@@ -2506,6 +2516,7 @@ def _compute_phenotypes(self):
25062516
current_max_track_distance = []
25072517
current_track_duration = []
25082518
current_msd = []
2519+
current_recoil = []
25092520

25102521
for j in range(time.shape[0]):
25112522
if current_unique_id == unique_ids[j]:
@@ -2551,6 +2562,7 @@ def _compute_phenotypes(self):
25512562
current_max_track_distance.append(max_track_distance[j])
25522563
current_track_duration.append(track_duration[j])
25532564
current_msd.append(msd[j])
2565+
current_recoil.append(recoil[j])
25542566

25552567
current_time = np.asarray(current_time, dtype=np.float32)
25562568
current_intensity = np.asarray(current_intensity, dtype=np.float32)
@@ -2621,7 +2633,7 @@ def _compute_phenotypes(self):
26212633
current_track_duration, dtype=np.float32
26222634
)
26232635
current_msd = np.asarray(current_msd, dtype=np.float32)
2624-
2636+
current_recoil = np.asarray(current_recoil, dtype=np.float32)
26252637
if point_sample > 0:
26262638
xf_sample = fftfreq(point_sample, self.tcalibration)
26272639
fftstrip_sample = fft(current_intensity)
@@ -2668,6 +2680,7 @@ def _compute_phenotypes(self):
26682680
current_max_track_distance,
26692681
current_track_duration,
26702682
current_msd,
2683+
current_recoil
26712684
)
26722685
self.unique_fft_properties[track_id].update(
26732686
{
@@ -2983,8 +2996,10 @@ def _msd_update(
29832996
]
29842997

29852998
msd = np.dot(vec_root, vec_root)
2999+
recoil = vec_root
29863000

29873001
self.unique_spot_properties[int(cell_id)].update({self.msd_key: msd})
3002+
self.unique_spot_properties[int(cell_id)].update({self.recoil_key: recoil})
29883003

29893004
def _temporal_plots_trackmate(self):
29903005

@@ -4140,6 +4155,7 @@ def get_feature_dict(unique_tracks_properties):
41404155
],
41414156
"track_duration": np.asarray(unique_tracks_properties, dtype="float16")[:, 25],
41424157
"msd": np.asarray(unique_tracks_properties, dtype="float16")[:, 26],
4158+
"recoil": np.asarray(unique_tracks_properties, dtype="float16")[:, 27],
41434159
}
41444160

41454161
return features

src/napatrackmater/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = version = "5.8.5"
2-
__version_tuple__ = version_tuple = (5, 8, 5)
1+
__version__ = version = "5.8.6"
2+
__version_tuple__ = version_tuple = (5, 8, 6)

0 commit comments

Comments
 (0)