8000 [ENH] Allow multithreading in eddy by mattcieslak · Pull Request #743 · PennLINC/qsiprep · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[ENH] Allow multithreading in eddy #743

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

Merged
merged 1 commit into from
May 2, 2024
Merged
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
20 changes: 5 additions & 15 deletions qsiprep/interfaces/eddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ def _run_interface(self, runtime):
return runtime


class ExtendedEddyInputSpec(fsl.epi.EddyInputSpec):
num_threads = traits.Int(1, usedefault=True, argstr="--nthr=%d")


class ExtendedEddyOutputSpec(fsl.epi.EddyOutputSpec):
shell_PE_translation_parameters = File(
exists=True, desc=("the translation along the PE-direction between the different shells")
Expand Down Expand Up @@ -169,29 +173,15 @@ class ExtendedEddyOutputSpec(fsl.epi.EddyOutputSpec):


class ExtendedEddy(fsl.Eddy):
input_spec = ExtendedEddyInputSpec
output_spec = ExtendedEddyOutputSpec

_num_threads = 1

def __init__(self, **inputs):
super(ExtendedEddy, self).__init__(**inputs)
self.inputs.on_trait_change(self._num_threads_update, "num_threads")
if not isdefined(self.inputs.num_threads):
self.inputs.num_threads = self._num_threads
else:
self._num_threads_update()
self.inputs.on_trait_change(self._use_cuda, "use_cuda")
if isdefined(self.inputs.use_cuda):
self._use_cuda()

def _num_threads_update(self):
self._num_threads = self.inputs.num_threads
if not isdefined(self.inputs.num_threads):
if "OMP_NUM_THREADS" in self.inputs.environ:
del self.inputs.environ["OMP_NUM_THREADS"]
else:
self.inputs.environ["OMP_NUM_THREADS"] = str(self.inputs.num_threads)

def _use_cuda(self):
self._cmd = "eddy_cuda10.2" if self.inputs.use_cuda else "eddy_cpu"

Expand Down
0