Skip to content

Commit

Permalink
compute raw matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Jan 23, 2024
1 parent 8144801 commit 65c8f9b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/napatrackmater/Trackvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2137,19 +2137,21 @@ def convert_tracks_to_simple_arrays(


def compute_raw_matrix(track_arrays, t_delta):

track_duration = track_arrays.shape[0]
t_delta = int(t_delta)
if track_duration < t_delta:
#zero pad
pad_rows = t_delta - track_duration

# Pad with the last row and then zeros

if track_duration < t_delta:
repetitions = t_delta - track_duration
last_row = track_arrays[-1, :]
zero_pad = np.zeros((pad_rows, track_arrays.shape[1]))
track_arrays = np.vstack((track_arrays, np.tile(last_row, (pad_rows, 1)), zero_pad))
repeated_rows = np.tile(last_row, (repetitions, 1))
result_matrix = np.vstack([track_arrays, repeated_rows])
elif track_duration > t_delta:
result_matrix = track_arrays[:t_delta, :]
else:
result_matrix = track_arrays


flattened_array = track_arrays.flatten()
flattened_array = result_matrix.flatten()

return flattened_array

Expand Down

0 comments on commit 65c8f9b

Please sign in to comment.