Skip to content

Persistent IndexError when running CSE3D function #18

@stibossu

Description

@stibossu

Hello,
I am trying to implement the CSE3D function to my image and segmentation masks.
Unfortunately, I am dealing with a persistent IndexError:

`

IndexError Traceback (most recent call last)
Cell In[52], line 2
1 # This returns a dict containing all the per-metric scores plus the overall quality score.
----> 2 seg_eval_results = CSE3D(img_channels=final_image, metric_mask=combined_masks, PCA_model="3Dv1.6")
4 print("Overall quality score:", seg_eval_results["QualityScore"])
5 for metric, value in seg_eval_results.items(): File ~/.conda/envs/harpy_wsl_cellsegmentationevaluator/lib/python3.10/site-packages/CellSegmentationEvaluator/CSE3D.py:150, in CSE3D(img_channels, metric_mask, PCA_model, img4thresh, voxel_size, disksizes, areasizes)
147 cell_type_labels = cell_type(current_mask, img_channels)
148 else:
149 # get uniformity for nucleus and non-nucleus
--> 150 cell_CV, cell_fraction, cell_silhouette = cell_uniformity(
151 current_mask, img_channels, cell_type_labels 152 )
153 avg_cell_CV = np.average(cell_CV) #was cell_CV[0]
154 avg_cell_fraction = np.average(cell_fraction) #was cell_fraction[0]
File ~/.conda/envs/harpy_wsl_cellsegmentationevaluator/lib/python3.10/site-packages/CellSegmentationEvaluator/functions.py:436, in cell_uniformity(mask, channels, label_list)
434 silhouette.append(silhouette_score(feature_matrix_z, labels))
435 for i in range(c):
--> 436 cluster_feature_matrix = feature_matrix[np.where(labels == i)[0], :]
437 cluster_feature_matrix_z = feature_matrix_z[np.where(labels == i)[0], :]
438 CV_current.append(cell_uniformity_CV(cluster_feature_matrix))
IndexError: index 502 is out of bounds for axis 0 with size 502
`

I don't really understand where it is coming from because I have made the mask IDs in my cell, nuclei and cytoplasm masks contiguous and eliminated mask IDs that are not present in all 3 mask layers. So the zeros in my mask layers are background and the 1,...,N indices are my n mask IDs.
I got the feeling that I am overlooking something small, but I hoping on some advice that would help me further apply your tools.
Best regards,
Stijn Bossuyt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions