-
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.
* add numpyro * small corrections * typing * typing * typing * snr doc * typing * minor refactor * ruff
- Loading branch information
1 parent
68e15c8
commit 238d4b9
Showing
8 changed files
with
45 additions
and
31 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
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,14 +1,17 @@ | ||
import numpy as np | ||
from jax.typing import ArrayLike | ||
import jax.numpy as jnp | ||
from jaxtyping import ArrayLike | ||
|
||
|
||
def get_snr(im: ArrayLike, background: float) -> float: | ||
"""Calculate the signal-to-noise ratio of an image. | ||
Args: | ||
im: Image array with no background. | ||
im: 2D image array with no background. | ||
background: Background level. | ||
Returns: | ||
float: The signal-to-noise ratio. | ||
""" | ||
assert im.ndim == 2 | ||
assert isinstance(background, float) or background.shape == () | ||
return np.sqrt(np.sum(im * im / (background + im))) | ||
return jnp.sqrt(jnp.sum(im * im / (background + im))) |
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