-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3a4c61
commit c58a82e
Showing
7 changed files
with
175 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,43 @@ | ||
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/06_metrics.ipynb. | ||
|
||
# %% auto 0 | ||
__all__ = ['foo'] | ||
__all__ = ['SSIMMetric', 'SSIM', 'FRCM'] | ||
|
||
# %% ../nbs/06_metrics.ipynb 3 | ||
def foo(): pass | ||
from numpy import trapz | ||
from fastai.vision.all import AvgMetric | ||
from .losses import SSIMLoss, get_fourier_ring_correlations | ||
|
||
# %% ../nbs/06_metrics.ipynb 4 | ||
def SSIM(x, y, spatial_dims=2): | ||
return 1 - SSIMLoss(spatial_dims)(x,y) | ||
|
||
SSIMMetric = AvgMetric(SSIM) | ||
|
||
# %% ../nbs/06_metrics.ipynb 5 | ||
def FRCM(image1, image2): | ||
|
||
|
||
""" | ||
Compute the area under the Fourier Ring Correlation (FRC) curve between two images. | ||
#### Args: | ||
- image1 (torch.Tensor): The first input image. | ||
- image2 (torch.Tensor): The second input image. | ||
#### Returns: | ||
- float: The area under the FRC curve. | ||
""" | ||
|
||
# Calculate the Fourier Ring Correlation and spatial frequency | ||
FRC, spatial_frequency = get_fourier_ring_correlations(image1, image2) | ||
|
||
# Convert to numpy | ||
FRC = FRC.numpy() | ||
spatial_frequency = spatial_frequency.numpy() | ||
|
||
# Compute the area under the curve using trapezoidal integration | ||
area = trapz(FRC, spatial_frequency) | ||
|
||
return area | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.