Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade base torchio version #749

Merged
merged 7 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions GANDLF/cli/preprocess_and_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions GANDLF/compute/forward_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand All @@ -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),
)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions GANDLF/data/augmentation/noise_enhanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading