def __init__(self, transforms=None) -> None: if transforms is None: transforms = [] if not isinstance(transforms, (list, tuple)): raise ValueError("Parameters 'transforms' must be a list or tuple") self.transforms = transforms self.set_random_state(seed=get_seed())
def __init__( self, image_files, seg_files=None, labels=None, as_closest_canonical: bool = False, transform: Optional[Callable] = None, seg_transform: Optional[Callable] = None, image_only: bool = True, dtype: Optional[np.dtype] = np.float32, ): """ Initializes the dataset with the image and segmentation filename lists. The transform `transform` is applied to the images and `seg_transform` to the segmentations. Args: image_files (list of str): list of image filenames seg_files (list of str): if in segmentation task, list of segmentation filenames labels (list or array): if in classification task, list of classification labels as_closest_canonical: if True, load the image as closest to canonical orientation transform: transform to apply to image arrays seg_transform: transform to apply to segmentation arrays image_only: if True return only the image volume, other return image volume and header dict dtype (np.dtype, optional): if not None convert the loaded image to this data type """ if seg_files is not None and len(image_files) != len(seg_files): raise ValueError( "Must have same number of image and segmentation files") self.image_files = image_files self.seg_files = seg_files self.labels = labels self.as_closest_canonical = as_closest_canonical self.transform = transform self.seg_transform = seg_transform self.image_only = image_only self.dtype = dtype self.set_random_state(seed=get_seed()) self._seed = 0 # transform synchronization seed