def _extract_patches(self, image, label, patch_size, step): transforms_ = transforms.Compose( [PadToPatchShape(patch_size=patch_size, step=step)]) transformed_image = transforms_(image) transformed_label = transforms_(label) return ABIDEPreprocessingPipeline.get_filtered_patches( transformed_image, transformed_label, patch_size, step)
def _extract_patches(self, image, label, patch_size, step): transforms_ = transforms.Compose( [PadToPatchShape(patch_size=patch_size, step=step)]) transformed_image = transforms_(image) transformed_label = transforms_(label) return MultipleDatasetPipeline.get_filtered_patches( transformed_image, transformed_label, patch_size, step)
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 _extract_patches(self, image, subject, modality, patch_size, step): transforms_ = transforms.Compose( [PadToPatchShape(patch_size=patch_size, step=step)]) transformed_image = transforms_(image) patches = ABIDEPreprocessingPipeline.get_patches( transformed_image, patch_size, step) for i, patch in enumerate(patches): x = transformed_image.x[tuple(patch.slice)] transform_ = transforms.Compose([ ToNifti1Image(), NiftiToDisk( os.path.join( os.path.join(self._output_dir, subject, "mri", "patches", modality), str(i) + ".nii.gz")) ]) transform_(x)
def _extract_patches(self, image, subject, modality, patch_size, step): transforms_ = transforms.Compose( [PadToPatchShape(patch_size=patch_size, step=step)]) transformed_image = transforms_(image) patches = iSEGPipeline.get_patches(transformed_image, patch_size, step) if not os.path.exists(os.path.join(self._output_dir, subject, modality)): os.makedirs(os.path.join(self._output_dir, subject, modality)) for i, patch in enumerate(patches): x = transformed_image[tuple(patch.slice)] transforms_ = transforms.Compose([ ToNifti1Image(), NiftiToDisk( os.path.join(self._output_dir, subject, modality, str(i) + ".nii.gz")) ]) transforms_(x)
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)
def pad_to_shape(image, patch_size, step): transforms_ = transforms.Compose( [PadToPatchShape(patch_size=patch_size, step=step)]) return transforms_(image)