sct-pipeline / contrast-agnostic-softseg-spinalcord

Contrast-agnostic spinal cord segmentation project with softseg
MIT License
4 stars 3 forks source link

_pred has 4 dimensions, not able to compute CSA #34

Closed sandrinebedard closed 1 year ago

sandrinebedard commented 1 year ago

Description

To compute CSA on the prediction mask, we need to use _pred.nii.gz. However, they are in 4 dimensions:

Example of header of /duke/temp/adrian/contrast-agnostic-seg-models/Group8_01-12-2022/hard_hard_T1w_seed=15/pred_masks/

fslhd sub-amu02_T1w_pred.nii.gz filename sub-amu02_T1w_pred.nii.gz sizeof_hdr 348 data_type UINT16 dim0 4 dim1 29 dim2 68 dim3 168 dim4 1 dim5 1 dim6 1 dim7 1 vox_units mm time_units Unknown datatype 512 nbyper 2 bitpix 16 pixdim0 -1.000000 pixdim1 1.000000 pixdim2 1.000000 pixdim3 1.000000 pixdim4 1.000000 pixdim5 1.000000 pixdim6 1.000000 pixdim7 1.000000 vox_offset 352 cal_max 0.000000 cal_min 0.000000 scl_slope 1.000000 scl_inter 0.000000 phase_dim 0 freq_dim 0 slice_dim 0 slice_name Unknown slice_code 0 slice_start 0 slice_end 0 slice_duration 0.000000 toffset 0.000000 intent Unknown intent_code 0 intent_name intent_p1 0.000000 intent_p2 0.000000 intent_p3 0.000000 qform_name Scanner Anat qform_code 1 qto_xyz:1 -1.000000 -0.000000 -0.000000 13.750153 qto_xyz:2 0.000000 1.000000 -0.000349 -51.344486 qto_xyz:3 -0.000000 0.000349 1.000000 -152.807678 qto_xyz:4 0.000000 0.000000 0.000000 1.000000 qform_xorient Right-to-Left qform_yorient Posterior-to-Anterior qform_zorient Inferior-to-Superior sform_name Scanner Anat sform_code 0 sto_xyz:1 0.000000 0.000000 0.000000 0.000000 sto_xyz:2 0.000000 0.000000 0.000000 0.000000 sto_xyz:3 0.000000 0.000000 0.000000 0.000000 sto_xyz:4 0.000000 0.000000 0.000000 1.000000 sform_xorient Unknown sform_yorient Unknown sform_zorient Unknown file_type NIFTI-1+ file_code 1 descrip aux_file

When running sct_process_segmentation, we get the following error:

(base) sabeda@DESKTOP-JQ8A4UV:/mnt/y/adrian/contrast-agnostic-seg-models/Group8_01-12-2022/hard_hard_T1w_seed=15/pred_masks$ sct_proc
ess_segmentation -i sub-amu02_T1w_pred.nii.gz

--
Spinal Cord Toolbox (git-sb/3733-bring-metrics-to-pam50-add_mscc-2ea5e472d64af93aa6e5cd9a5c6f135f67e8687c)

sct_process_segmentation -i sub-amu02_T1w_pred.nii.gz
--

Traceback (most recent call last):
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_process_segmentation.py", line 533, in <module>
    main(sys.argv[1:])
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_process_segmentation.py", line 417, in main
    remove_temp_files=arguments.r)
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/process_seg.py", line 57, in compute_shape
    X, Y, Z = (data_seg > NEAR_ZERO_THRESHOLD).nonzero()
ValueError: too many values to unpack (expected 3)

Solution

In compute_csa.sh, use _pred and not _pred_painted and remove teh 4th dimension using:

sct_image -i <IMAGE> -split t