Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f9aa4b

Browse files
fix eddy command and multithreading
1 parent 2f85d92 commit 2f9aa4b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

‎nipype/interfaces/fsl/epi.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
was written to work with FSL version 5.0.4.
66
"""
77
import os
8+
from shutil import which
89
import numpy as np
910
import nibabel as nb
1011
import warnings
1112

1213
from ...utils.filemanip import split_filename, fname_presuffix
14+
from ...utils.gpu_count import gpu_count
1315

1416
from ..base import traits, TraitedSpec, InputMultiPath, File, isdefined
1517
from .base import FSLCommand, FSLCommandInputSpec, Info
@@ -793,9 +795,12 @@ class EddyInputSpec(FSLCommandInputSpec):
793795
requires=["estimate_move_by_susceptibility"],
794796
min_ver="6.0.1",
795797
)
796-
797798
num_threads = traits.Int(
798-
1, usedefault=True, nohash=True, desc="Number of openmp threads to use"
799+
argstr="--nthr=%d",
800+
default_value=1,
801+
usedefault=True,
802+
nohash=True,
803+
desc="Number of openmp threads to use"
799804
)
800805
is_shelled = traits.Bool(
801806
False,
@@ -937,7 +942,7 @@ class Eddy(FSLCommand):
937942
938943
"""
939944

940-
_cmd = "eddy_openmp"
945+
_cmd = "eddy_openmp"ifwhich("eddy_openmp") else"eddy_cpu"
941946
input_spec = EddyInputSpec
942947
output_spec = EddyOutputSpec
943948

@@ -963,17 +968,22 @@ def _num_threads_update(self):
963968
self.inputs.environ["OMP_NUM_THREADS"] = str(self.inputs.num_threads)
964969

965970
def _use_cuda(self):
966-
self._cmd = "eddy_cuda" if self.inputs.use_cuda else "eddy_openmp"
971+
if self.inputs.use_cuda and gpu_count()>0:
972+
# eddy_cuda usually link to eddy_cudaX.X but some versions miss the symlink
973+
# anyway in newer fsl versions eddy automatically use cuda on cuda-capable systems
974+
self._cmd = "eddy_cuda" if which("eddy_cuda") else "eddy"
975+
else:
976+
# older fsl versions has cuda_openmp, newer versions has eddy_cpu
977+
_cmd = "eddy_openmp" if which("eddy_openmp") else "eddy_cpu"
967978

968979
def _run_interface(self, runtime):
969-
# If 'eddy_openmp' is missing, use 'eddy'
980+
# If selected command is missing, use generic 'eddy'
970981
FSLDIR = os.getenv("FSLDIR", "")
971982
cmd = self._cmd
972983
if all(
973984
(
974985
FSLDIR != "",
975-
cmd == "eddy_openmp",
976-
not os.path.exists(os.path.join(FSLDIR, "bin", cmd)),
986+
not os.path.exists(os.path.join(FSLDIR, "bin", self._cmd)),
977987
)
978988
):
979989
self._cmd = "eddy"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /