Open gireeshkbogu opened 5 years ago
Thanks for your interest in this repo. Image slices are expected to be 3D: 2 spacial dimensions and 1 for 3 channels. Masks slices are 2D. One image volume is expected to be 4D: an array of 3D image slices. Corresponding mask volume is expected to be 3D: an array of 2D mask slices. At the end of the dataset initialization, mask slices are expanded to 3D volumes with one channel.
# add channel dimension to masks
self.volumes = [(v, m[..., np.newaxis]) for (v, m) in self.volumes]
Variable volumes
is expected to be a list of tuples that contain 4D image volume and 4D mask volume.
The order of dimensions is: [slices, height, width, channels].
For example, an image volume with 10 slices and slices of size 200x300 has shape (10, 200, 300, 3) and corresponding mask volume has shape (10, 200, 300, 1).
I hope it helps.
Thank you for the quick response and detailed explanation. I converted .nii.gz files to tiff by thinking that all the input to your code is 2D. Do you know how can I convert .nii.gz files into .tff (3D images and 2D masks)?
The model is 2D with 3-channel input but on a higher level it segments volumes.
If you have files for only one modality, you can try to copy it to have 3-channel slices or use gray2rgb
function from skimage: https://scikit-image.org/docs/dev/api/skimage.color.html#skimage.color.gray2rgb.
If you have files for three modalities, you have to register them first and then read in the same order and concatenate along the lest dimension/axis.
For masks, you can read them with imread
function from skimage with as_gray=True
: https://scikit-image.org/docs/dev/api/skimage.io.html#skimage.io.imread.
Hi, I am testing your code and ended up with the following error. My test data has 11 patients with around 800 .tifs (400 images, 400 masks) per patient. I found out this error might because either I've given too many index values and my data probably not 2D. But I double-checked this is not the case.
$ train_validate()
reading train images... preprocessing train volumes... cropping train volumes...