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

Analysis: Noise Floor Delta over Z-axis #151

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions aydin/analysis/demo/demo_noise_floor_delta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# flake8: noqa
from aydin.analysis.noise_floor_delta import noise_floor_delta
from aydin.io.datasets import examples_single


def demo_noise_floor_delta():
noisy_image = examples_single.gauss_noisy.get_array()

noise_floor_delta = noise_floor_delta(denoised_image, noisy_image, axis=0)


if __name__ == '__main__':
demo_noise_floor_delta()
5 changes: 5 additions & 0 deletions aydin/analysis/fsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def fsc(image1, image2):
Method that calculates Fourier Shell Correlations between
the two provided 2D images. For more,
https://en.wikipedia.org/wiki/Fourier_shell_correlation

Parameters
----------
image1 : numpy.ArrayLike
Expand Down Expand Up @@ -59,3 +60,7 @@ def shell_sum(image):
]

return output


def halfbit_curve(correlations):
raise NotImplementedError()
32 changes: 32 additions & 0 deletions aydin/analysis/noise_floor_delta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from aydin.analysis.fsc import fsc, halfbit_curve


def noise_floor_delta(noisy_array, denoised_array1, denoised_array2) -> float:
"""
This method calculates the noise floor level difference on spectra
of a noisy and a denoised array (does NOT require groundtruth).

Parameters
----------
denoised_array : numpy.typing.ArrayLike
Denoised nD array of interest
noisy_array : numpy.typing.ArrayLike
Noisy(original) nD array of interest

Returns
-------
float
Calculated noise floor difference between the noisy and denoised arrays.

"""
# TODO: handle the case where axis=-1
# if axis == -1:
# numpy.newaxis(denoised_array, 0)

correlations1 = fsc(noisy_array, denoised_array1)
correlations2 = fsc(noisy_array, denoised_array2)

halfbit1 = halfbit_curve(correlations1)
halfbit2 = halfbit_curve(correlations2)

return abs(halfbit1 - halfbit2)
1 change: 0 additions & 1 deletion aydin/io/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from enum import Enum
from os.path import join, exists
from typing import Optional

import gdown
import numpy
from scipy.ndimage import binary_dilation, zoom
Expand Down