Ejemplo n.º 1
0
 def setUp(self):
     super().setUp()
     self.subjects_list = create_dummy_dataset(
         num_images=10,
         size_range=(10, 20),
         directory=self.dir,
         suffix='.nii',
         force=False,
     )
Ejemplo n.º 2
0
 def setUp(self):
     """Set up test fixtures, if any."""
     self.dir = Path(tempfile.gettempdir()) / 'torchio'
     self.subjects_list = create_dummy_dataset(
         num_images=10,
         size_range=(10, 20),
         directory=self.dir,
         suffix='.nii',
         force=False,
     )
Ejemplo n.º 3
0
    # Define training and patches sampling parameters
    num_epochs = 4
    patch_size = 128
    queue_length = 100
    samples_per_volume = 10
    batch_size = 4

    def model(batch, sleep_time=0.1):
        """Dummy function to simulate a forward pass through the network"""
        time.sleep(sleep_time)
        return batch

    # Create a dummy dataset in the temporary directory, for this example
    subjects_paths = create_dummy_dataset(
        num_images=100,
        size_range=(193, 229),
        force=False,
    )

    # Each element of subjects_paths is a dictionary:
    # subject = {
    #     'one_image': dict(path=path_to_one_image, type=torchio.INTENSITY),
    #     'another_image': dict(path=path_to_another_image, type=torchio.INTENSITY),
    #     'a_label': dict(path=path_to_a_label, type=torchio.LABEL),
    # }

    # Define transforms for data normalization and augmentation
    transforms = (
        ZNormalization(),
        RandomNoise(std_range=(0, 0.25)),
        RandomAffine(scales=(0.9, 1.1), degrees=10),