Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
4rnaudB committed Nov 16, 2023
1 parent 0218dde commit b89351d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions shimmingtoolbox/load_nifti.py
Expand Up @@ -181,14 +181,11 @@ def read_nii(fname_nifti, auto_scale=True):
extent = (np.amax(image) - np.amin(image))

if np.amin(image) < 0 and (0.95 * 2 * PHASE_SCALING_SIEMENS < extent < 2 * PHASE_SCALING_SIEMENS * 1.05):
# Siemens' scaling: [-4096, 4095] --> [-pi, pi)
# Siemens' scaling: [-4096, 4095] --> [-pi, pi[
image = (image * math.pi / PHASE_SCALING_SIEMENS)
image = np.angle(np.exp(1j * image))
elif np.amin(image) >= 0 and (0.95 * PHASE_SCALING_SIEMENS < extent < PHASE_SCALING_SIEMENS * 1.05):
# Siemens' scaling [0, 4095] --> [0, 2pi)
# We want: [-pi, pi]
# Siemens' scaling [0, 4095] --> [-pi, pi[
image = (image * 2 * math.pi / PHASE_SCALING_SIEMENS) - math.pi
image = np.angle(np.exp(1j * image))
else:
logger.info("Could not scale phase data")

Expand Down

0 comments on commit b89351d

Please sign in to comment.