MRI Reconstruction Losses#
- class atommic.collections.reconstruction.losses.NoiseAwareLoss(*args: Any, **kwargs: Any)[source]#
Bases:
LossComputes the Noise Aware loss between two tensors.
Note
Extends
atommic.core.classes.loss.Loss.Examples
>>> from atommic.collections.reconstruction.losses.na import NoiseAwareLoss >>> import torch >>> loss = NoiseAwareLoss(win_size=7, k1=0.01, k2=0.03) >>> loss(X=torch.rand(1, 1, 256, 256), Y=torch.rand(1, 1, 256, 256)) tensor(0.0872)
- forward(target: torch.Tensor, pred: torch.Tensor, mask: Optional[torch.Tensor] = None, sigma: float = 0.0) torch.Tensor[source]#
Forward pass of
NoiseAwareLoss.- Parameters
target (torch.Tensor) – The target tensor.
pred (torch.Tensor) – The predicted tensor.
mask (torch.Tensor) – The mask tensor. If None, all pixels are considered.
sigma (float) – The noise level.
- class atommic.collections.reconstruction.losses.SSIMLoss(*args: Any, **kwargs: Any)[source]#
Bases:
LossComputes the (1-) SSIM loss between two tensors.
Examples
>>> from atommic.collections.reconstruction.losses.ssim import SSIMLoss >>> import torch >>> loss = SSIMLoss(win_size=7, k1=0.01, k2=0.03) >>> loss(X=torch.rand(1, 1, 256, 256), Y=torch.rand(1, 1, 256, 256), data_range=torch.tensor([1.])) tensor(0.9872)
- __init__(win_size: int = 7, k1: float = 0.01, k2: float = 0.03)[source]#
Inits
SSIMLoss.- Parameters
win_size (int, optional) – Window size for SSIM calculation.
k1 (float, optional) – k1 parameter for SSIM calculation.
k2 (float, optional) – k2 parameter for SSIM calculation.
- forward(X: torch.Tensor, Y: torch.Tensor, data_range: Optional[torch.Tensor] = None)[source]#
Forward pass of
SSIMLoss.- Parameters
X (torch.Tensor) – First input tensor.
Y (torch.Tensor) – Second input tensor.
data_range (torch.Tensor) – Data range of the input tensors. If
None, it is computed as the maximum range of the input tensors. Default isNone.