Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 12, 2024
1 parent 07221d7 commit 50bc5ff
Show file tree
Hide file tree
Showing 23 changed files with 198 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/mridc.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mridc/collections/common/parts/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def roll(data: torch.Tensor, shift: List[int], dim: Union[List[int], Sequence[in
if isinstance(dim, ListConfig):
dim = list(dim)

for (s, d) in zip(shift, dim):
for s, d in zip(shift, dim):
data = roll_one_dim(data, s, d)

return data
Expand Down
4 changes: 1 addition & 3 deletions mridc/collections/common/parts/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,9 +1977,7 @@ def __repr__(self) -> str:
def __str__(self) -> str:
return self.__repr__()

def __process_kspace__(
self, kspace: np.ndarray, mask: Union[np.ndarray, None], attrs: Dict, fname: str
) -> Tuple[
def __process_kspace__(self, kspace: np.ndarray, mask: Union[np.ndarray, None], attrs: Dict, fname: str) -> Tuple[
torch.Tensor,
Union[List[torch.Tensor], torch.Tensor],
Union[List[torch.Tensor], torch.Tensor],
Expand Down
40 changes: 22 additions & 18 deletions mridc/collections/multitask/rs/nn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,28 +239,32 @@ def process_reconstruction_loss( # noqa: W0221
{
"min": attrs["prediction_min"] if "prediction_min" in attrs else attrs[f"prediction_min_{r}"],
"max": attrs["prediction_max"] if "prediction_max" in attrs else attrs[f"prediction_max_{r}"],
"mean": attrs["prediction_mean"]
if "prediction_mean" in attrs
else attrs[f"prediction_mean_{r}"],
"mean": (
attrs["prediction_mean"] if "prediction_mean" in attrs else attrs[f"prediction_mean_{r}"]
),
"std": attrs["prediction_std"] if "prediction_std" in attrs else attrs[f"prediction_std_{r}"],
},
self.normalization_type,
)
prediction = utils.unnormalize(
prediction,
{
"min": attrs["noise_prediction_min"]
if "noise_prediction_min" in attrs
else attrs[f"noise_prediction_min_{r}"],
"max": attrs["noise_prediction_max"]
if "noise_prediction_max" in attrs
else attrs[f"noise_prediction_max_{r}"],
attrs["noise_prediction_mean"]
if "noise_prediction_mean" in attrs
else "mean": attrs[f"noise_prediction_mean_{r}"],
attrs["noise_prediction_std"]
if "noise_prediction_std" in attrs
else "std": attrs[f"noise_prediction_std_{r}"],
"min": (
attrs["noise_prediction_min"]
if "noise_prediction_min" in attrs
else attrs[f"noise_prediction_min_{r}"]
),
"max": (
attrs["noise_prediction_max"]
if "noise_prediction_max" in attrs
else attrs[f"noise_prediction_max_{r}"]
),
attrs["noise_prediction_mean"] if "noise_prediction_mean" in attrs else "mean": attrs[
f"noise_prediction_mean_{r}"
],
attrs["noise_prediction_std"] if "noise_prediction_std" in attrs else "std": attrs[
f"noise_prediction_std_{r}"
],
},
self.normalization_type,
)
Expand All @@ -280,9 +284,9 @@ def process_reconstruction_loss( # noqa: W0221
{
"min": attrs["prediction_min"] if "prediction_min" in attrs else attrs[f"prediction_min_{r}"],
"max": attrs["prediction_max"] if "prediction_max" in attrs else attrs[f"prediction_max_{r}"],
"mean": attrs["prediction_mean"]
if "prediction_mean" in attrs
else attrs[f"prediction_mean_{r}"],
"mean": (
attrs["prediction_mean"] if "prediction_mean" in attrs else attrs[f"prediction_mean_{r}"]
),
"std": attrs["prediction_std"] if "prediction_std" in attrs else attrs[f"prediction_std_{r}"],
},
self.normalization_type,
Expand Down
40 changes: 22 additions & 18 deletions mridc/collections/multitask/rs/nn/mtlrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,28 +231,32 @@ def process_reconstruction_loss( # noqa: W0221
{
"min": attrs["prediction_min"] if "prediction_min" in attrs else attrs[f"prediction_min_{r}"],
"max": attrs["prediction_max"] if "prediction_max" in attrs else attrs[f"prediction_max_{r}"],
"mean": attrs["prediction_mean"]
if "prediction_mean" in attrs
else attrs[f"prediction_mean_{r}"],
"mean": (
attrs["prediction_mean"] if "prediction_mean" in attrs else attrs[f"prediction_mean_{r}"]
),
"std": attrs["prediction_std"] if "prediction_std" in attrs else attrs[f"prediction_std_{r}"],
},
self.normalization_type,
)
prediction = utils.unnormalize(
prediction,
{
"min": attrs["noise_prediction_min"]
if "noise_prediction_min" in attrs
else attrs[f"noise_prediction_min_{r}"],
"max": attrs["noise_prediction_max"]
if "noise_prediction_max" in attrs
else attrs[f"noise_prediction_max_{r}"],
attrs["noise_prediction_mean"]
if "noise_prediction_mean" in attrs
else "mean": attrs[f"noise_prediction_mean_{r}"],
attrs["noise_prediction_std"]
if "noise_prediction_std" in attrs
else "std": attrs[f"noise_prediction_std_{r}"],
"min": (
attrs["noise_prediction_min"]
if "noise_prediction_min" in attrs
else attrs[f"noise_prediction_min_{r}"]
),
"max": (
attrs["noise_prediction_max"]
if "noise_prediction_max" in attrs
else attrs[f"noise_prediction_max_{r}"]
),
attrs["noise_prediction_mean"] if "noise_prediction_mean" in attrs else "mean": attrs[
f"noise_prediction_mean_{r}"
],
attrs["noise_prediction_std"] if "noise_prediction_std" in attrs else "std": attrs[
f"noise_prediction_std_{r}"
],
},
self.normalization_type,
)
Expand All @@ -272,9 +276,9 @@ def process_reconstruction_loss( # noqa: W0221
{
"min": attrs["prediction_min"] if "prediction_min" in attrs else attrs[f"prediction_min_{r}"],
"max": attrs["prediction_max"] if "prediction_max" in attrs else attrs[f"prediction_max_{r}"],
"mean": attrs["prediction_mean"]
if "prediction_mean" in attrs
else attrs[f"prediction_mean_{r}"],
"mean": (
attrs["prediction_mean"] if "prediction_mean" in attrs else attrs[f"prediction_mean_{r}"]
),
"std": attrs["prediction_std"] if "prediction_std" in attrs else attrs[f"prediction_std_{r}"],
},
self.normalization_type,
Expand Down
4 changes: 1 addition & 3 deletions mridc/collections/multitask/rs/parts/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ def __repr__(self) -> str:
def __str__(self) -> str:
return self.__repr__()

def __process_kspace__(
self, kspace: np.ndarray, mask: Union[np.ndarray, None], attrs: Dict, fname: str
) -> Tuple[
def __process_kspace__(self, kspace: np.ndarray, mask: Union[np.ndarray, None], attrs: Dict, fname: str) -> Tuple[
torch.Tensor,
Union[List[torch.Tensor], torch.Tensor],
Union[List[torch.Tensor], torch.Tensor],
Expand Down
38 changes: 29 additions & 9 deletions mridc/collections/quantitative/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,15 @@ def training_step(self, batch: Dict[float, torch.Tensor], batch_idx: int) -> Dic
acc,
) = batch

(R2star_map_init, S0_map_init, B0_map_init, phi_map_init, y, sampling_mask, r,) = self.process_inputs(
(
R2star_map_init,
S0_map_init,
B0_map_init,
phi_map_init,
y,
sampling_mask,
r,
) = self.process_inputs(
R2star_map_init,
S0_map_init,
B0_map_init,
Expand Down Expand Up @@ -527,7 +535,15 @@ def validation_step(self, batch: Dict[float, torch.Tensor], batch_idx: int) -> D
acc,
) = batch

(R2star_map_init, S0_map_init, B0_map_init, phi_map_init, y, sampling_mask, r,) = self.process_inputs(
(
R2star_map_init,
S0_map_init,
B0_map_init,
phi_map_init,
y,
sampling_mask,
r,
) = self.process_inputs(
R2star_map_init,
S0_map_init,
B0_map_init,
Expand Down Expand Up @@ -673,12 +689,8 @@ def validation_step(self, batch: Dict[float, torch.Tensor], batch_idx: int) -> D
torch.abs(target[:, echo_time, :, :] - recon_pred[:, echo_time, :, :]), # type: ignore
)

target_qmaps = torch.cat(
[R2star_map_target, S0_map_target, B0_map_target, phi_map_target], dim=-1
)
output_qmaps = torch.cat(
[R2star_map_output, S0_map_output, B0_map_output, phi_map_output], dim=-1
)
target_qmaps = torch.cat([R2star_map_target, S0_map_target, B0_map_target, phi_map_target], dim=-1)
output_qmaps = torch.cat([R2star_map_output, S0_map_output, B0_map_output, phi_map_output], dim=-1)
error_qmaps = torch.abs(target_qmaps - output_qmaps)

self.log_image(f"{key}/qmaps/target", target_qmaps)
Expand Down Expand Up @@ -888,7 +900,15 @@ def test_step(self, batch: Dict[float, torch.Tensor], batch_idx: int) -> Tuple[s
acc,
) = batch

(R2star_map_init, S0_map_init, B0_map_init, phi_map_init, y, sampling_mask, r,) = self.process_inputs(
(
R2star_map_init,
S0_map_init,
B0_map_init,
phi_map_init,
y,
sampling_mask,
r,
) = self.process_inputs(
R2star_map_init,
S0_map_init,
B0_map_init,
Expand Down
40 changes: 22 additions & 18 deletions mridc/collections/quantitative/nn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,28 +275,32 @@ def process_reconstruction_loss( # noqa: W0221
{
"min": attrs["prediction_min"] if "prediction_min" in attrs else attrs[f"prediction_min_{r}"],
"max": attrs["prediction_max"] if "prediction_max" in attrs else attrs[f"prediction_max_{r}"],
"mean": attrs["prediction_mean"]
if "prediction_mean" in attrs
else attrs[f"prediction_mean_{r}"],
"mean": (
attrs["prediction_mean"] if "prediction_mean" in attrs else attrs[f"prediction_mean_{r}"]
),
"std": attrs["prediction_std"] if "prediction_std" in attrs else attrs[f"prediction_std_{r}"],
},
self.normalization_type,
)
prediction = utils.unnormalize(
prediction,
{
"min": attrs["noise_prediction_min"]
if "noise_prediction_min" in attrs
else attrs[f"noise_prediction_min_{r}"],
"max": attrs["noise_prediction_max"]
if "noise_prediction_max" in attrs
else attrs[f"noise_prediction_max_{r}"],
attrs["noise_prediction_mean"]
if "noise_prediction_mean" in attrs
else "mean": attrs[f"noise_prediction_mean_{r}"],
attrs["noise_prediction_std"]
if "noise_prediction_std" in attrs
else "std": attrs[f"noise_prediction_std_{r}"],
"min": (
attrs["noise_prediction_min"]
if "noise_prediction_min" in attrs
else attrs[f"noise_prediction_min_{r}"]
),
"max": (
attrs["noise_prediction_max"]
if "noise_prediction_max" in attrs
else attrs[f"noise_prediction_max_{r}"]
),
attrs["noise_prediction_mean"] if "noise_prediction_mean" in attrs else "mean": attrs[
f"noise_prediction_mean_{r}"
],
attrs["noise_prediction_std"] if "noise_prediction_std" in attrs else "std": attrs[
f"noise_prediction_std_{r}"
],
},
self.normalization_type,
)
Expand All @@ -316,9 +320,9 @@ def process_reconstruction_loss( # noqa: W0221
{
"min": attrs["prediction_min"] if "prediction_min" in attrs else attrs[f"prediction_min_{r}"],
"max": attrs["prediction_max"] if "prediction_max" in attrs else attrs[f"prediction_max_{r}"],
"mean": attrs["prediction_mean"]
if "prediction_mean" in attrs
else attrs[f"prediction_mean_{r}"],
"mean": (
attrs["prediction_mean"] if "prediction_mean" in attrs else attrs[f"prediction_mean_{r}"]
),
"std": attrs["prediction_std"] if "prediction_std" in attrs else attrs[f"prediction_std_{r}"],
},
self.normalization_type,
Expand Down
40 changes: 22 additions & 18 deletions mridc/collections/quantitative/nn/qcirim.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,28 +491,32 @@ def process_reconstruction_loss( # noqa: W0221
{
"min": attrs["prediction_min"] if "prediction_min" in attrs else attrs[f"prediction_min_{r}"],
"max": attrs["prediction_max"] if "prediction_max" in attrs else attrs[f"prediction_max_{r}"],
"mean": attrs["prediction_mean"]
if "prediction_mean" in attrs
else attrs[f"prediction_mean_{r}"],
"mean": (
attrs["prediction_mean"] if "prediction_mean" in attrs else attrs[f"prediction_mean_{r}"]
),
"std": attrs["prediction_std"] if "prediction_std" in attrs else attrs[f"prediction_std_{r}"],
},
self.normalization_type,
)
prediction = utils.unnormalize(
prediction,
{
"min": attrs["noise_prediction_min"]
if "noise_prediction_min" in attrs
else attrs[f"noise_prediction_min_{r}"],
"max": attrs["noise_prediction_max"]
if "noise_prediction_max" in attrs
else attrs[f"noise_prediction_max_{r}"],
attrs["noise_prediction_mean"]
if "noise_prediction_mean" in attrs
else "mean": attrs[f"noise_prediction_mean_{r}"],
attrs["noise_prediction_std"]
if "noise_prediction_std" in attrs
else "std": attrs[f"noise_prediction_std_{r}"],
"min": (
attrs["noise_prediction_min"]
if "noise_prediction_min" in attrs
else attrs[f"noise_prediction_min_{r}"]
),
"max": (
attrs["noise_prediction_max"]
if "noise_prediction_max" in attrs
else attrs[f"noise_prediction_max_{r}"]
),
attrs["noise_prediction_mean"] if "noise_prediction_mean" in attrs else "mean": attrs[
f"noise_prediction_mean_{r}"
],
attrs["noise_prediction_std"] if "noise_prediction_std" in attrs else "std": attrs[
f"noise_prediction_std_{r}"
],
},
self.normalization_type,
)
Expand All @@ -532,9 +536,9 @@ def process_reconstruction_loss( # noqa: W0221
{
"min": attrs["prediction_min"] if "prediction_min" in attrs else attrs[f"prediction_min_{r}"],
"max": attrs["prediction_max"] if "prediction_max" in attrs else attrs[f"prediction_max_{r}"],
"mean": attrs["prediction_mean"]
if "prediction_mean" in attrs
else attrs[f"prediction_mean_{r}"],
"mean": (
attrs["prediction_mean"] if "prediction_mean" in attrs else attrs[f"prediction_mean_{r}"]
),
"std": attrs["prediction_std"] if "prediction_std" in attrs else attrs[f"prediction_std_{r}"],
},
self.normalization_type,
Expand Down
4 changes: 1 addition & 3 deletions mridc/collections/reconstruction/models/didn/didn.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def __init__(self, in_channels, out_channels, upscale_factor, kernel_size, paddi
padding: Padding size. Default: 0.
"""
super().__init__()
self.conv = nn.Conv2d(
in_channels, out_channels * upscale_factor**2, kernel_size=kernel_size, padding=padding
)
self.conv = nn.Conv2d(in_channels, out_channels * upscale_factor**2, kernel_size=kernel_size, padding=padding)
self.pixelshuffle = nn.PixelShuffle(upscale_factor)

def forward(self, x):
Expand Down
Loading

0 comments on commit 50bc5ff

Please sign in to comment.