-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Bug in deepgrow dataset #4828
Description
Describe the bug
It does't work when replace AsChannelFirstd with EnsureChannelFirstd in deepgrow's dataset.
It mainly due to _save_data_2d only works on the image since EnsureChannelFirstd also makes the label 4-dimensional(with channel 1 at the first).
MONAI/monai/apps/deepgrow/dataset.py
Lines 138 to 148 in f317aeb
| def _save_data_2d(vol_idx, vol_image, vol_label, dataset_dir, relative_path): | |
| data_list = [] | |
| if len(vol_image.shape) == 4: | |
| logging.info( | |
| "4D-Image, pick only first series; Image: {}; Label: {}".format( | |
| vol_image.shape, vol_label.shape if vol_label is not None else None | |
| ) | |
| ) | |
| vol_image = vol_image[0] | |
| vol_image = np.moveaxis(vol_image, -1, 0) |
To Reproduce
python -m unittest test_deepgrow_dataset.py
Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/parameterized/parameterized.py", line 533, in standalone_func
return func(*(a + p.args), **p.kwargs)
File "/workspace/Code/MONAI/tests/test_deepgrow_dataset.py", line 87, in test_create_dataset
deepgrow_datalist = create_dataset(datalist=datalist, output_dir=self.tempdir, **args)
File "/workspace/Code/MONAI/monai/apps/deepgrow/dataset.py", line 105, in create_dataset
data = _save_data_2d(
File "/workspace/Code/MONAI/monai/apps/deepgrow/dataset.py", line 159, in _save_data_2d
label = vol_label[sid, ...] if vol_label is not None else None
IndexError: index 1 is out of bounds for axis 0 with size 1