问题描述:原因分析:
当一个训练nifti卷没有96(ROIsize)个切片时,就会出现这个错误。
解决方法:
1,设置较小的ROIsize,比如(48,48,48)
2,参考Getting "The size of the proposed random crop ROI is larger than the image size" · Project-MONAI/MONAI · Discussion #6164 (github.com)将transform里面的裁剪操作加上填充,即在切片尺寸小于裁剪尺寸时,自动padding
RandCropByPosNegLabeld(keys=["image", "label"],label_key="label",spatial_size=(96, 96, 96),
pos=1,
neg=1,
num_samples=4,
image_key="image",
image_threshold=0,
allow_smaller=True
),
ResizeWithPadOrCropd(keys=["image", "label"],spatial_size=(96, 96, 96),mode='constant')