Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update method generate_cluster_tracks() #290

Merged
merged 6 commits into from
Dec 20, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions napari_clusters_plotter/_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,20 @@ def update_properties_list(widget, exclude_list):

def generate_cluster_tracks(analysed_layer, plot_cluster_name):
features = analysed_layer.features
label_id_list_per_timepoint = [
features["label"].tolist() for i in range(analysed_layer.data.shape[0])
]
prediction_lists_per_timepoint = [
features[plot_cluster_name].tolist()
for i in range(analysed_layer.data.shape[0])
]
label_id_lists_per_timepoint = list()
prediction_lists_per_timepoint = list()

for i in range(analysed_layer.data.shape[0]):
labels_of_timeframe = np.unique(analysed_layer.data[i].flatten())
stefanhahmann marked this conversation as resolved.
Show resolved Hide resolved
filtered_features = features[features["label"].isin(labels_of_timeframe)]
label_id_lists_per_timepoint.append(filtered_features["label"].tolist())
prediction_lists_per_timepoint.append(
filtered_features[plot_cluster_name].tolist()
)

cluster_data = dask_cluster_image_timelapse(
analysed_layer.data,
label_id_list_per_timepoint,
label_id_lists_per_timepoint,
prediction_lists_per_timepoint,
)

Expand Down Expand Up @@ -284,6 +287,9 @@ def generate_cluster_image_(label_image, label_list, predictionlist):
Generates a clusters image from a label image and a list of cluster predictions,
where each label value corresponds to the cluster identity.
It is assumed that len(predictionlist) == max(label_image)

Deprecated, use generate_cluster_image instead

Parameters
----------
label_image: ndarray or dask array
Expand Down Expand Up @@ -314,6 +320,9 @@ def generate_cluster_image(label_image, label_list, predictionlist):
where each label value corresponds to the cluster identity.
It is assumed that len(predictionlist) == max(label_image)

This function is recommended instead of generate_cluster_image_ as it is faster,
because it does not use skimage.util.map_array

Parameters
----------
label_image: ndarray or dask array
Expand All @@ -327,9 +336,7 @@ def generate_cluster_image(label_image, label_list, predictionlist):
"""

predictionlist_new = np.array(predictionlist) + 1
plist = np.zeros(
stefanhahmann marked this conversation as resolved.
Show resolved Hide resolved
int(max([label_image.max(), np.max(label_list)])) + 1, dtype=np.uint32
)
plist = np.zeros(int(np.max(label_image)) + 1, dtype=np.uint32)
plist[label_list] = predictionlist_new

predictionlist_new = plist
Expand Down
Loading