Get data paths and labels
Data is divided into a train, valid and test dataset of different patients, which either have prostate cancer or are healthy. Each patient has three MRI sequences: T2, T1map and ADC. These sequences differ regarding the number of slices and resolution.
At first, the paths to the data are specified:
d = pd.read_csv('../data/radiopaedia_cases.csv')
d['label'] = ['Label A', 'Label A', 'Label A', 'Label B', 'Label B']
Raw pixel data for DICOM must sometimes undergo affine transformation (e.g. to be converted to Houndsfiel Units). PreProcessDicom
is a convenience function which can perform a few frequently needed manipulations with the pixel data.
d
dls = ImageDataLoaders3D.from_df(d,
fn_col = 'series',
label_col = 'label',
item_tfms = ResizeCrop3D(crop_by = (0., 0.1, 0.1),
resize_to = (20, 150, 150),
perc_crop = True),
bs = 2,
)
from fastai.data.core import DataLoaders # for compatibility with show_docs
dls.show_batch_3d()
dls.show_batch_3d(viewer='mosaik', nrow = 15, figsize=(15, 15))
from torch import Tensor # for show_docs
dls.show_hist(with_stats=True)
dls = SegmentationDataLoaders3D.from_df(d,
fn_col='series',
label_col = 'masks',
batch_size = 4)
dls.show_batch_3d(with_mask=True)