Error in seg_tumor_t2 task

Dear SCT team,

I run into an error using the seg_tumor_t2 task of sct_deepseg for lesion segmentation. I’m currently using SCT 5.8 with WSL, and here’s the output:

--
Spinal Cord Toolbox (5.8)

sct_deepseg -i T2w_301.nii.gz -c t2 -task seg_tumor_t2
--

2023-07-07 21:23:43.791 | INFO     | ivadomed.config_manager:_display_differing_keys:153 - Adding the following keys to the configuration file
2023-07-07 21:23:43.792 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     gpu_ids: [0]
2023-07-07 21:23:43.792 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     path_output: sc_model_30mm_32
2023-07-07 21:23:43.793 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     model_name: my_model
2023-07-07 21:23:43.793 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     log_file: log
2023-07-07 21:23:43.793 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     object_detection_params: path_output: sc_model_30mm_32
2023-07-07 21:23:43.794 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     wandb: {'wandb_api_key': '', 'project_name': 'my_project', 'group_name': 'my_group', 'run_name': 'run-1', 'log_grads_every': 100}
2023-07-07 21:23:43.794 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     loader_parameters: path_data: /home/GRAMES.POLYMTL.CA/anlemj/duke/temp/andreanne/tumor_segmentation_masks/results/data
2023-07-07 21:23:43.794 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     loader_parameters: subject_selection: {'n': [], 'metadata': [], 'value': []}
2023-07-07 21:23:43.795 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     loader_parameters: extensions: []
2023-07-07 21:23:43.795 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     loader_parameters: patch_filter_params: {'filter_empty_mask': False, 'filter_empty_input': False}
2023-07-07 21:23:43.795 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     loader_parameters: soft_gt: False
2023-07-07 21:23:43.795 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     loader_parameters: is_input_dropout: False
2023-07-07 21:23:43.795 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     object_detection_params: path_output: sc_model_30mm_32
2023-07-07 21:23:43.795 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     split_dataset: split_method: participant_id
2023-07-07 21:23:43.796 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     split_dataset: data_testing: {'data_type': None, 'data_value': []}
2023-07-07 21:23:43.796 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     split_dataset: balance: None
2023-07-07 21:23:43.796 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     lr_scheduler: name: CosineAnnealingLR
2023-07-07 21:23:43.796 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     balance_samples: applied: False
2023-07-07 21:23:43.797 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     balance_samples: type: gt
2023-07-07 21:23:43.797 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     transfer_learning: reset: True
2023-07-07 21:23:43.797 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     default_model: is_2d: True
2023-07-07 21:23:43.797 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     uncertainty: {'epistemic': False, 'aleatoric': False, 'n_it': 0}
2023-07-07 21:23:43.797 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     evaluation_parameters: object_detection_metrics: True
2023-07-07 21:23:43.798 | INFO     | ivadomed.config_manager:deep_dict_compare:44 -     Modified3DUNet: {'applied': True, 'length_3D': [512, 256, 32], 'stride_3D': [512, 256, 32], 'attention': False, 'n_filters': 8}
2023-07-07 21:23:43.798 | INFO     | ivadomed.config_manager:_display_differing_keys:155 -

2023-07-07 21:23:43.798 | WARNING  | ivadomed.inference:segment_volume:407 - fname_roi has not been specified, then the entire volume is processed.
2023-07-07 21:23:45.471 | INFO     | ivadomed.inference:segment_volume:462 - Loaded 1 sagittal volumes of shape [512, 256, 32].
Traceback (most recent call last):
  File "/home/ryanxu/sct_5.8/spinalcordtoolbox/scripts/sct_deepseg.py", line 253, in <module>
    main(sys.argv[1:])
  File "/home/ryanxu/sct_5.8/spinalcordtoolbox/scripts/sct_deepseg.py", line 215, in main
    nii_lst, target_lst = imed_inference.segment_volume(path_model, input_filenames, options=options)
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/ivadomed/inference.py", line 495, in segment_volume
    for i_batch, batch in enumerate(data_loader):
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 530, in __next__
    data = self._next_data()
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 570, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/ivadomed/loader/mri3d_subvolume_segmentation_dataset.py", line 220, in __getitem__
    stack_input, metadata_input = self.transform(sample=stack_input,
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/ivadomed/transforms.py", line 156, in __call__
    sample, metadata = tr(sample, metadata)
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/ivadomed/transforms.py", line 53, in wrapper
    return wrapped(self, sample, metadata)
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/ivadomed/transforms.py", line 79, in wrapper
    return wrapped(self, sample, metadata)
  File "/home/ryanxu/sct_5.8/python/envs/venv_sct/lib/python3.8/site-packages/ivadomed/transforms.py", line 719, in __call__
    metadata[MetadataKW.ROTATION] = [angle, axes]
TypeError: list indices must be integers or slices, not str

I have tried reinstalling the task but still get the same error.

Hope someone can work this out. I’ll appreciate any help.

Regards,
Ryan

Hi Ryan,

This appears to be a bug in one of SCT’s dependencies, ivadomed. Thankfully, it seems like the bug has already been discovered and fixed (see: ivadomed#1213). So, fixing this issue just a matter of updating the version of ivadomed inside of your SCT environment.

You can do this using the following commands:

source $SCT_DIR/python/bin/activate venv_sct
pip install --upgrade --no-deps ivadomed
conda deactivate

This should upgrade ivadomed from 2.9.7 (buggy version) to 2.9.8 (fixed version).

Please let me know if you have any other questions or concerns!

Kind regards,
Joshua

Thanks for your friendly reminder! After upgrading ivadomed and re-running sct_deepseg, another problem occurs:

Traceback (most recent call last):
  File "/home/ryanxu/sct_5.8/spinalcordtoolbox/scripts/sct_deepseg.py", line 253, in <module>
    main(sys.argv[1:])
  File "/home/ryanxu/sct_5.8/spinalcordtoolbox/scripts/sct_deepseg.py", line 234, in main
    fname_seg = ''.join([sct.image.splitext(input_filenames[0])[0], target + '.nii.gz'])
AttributeError: module 'spinalcordtoolbox' has no attribute 'image'

Does it have something to do with the SCT installation?

Hi @ryan_x,

My apologies for this subsequent error. This is another known bug with v5.8 that has been fixed in our code repository (spinalcordtoolbox#3972), but still exists in the stable release of v5.8.

As a short-term fix, you can sidestep this issue by manually specifying the output name using -o, for example:

sct_deepseg -i T2w_301.nii.gz -o T2w_301_seg-tumor.nii.gz -c t2 -task seg_tumor_t2

As a long term solution, our team can look into backporting the fix for this error to the v5.8 release if need be.

Kind regards,
Joshua

Many thanks, Joshua! This is very helpful.

Just as a follow-up, I’m writing to mention that SCT v6.0 has been released, and that the issues described in this thread have been fixed for the v6.0 release. :slight_smile:

1 Like