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

Fix type annotations for array inputs in signal functions #63

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 17 additions & 17 deletions src/osipi/_signal.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import numpy as np
from numpy.typing import NDArray


def signal_linear(R1: np.float64, k: np.float64) -> np.float64:
# Use a more generic floating-point type annotation
def signal_linear(R1: NDArray[np.floating], k: np.floating) -> NDArray[np.floating]:
"""Linear model for relationship between R1 and magnitude signal

Args:
R1 (np.float64): longitudinal relaxation rate in units of /s. [OSIPI code Q.EL1.001]
k (np.float64): proportionality constant in a.u. S [OSIPI code Q.GE1.009]

R1 (NDArray[np.floating]): longitudinal relaxation rate in units of /s. [OSIPI code Q.EL1.001]
k (np.floating): proportionality constant in a.u. S [OSIPI code Q.GE1.009]
Returns:
np.float64: magnitude signal in a.u. [OSIPI code Q.MS1.001]

NDArray[np.floating]: magnitude signal in a.u. [OSIPI code Q.MS1.001]
References:
- Lexicon url: https://osipi.github.io/OSIPI_CAPLEX/perfusionModels/#LinModel_SM2
- Lexicon code: M.SM2.001
Expand All @@ -21,25 +20,26 @@ def signal_linear(R1: np.float64, k: np.float64) -> np.float64:
return k * R1 # S


def signal_SPGR(R1: np.float64, S0: np.float64, TR: np.float64, a: np.float64) -> np.float64:
def signal_SPGR(
R1: NDArray[np.floating],
S0: NDArray[np.floating],
TR: np.floating,
a: np.floating,
) -> NDArray[np.floating]:
"""Steady-state signal for SPGR sequence.

Args:
R1 (np.float64): longitudinal relaxation rate in units of /s. [OSIPI code Q.EL1.001]
S0 (np.float64): fully T1-relaxed signal in a.u. [OSIPI code Q.MS1.010]
TR (np.float64): repetition time in units of s. [OSIPI code Q.MS1.006]
a (np.float64): prescribed flip angle in units of deg. [OSIPI code Q.MS1.007]

R1 (NDArray[np.floating]): longitudinal relaxation rate in units of /s. [OSIPI code Q.EL1.001]
S0 (NDArray[np.floating]): fully T1-relaxed signal in a.u. [OSIPI code Q.MS1.010]
TR (np.floating): repetition time in units of s. [OSIPI code Q.MS1.006]
a (np.floating): prescribed flip angle in units of deg. [OSIPI code Q.MS1.007]
Returns:
np.float64: magnitude signal in a.u. [OSIPI code Q.MS1.001]

NDArray[np.floating]: magnitude signal in a.u. [OSIPI code Q.MS1.001]
References:
- Lexicon url: https://osipi.github.io/OSIPI_CAPLEX/perfusionModels/#SPGR%20model
- Lexicon code: M.SM2.002
- OSIPI name: Spoiled gradient recalled echo model
- Adapted from equation given in the Lexicon and contribution from MJT_UoEdinburgh_UK
"""

# calculate signal
a_rad = a * np.pi / 180
exp_TR_R1 = np.exp(-TR * R1)
Expand Down