def single(self, kspace, fname): kspace = common.to_tensor(kspace) # Apply mask seed = None if not self.use_seed else tuple(map(ord, fname)) masked_kspace, mask = common.apply_mask(kspace, self.mask_func, seed) # Inverse Fourier Transform to get zero filled solution image = common.ifft2(masked_kspace) # Crop input image image = common.complex_center_crop(image, (self.resolution, self.resolution)) # Absolute value image = common.complex_abs(image) # Apply Root-Sum-of-Squares if multicoil data if self.which_challenge == 'multicoil': image = common.root_sum_of_squares(image) # Normalize input image, mean, std = common.normalize_instance(image, eps=1e-11) image = image.clamp(-6, 6) return image, mean, std
def __call__(self, kspace, target, attrs, fname, slice): """ Args: kspace (numpy.array): Input k-space of shape (num_coils, rows, cols, 2) for multi-coil data or (rows, cols, 2) for single coil data. target (numpy.array): Target image attrs (dict): Acquisition related information stored in the HDF5 object. fname (str): File name slice (int): Serial number of the slice. Returns: (tuple): tuple containing: image (torch.Tensor): Zero-filled input image. target (torch.Tensor): Target image converted to a torch Tensor. mean (float): Mean value used for normalization. std (float): Standard deviation value used for normalization. norm (float): L2 norm of the entire volume. """ kspace = common.to_tensor(kspace) # Apply mask seed = None if not self.use_seed else tuple(map(ord, fname)) masked_kspace, mask = common.apply_mask(kspace, self.mask_func, seed) # Inverse Fourier Transform to get zero filled solution image = common.ifft2(masked_kspace) # Crop input image image = common.complex_center_crop(image, (self.resolution, self.resolution)) # Absolute value image = common.complex_abs(image) # Apply Root-Sum-of-Squares if multicoil data if self.which_challenge == 'multicoil': image = common.root_sum_of_squares(image) # Normalize input image, mean, std = common.normalize_instance(image, eps=1e-11) image = image.clamp(-6, 6) target = common.to_tensor(target) # Normalize target target = common.normalize(target, mean, std, eps=1e-11) target = target.clamp(-6, 6) # Apply random crop if self.crop: image, target = common.random_crop(image, target, self.crop_size) return image, target, mean, std, attrs['norm'].astype(np.float32)
def to_img(kspace, target, which_challenge, mask_func, resolution): kspace = common.to_tensor(kspace) seed = tuple(map(ord, '233')) masked_kspace = kspace if mask_func is not None: masked_kspace, mask = common.apply_mask(kspace, mask_func, seed) # Inverse Fourier Transform to get zero filled solution image = common.ifft2(masked_kspace) # Crop input image image = common.complex_center_crop(image, (resolution, resolution)) # Absolute value image = common.complex_abs(image) # Apply Root-Sum-of-Squares if multicoil data if which_challenge == 'multicoil': image = common.root_sum_of_squares(image) image, mean, std = common.normalize_instance(image, eps=1e-11) image = image.clamp(-6, 6) target = common.to_tensor(target) image, target = common.random_crop(image, target, 196) # Normalize target target = common.normalize(target, mean, std, eps=1e-11) target = target.clamp(-6, 6) return image.numpy(), target.numpy()
def __call__(self, kspace, target, attrs, fname, slice): """ Args: kspace (numpy.Array): k-space measurements target (numpy.Array): Target image attrs (dict): Acquisition related information stored in the HDF5 object fname (pathlib.Path): Path to the input file slice (int): Serial number of the slice Returns: (tuple): tuple containing: image (torch.Tensor): Normalized zero-filled input image mean (float): Mean of the zero-filled image std (float): Standard deviation of the zero-filled image fname (pathlib.Path): Path to the input file slice (int): Serial number of the slice """ kspace = common.to_tensor(kspace) if self.mask_func is not None: seed = tuple(map(ord, fname)) masked_kspace, _ = common.apply_mask(kspace, self.mask_func, seed) else: masked_kspace = kspace # Inverse Fourier Transform to get zero filled solution image = common.ifft2(masked_kspace) # Crop input image image = common.complex_center_crop(image, (self.resolution, self.resolution)) # Absolute value image = common.complex_abs(image) # Apply Root-Sum-of-Squares if multicoil data if self.which_challenge == 'multicoil': image = common.root_sum_of_squares(image) # Normalize input image, mean, std = common.normalize_instance(image) image = image.clamp(-6, 6) return image, mean, std, fname, slice