Problem with sct_extract_metric

Hi all, hope you are safe and sound,

We just found a problem with sct_extract_metric.

extop@:/mnt/aran/Processes/Patients/CN_101$ sct_extract_metric -i n4_CN_101_SC.nii.gz -l 5

--
Spinal Cord Toolbox (dev)

Traceback (most recent call last):
  File "/home/extop/sct_dev/scripts/sct_extract_metric.py", line 425, in <module>
    perlevel=perlevel, verbose=verbose, combine_labels=combine_labels)
  File "/home/extop/sct_dev/scripts/sct_extract_metric.py", line 289, in main
    map_cluster in map_clusters].index(True))
ValueError: True is not in list

We are using the last version from GitHub. 4.2.2 updated

thanks for your help!

Hi @Aran

I am not able to reproduce your error using testing data. Could you please share the necessary files for us to try to reproduce your issue on our end? Namely: n4_CN_101_SC.nii.gz and the local label/ folder.

Cheers
Julien

I added some labels of my own, that might be the problem.

I am sharing with you the files
Here

thanks
aran

Hi Aran,

I can reproduce your error.

Indeed, the error is caused by the files you’ve added under label/atlas. As explained in the SCT Course page 95, the function sct_extract_metric uses a Gaussian mixture algorithm, which assumes that each voxel across labels sums to one. If you add labels, you violate this assumption and results will be incorrect. If you would like to add custom labels under label/atlas, you need to follow the mathematical assumption. I clarified it on page 98 of the course (I agree this was not explicit enough).

So for now, you need to remove the files you’ve added, and update the file info_label.txt as it was before.

If you would like to extract values in your custom labels without using Gaussian mixture algorithm, you can do so by simply pointing to the label file with flag -f:

sct_extract_metric -i n4_CNS_101_SC_t1t2_thr0_uthr10.nii.gz -f PAM50_atlas_37.nii.gz 

Best,
Julien