def setUp(self) -> None: paths = extract_file_paths(self.PATH) self._dataset = MRBrainSSegmentationFactory.create( natural_sort(paths), None, modalities=Modality.T1, dataset_id=0) self._reconstructor = ImageReconstructor([256, 256, 192], [1, 32, 32, 32], [1, 8, 8, 8]) transforms = Compose( [ToNumpyArray(), PadToPatchShape([1, 32, 32, 32], [1, 8, 8, 8])]) self._full_image = transforms(self.FULL_IMAGE_PATH)
def setUp(self) -> None: transforms = Compose( [ToNumpyArray(), PadToPatchShape((1, 32, 32, 32), (1, 8, 8, 8))]) self._image = transforms(self.FULL_IMAGE_PATH) self._target = transforms(self.TARGET_PATH) patches = iSEGSliceDatasetFactory.get_patches([self._image], [self._target], (1, 32, 32, 32), (1, 16, 16, 16)) self._dataset = iSEGSliceDatasetFactory.create( [self._image], [self._target], patches, Modality.T1, 0, transforms=[ToNDTensor()]) self._reconstructor = ImageReconstructor([256, 192, 160], [1, 32, 32, 32], [1, 16, 16, 16], models=None, test_image=self._image)
step=dataset_configs["ABIDE"].step, test_patch_size=dataset_configs["ABIDE"].test_patch_size, test_step=dataset_configs["ABIDE"].test_step, data_augmentation_config=data_augmentation_config) train_datasets.append(ABIDE_train) valid_datasets.append(ABIDE_valid) test_datasets.append(ABIDE_test) reconstruction_datasets.append(ABIDE_reconstruction) if len(list(dataset_configs.keys())) == 2: normalized_reconstructor = ImageReconstructor( [ iSEG_reconstruction._source_images[0], MRBrainS_reconstruction._source_images[0] ], patch_size=dataset_configs["iSEG"].test_patch_size, reconstructed_image_size=(1, 256, 256, 192), step=dataset_configs["iSEG"].test_step, models=[model_trainers[GENERATOR]], normalize=True, batch_size=5) segmentation_reconstructor = ImageReconstructor( [ iSEG_reconstruction._source_images[0], MRBrainS_reconstruction._source_images[0] ], patch_size=dataset_configs["iSEG"].test_patch_size, reconstructed_image_size=(1, 256, 256, 192), step=dataset_configs["iSEG"].test_step, models=[model_trainers[GENERATOR], model_trainers[SEGMENTER]], normalize_and_segment=True,
max_subjects=dataset_configs["iSEG"].max_subjects, max_num_patches=dataset_configs["iSEG"].max_num_patches, augmentation_strategy=iSEG_augmentation_strategy, patch_size=dataset_configs["iSEG"].patch_size, step=dataset_configs["iSEG"].step, augmented_path=dataset_configs["iSEG"].path_augmented, test_patch_size=dataset_configs["iSEG"].test_patch_size, test_step=dataset_configs["iSEG"].test_step) train_datasets.append(iSEG_train) valid_datasets.append(iSEG_valid) test_datasets.append(iSEG_test) reconstruction_datasets.append(iSEG_reconstruction) normalized_reconstructors.append(ImageReconstructor(dataset_configs["iSEG"].reconstruction_size, dataset_configs['iSEG'].test_patch_size, dataset_configs["iSEG"].test_step, [model_trainers[GENERATOR]], normalize=True, test_image=iSEG_reconstruction._augmented_images[ 0] if iSEG_reconstruction._augmented_images is not None else iSEG_reconstruction._source_images[0])) segmentation_reconstructors.append( ImageReconstructor(dataset_configs["iSEG"].reconstruction_size, dataset_configs['iSEG'].test_patch_size, dataset_configs["iSEG"].test_step, [model_trainers[GENERATOR], model_trainers[SEGMENTER]], normalize_and_segment=True, test_image=iSEG_reconstruction._augmented_images[ 0] if iSEG_reconstruction._augmented_images is not None else iSEG_reconstruction._source_images[0])) input_reconstructors.append(ImageReconstructor(dataset_configs["iSEG"].reconstruction_size, dataset_configs['iSEG'].test_patch_size,
patch_size=dataset_configs["iSEG"].patch_size, step=dataset_configs["iSEG"].step, augmented_path=dataset_configs["iSEG"].path_augmented, test_patch_size=dataset_configs["iSEG"].test_patch_size, test_step=dataset_configs["iSEG"].test_step) train_datasets.append(iSEG_train) valid_datasets.append(iSEG_valid) test_datasets.append(iSEG_test) reconstruction_datasets.append(iSEG_reconstruction) segmentation_reconstructors.append( ImageReconstructor(dataset_configs["iSEG"].reconstruction_size, dataset_configs['iSEG'].test_patch_size, dataset_configs["iSEG"].test_step, [model_trainers[0]], segment=True, test_image=iSEG_augmentation_strategy( iSEG_reconstruction._source_images[0]) if iSEG_augmentation_strategy is not None else iSEG_reconstruction._source_images[0])) input_reconstructors.append( ImageReconstructor(dataset_configs["iSEG"].reconstruction_size, dataset_configs['iSEG'].test_patch_size, dataset_configs["iSEG"].test_step, test_image=iSEG_augmentation_strategy( iSEG_reconstruction._source_images[0]) if iSEG_augmentation_strategy is not None else iSEG_reconstruction._source_images[0])) gt_reconstructors.append(