Error while trying to load 3D nifti data with labels using transforms #2601
Replies: 2 comments 2 replies
-
Edit: As per external suggestion, I have tried the following: im = monai.utils.first(train_transforms(ID_train[0])) - this is getting the first filename and applying the transforms to that. It’s what the dataset will be doing, but just removes extra elements to reduce confusion. This does not raise the error I mentioned in my first comment but then I am not sure how to go from this to making it work for the entire dataset with all the needed elements. |
Beta Was this translation helpful? Give feedback.
-
Hi @LaiaHumbertVidan , Thanks for your interest and experiment with MONAI. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am very new to MONAI so this might be a very basic issue. I am having problems with the very simple task of loading the data and creating a dataset with basic transforms (not even attempting rotations yet). The data are 3D volumes as nifti files (I have the a list with the file paths) and the labels are simple binary outcomes (a list of 0's and 1's).
Below is an extract with the relevant piece of code for the training data (same issue with val and test data).
Many thanks in advance for your help!
train_transforms = Compose(
train_ds = monai.data.ImageDataset(image_files=ID_train, labels=y_train, transform=train_transforms, image_only=True)
im = monai.utils.first(train_ds) # this raises the error below
print(im.shape)
Error:
Traceback (most recent call last):
File "", line 1, in
img = train_ds[0]
File "C:\Users\lh18\AppData\Local\Continuum\anaconda2\envs\lhv\lib\site-packages\monai\data\image_dataset.py", line 111, in getitem
img = apply_transform(self.transform, img)
File "C:\Users\lh18\AppData\Local\Continuum\anaconda2\envs\lhv\lib\site-packages\monai\transforms\transform.py", line 71, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.compose.Compose object at 0x0000023B0B31B358>
Beta Was this translation helpful? Give feedback.
All reactions