Skip to content

Commit

Permalink
Apply changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
po09i committed Aug 22, 2023
1 parent e4ecb34 commit 18c7d78
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
3 changes: 3 additions & 0 deletions docs/source/user_section/installation/install_on_windows.rst
Expand Up @@ -62,6 +62,9 @@ Dependencies
Installation Procedure for Windows
----------------------------------

Conda requires an installation path that does not contain spaces. Your username should not contain spaces to avoid this issue.
If your username contains spaces, you can create a new user account with no spaces in the username or use a different OS.

.. Note::

The installer will install ``Shimming Toolbox`` and ``dcm2niix`` into an isolated environment. It will not interfere if you already have ``dcm2niix`` installed.
Expand Down
13 changes: 7 additions & 6 deletions shimmingtoolbox/cli/check_env.py
Expand Up @@ -83,10 +83,11 @@ def check_prelude_installation():
bool: True if prelude is installed, False if not.
"""
try:
if sys.platform != 'win32':
subprocess.check_call(['which', 'prelude'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
if sys.platform == 'win32':
subprocess.check_call(['where', 'prelude'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
subprocess.check_call(['which', 'prelude'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

except subprocess.CalledProcessError as error:
print_fail()
print(f"Error {error.returncode}: prelude is not installed or not in your PATH.")
Expand All @@ -106,10 +107,10 @@ def check_dcm2niix_installation():
bool: True if dcm2niix is installed, False if not.
"""
try:
if sys.platform != 'win32':
subprocess.check_call(['which', 'dcm2niix'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
if sys.platform == 'win32':
subprocess.check_call(['where', 'dcm2niix'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
subprocess.check_call(['which', 'dcm2niix'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError as error:
print(error)
print_fail()
Expand Down
16 changes: 6 additions & 10 deletions shimmingtoolbox/unwrap/skimage_unwrap.py
Expand Up @@ -60,18 +60,14 @@ def skimage_unwrap(nii_wrapped_phase, mag=None, mask=None, threshold=None, fname
# Mask the wrapped phase
ma_wrapped_phase = ma.array(wrapped_phase, mask=~unwrap_mask.astype(bool))

singleton = False
if ma_wrapped_phase.ndim == 3 and ma_wrapped_phase.shape[2] == 1:
# If the phase is 3D with a single slice, remove the last dimension
ma_wrapped_phase = ma_wrapped_phase[:, :, 0]
singleton = True

# Unwrap the masked phase
ma_unwrapped_phase = unwrap_phase(ma_wrapped_phase, rng=0)

if singleton:
# If the phase was 3D with a single slice, add the last dimension back
# If the phase is 3D with a single slice, pass the array as 2D and unwrap
ma_unwrapped_phase = unwrap_phase(ma_wrapped_phase[:, :, 0], rng=0)
# Add the 3rd dimension back
ma_unwrapped_phase = ma_unwrapped_phase[:, :, np.newaxis]
else:
# Normal 3D case: Unwrap the phase
ma_unwrapped_phase = unwrap_phase(ma_wrapped_phase, rng=0)

# Fill the masked values with 0
unwrapped_phase = ma_unwrapped_phase.filled(0)
Expand Down

0 comments on commit 18c7d78

Please sign in to comment.