Skip to content

Commit

Permalink
Implement Philips+GE related spherical harmonics conventions (#498)
Browse files Browse the repository at this point in the history
* Start adding Philips to the spherical harmonics

* Add dcm2niic to the bin dir

* Fix syntax

* Add to dcm2bids and remove development mode from windows installation

* Add wildcard for fm2d2 sequence

* Add Philips to spherical harmonics basis functions

* Add build folder to git-ignore

* Use the mask to set transparency rather than 0 values

* Update spherical harmonics for ge and philips, update dcm2bids config file

* Correctly output the calculated correction

* Update dcm2bids, remove coordinate origin shift

* Update BIDS config file with EPI and T1w sequences

* Touch ups and fix tests

* Bug fix and PEP improvement

* Add test for ScannerCoil
  • Loading branch information
po09i committed Jan 23, 2024
1 parent 857908f commit 6170cf3
Show file tree
Hide file tree
Showing 10 changed files with 495 additions and 218 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.pytest_cache/
.ipynb_checkpoints/
.vscode/
build/

# Project's data
testing_data
Expand Down
13 changes: 12 additions & 1 deletion installer/windows_install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ REM Installing Shimming Toolbox
copy "%ST_SOURCE_FILES%\config\dcm2bids.json" "%ST_DIR%\dcm2bids.json" || goto error

cd "%ST_SOURCE_FILES%"
"%ST_DIR%\%PYTHON_DIR%\python.exe" -m pip install -e ".[docs,dev]" --no-warn-script-location || goto error
"%ST_DIR%\%PYTHON_DIR%\python.exe" -m pip install . --no-warn-script-location || goto error

REM Create launchers for Shimming Toolbox
set "BIN_DIR=bin"
Expand All @@ -52,6 +52,17 @@ for %%f in ("%ST_DIR%\%PYTHON_DIR%\Scripts\st_*.*") do (
copy "%%f" "%ST_DIR%\%BIN_DIR%" || goto error
)

REM Copy dcm2niix to the bin directory, there are 2 places it might be
set "PATH_DCM2NIIX=%ST_DIR%\%PYTHON_DIR%\Library\bin\dcm2niix.exe"
if exist "%PATH_DCM2NIIX%" (copy "%PATH_DCM2NIIX%" "%ST_DIR%\%BIN_DIR%" || goto error) else (
set "PATH_DCM2NIIX=%ST_DIR%\%PYTHON_DIR%\Scripts\dcm2niix.exe"
if exist "%PATH_DCM2NIIX%" (copy "%PATH_DCM2NIIX%" "%ST_DIR%\%BIN_DIR%" || goto error) else (
echo "dcm2niix.exe not found"
goto error
)
)


REM Add scripts to the User's path
for /F "skip=2 tokens=2,*" %%A in ('reg.exe query "HKEY_CURRENT_USER\Environment" /v path') do set "OLD_PATH=%%B"
REM If OLD_PATH is not an empty string
Expand Down
10 changes: 6 additions & 4 deletions shimmingtoolbox/coils/coil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import numpy as np
from typing import Tuple

from shimmingtoolbox.coils.spher_harm_basis import siemens_basis, ge_basis
from shimmingtoolbox.coils.spher_harm_basis import siemens_basis, ge_basis, philips_basis, SHIM_CS
from shimmingtoolbox.coils.coordinates import generate_meshgrid
from shimmingtoolbox.shim.shim_utils import shim_cs

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -131,8 +130,8 @@ def __init__(self, dim_volume, affine, constraints, orders, manufacturer=""):
self.orders = orders

manufacturer = manufacturer.upper()
if manufacturer in shim_cs:
self.coord_system = shim_cs[manufacturer.upper()]
if manufacturer in SHIM_CS:
self.coord_system = SHIM_CS[manufacturer.upper()]
else:
logger.warning(f"Unknown manufacturer {manufacturer}, assuming RAS")
self.coord_system = 'RAS'
Expand Down Expand Up @@ -167,6 +166,9 @@ def _create_coil_profile(self, dim, manufacturer=None):
elif manufacturer == 'GE':
profile_orders = ge_basis(mesh1, mesh2, mesh3, orders=tuple(temp_orders),
shim_cs=self.coord_system)
elif manufacturer == 'PHILIPS':
profile_orders = philips_basis(mesh1, mesh2, mesh3, orders=tuple(temp_orders),
shim_cs=self.coord_system)
else:
logger.warning(f"{manufacturer} manufacturer not implemented. Outputting in Hz, uT/m, uT/m^2 for order "
f"0, 1 and 2 respectively")
Expand Down
1 change: 1 addition & 0 deletions shimmingtoolbox/coils/create_coil_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
logger = logging.getLogger(__name__)
TOLERANCE = 0.001


def create_coil_profiles(fnames_fmaps, list_currents):
""" Create coil profiles from fieldmaps
Expand Down
Loading

0 comments on commit 6170cf3

Please sign in to comment.