fmusio / TopCoWSubmissions

Repo for the inference code of the TopCoW'23 submissions made by the challenge organizers.
6 stars 1 forks source link

Labels are flipped #2

Open torgil01 opened 1 month ago

torgil01 commented 1 month ago

The left / right vessel labels are flipped in our TOF MRA data. Segmentation and labeling are good, but when we overly the labels on the original images, it is apparent that the labels are flipped.

fmusio commented 1 month ago

Hi and thanks for reporting this issue. I didn't turn of the mirroring for the nnUNet which can lead to the mentioned flipping of the labels. But I actually try to take care of this issue in the inference.py script. Does the flipping happen for all images? And can you try to check what the sum_sides variable outputs for the cases where you have flipped labels?

torgil01 commented 1 month ago

Thanks for the quick reply! First, the code does an excellent job with segmenting the arteries in our data.

Regarding the flipping, my main concern is whether the behavior is consistent. The flipping happens in the few cases we have looked at, but we have run the segmentation on over 1000 TOF MRIs (all with identical image sizes), so it is difficult to tell. However, looking at sum_sides it seems to me that the flipping may vary from case to case. Is there any way to detect whether the labels have been flipped or not without looking at the images?

fmusio commented 1 month ago

In what orientation are your nifti images? If you are working with the nibabel library you can check that using aff2axcodes. The TopCoW data our model was trained on is in LPS+ orientation. And it might be that your problem stems from the fact that your niftis have a different orientation. In that case you would need to reorient the images first before running inference.

If the images are in LPS+ orientation, then the positive x-axis points to the left side of the patient. So, the rightmost point is at x=0 and the leftmost point at x=x_max. This means that the indices of the left side labels (e.g. L-MCA, label 7) must be higher than the indices of the right side labels (e.g. R-MCA, label 5). This is the idea behind the sign test of sum_sides: If sum_sides is negative then the labels are flipped. But again, this only works if the image is in LPS+ orientation.