diff --git a/GANDLF/cli/preprocess_and_save.py b/GANDLF/cli/preprocess_and_save.py index 82bc4f574..1da202ae7 100644 --- a/GANDLF/cli/preprocess_and_save.py +++ b/GANDLF/cli/preprocess_and_save.py @@ -105,15 +105,13 @@ def preprocess_and_save( # the "squeeze" is needed because the dataloader automatically # constructs 5D tensor considering the batch_size as first # dimension, but the constructor needs 4D tensor. - subject_process[str(channel)] = torchio.Image( + subject_process[str(channel)] = torchio.ScalarImage( tensor=subject[str(channel)]["data"].squeeze(0), - type=torchio.INTENSITY, path=subject[str(channel)]["path"], ) if parameters["headers"]["labelHeader"] is not None: - subject_process["label"] = torchio.Image( + subject_process["label"] = torchio.LabelMap( tensor=subject["label"]["data"].squeeze(0), - type=torchio.LABEL, path=subject["label"]["path"], ) subject_dict_to_write = torchio.Subject(subject_process) diff --git a/GANDLF/compute/forward_pass.py b/GANDLF/compute/forward_pass.py index 0adcc5fb3..82cebdaa4 100644 --- a/GANDLF/compute/forward_pass.py +++ b/GANDLF/compute/forward_pass.py @@ -129,12 +129,12 @@ def validate_network( subject_dict = {} label_ground_truth = None label_present = False - # this is when we want the dataloader to pick up properties of GaNDLF's DataLoader, such as pre-processing and augmentations, if appropriate + # this is when we want the dataloader to pick up properties of GaNDLF's + # DataLoader, such as pre-processing and augmentations, if appropriate if "label" in subject: if subject["label"] != ["NA"]: - subject_dict["label"] = torchio.Image( + subject_dict["label"] = torchio.LabelMap( path=subject["label"]["path"], - type=torchio.LABEL, tensor=subject["label"]["data"].squeeze(0), affine=subject["label"]["affine"].squeeze(0), ) @@ -149,9 +149,8 @@ def validate_network( ) for key in params["channel_keys"]: - subject_dict[key] = torchio.Image( + subject_dict[key] = torchio.ScalarImage( path=subject[key]["path"], - type=subject[key]["type"], tensor=subject[key]["data"].squeeze(0), affine=subject[key]["affine"].squeeze(0), ) @@ -320,8 +319,7 @@ def validate_network( output_prediction = aggregator.get_output_tensor() output_prediction = output_prediction.unsqueeze(0) if params["save_output"]: - img_for_metadata = torchio.Image( - type=subject["1"]["type"], + img_for_metadata = torchio.ScalarImage( tensor=subject["1"]["data"].squeeze(0), affine=subject["1"]["affine"].squeeze(0), ).as_sitk() diff --git a/GANDLF/data/augmentation/noise_enhanced.py b/GANDLF/data/augmentation/noise_enhanced.py index 2a9a21e17..41fb6ed74 100644 --- a/GANDLF/data/augmentation/noise_enhanced.py +++ b/GANDLF/data/augmentation/noise_enhanced.py @@ -59,8 +59,8 @@ def get_params( mean_range: Tuple[float, float], std_range: Tuple[float, float], ) -> Tuple[float, float]: - mean = self.sample_uniform(*mean_range).item() - std = self.sample_uniform(*std_range).item() + mean = self.sample_uniform(*mean_range) + std = self.sample_uniform(*std_range) seed = self._get_random_seed() return mean, std, seed diff --git a/setup.py b/setup.py index 4e02b6e79..cc49ede40 100644 --- a/setup.py +++ b/setup.py @@ -89,7 +89,7 @@ def run(self): "SimpleITK!=2.2.1", # https://github.com/mlcommons/GaNDLF/issues/536 "torchvision", "tqdm", - "torchio==0.18.75", + "torchio==0.19.3", "pandas>=2.0.0", "scikit-learn>=0.23.2", "scikit-image>=0.19.1",