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

[pre-commit.ci] pre-commit autoupdate #230

Closed
wants to merge 2 commits into from
Closed
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
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.

8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -21,15 +21,15 @@ repos:
args: [ --branch, main ]
- id: forbid-new-submodules
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 24.4.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.9.0
hooks:
- id: mypy
- repo: https://github.com/PyCQA/isort
rev: 5.8.0
rev: 5.13.2
hooks:
- id: isort
name: Format imports
Expand Down
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
Loading
Loading