ldctbench.data.LDCTMayo
LDCTMayo(mode, args)
Bases: Dataset
Dataset class for the LDCT dataset
Parameters:
-
mode(str) –Which subset to use. Must be
train,val, ortest. -
args(Namespace) –Command line argumetns passed to the dataset class.
Attributes:
-
seed(int) –Random seed to use
-
path(str) –Root path to datafolder
-
patchsize(int) –Patchsize to use for training.
-
eval_patchsize(int) –Patchsize to use for validation.
-
data_subset(float) –Subset of the data to use.
-
data_norm(str) –Normalization of the data, must be
meanstdorminmax. -
info(dict) –Dictionary of
info.ymlassociated with the dataset. -
samples(list) –List of all image slices
-
weights(list) –List of weights associated with each slice. Slices of each patient having
n_slicesare weighted with1/n_slices.
Examples:
Create a training dataset
>>> from argparse import Namespace
>>> from ldctbench.data import LDCTMayo
>>> args = Namespace(seed=1332, path='/path/to/dataset/root', data_norm='meanstd', data_subset=1.0, patchsize=128)
>>> train_data = LDCTMayo('train', args)
Create a validation dataset
>>> from argparse import Namespace
>>> from ldctbench.data import LDCTMayo
>>> args = Namespace(seed=1332, path='/path/to/dataset/root', data_norm='meanstd', data_subset=1.0, eval_patchsize=128)
>>> train_data = LDCTMayo('val', args)
__getitem__(idx)
Given an index, get slice, perform random cropping, normalize and return
__len__()
Length of dataset
denormalize(X)
Denormalize samples with precomputed mean/std or min/max
Parameters:
-
X(ndarray) –Array to denormalize
Returns:
-
ndarray–Denormalized array
Raises:
-
ValueError–If normalization method
self.data_normis neihter meanstd nor minmax
reset_seed()
Reset random seeds
to_torch(X)
staticmethod
Convert input image to torch tensor and unsqueeze