Skip to content
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

[FIX] Constrain threading for intramodal template #825

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions qsiprep/interfaces/ants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os.path as op

import nibabel as nb
from nipype.interfaces.ants.base import ANTSCommand, ANTSCommandInputSpec
from nipype.interfaces.base import (
BaseInterfaceInputSpec,
CommandLine,
Expand All @@ -22,7 +23,7 @@


# Step 1 from DSI Studio, importing DICOM files or nifti
class MultivariateTemplateConstruction2InputSpec(CommandLineInputSpec):
class MultivariateTemplateConstruction2InputSpec(ANTSCommandInputSpec):
dimension = traits.Enum(2, 3, 4, default=3, usedefault=True, argstr="-d %d")
input_file = File(desc="txt or csv file with images", exists=True, position=-1)
input_images = InputMultiObject(
Expand Down Expand Up @@ -93,7 +94,7 @@ class MultivariateTemplateConstruction2OutputSpec(TraitedSpec):
iteration_templates = OutputMultiObject(File(exists=True))


class MultivariateTemplateConstruction2(CommandLine):
class MultivariateTemplateConstruction2(ANTSCommand):
input_spec = MultivariateTemplateConstruction2InputSpec
output_spec = MultivariateTemplateConstruction2OutputSpec
_cmd = "antsMultivariateTemplateConstruction2.sh "
Expand Down Expand Up @@ -136,6 +137,10 @@ def _list_outputs(self):

return outputs

def _num_threads_update(self):
# Parallelization is controlled by ants pexec
self.inputs.environ.update({"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS": "1", "NSLOTS": "1"})


class ImageMathInputSpec(BaseInterfaceInputSpec):
in_file = File(exists=True, mandatory=True, position=3, argstr="%s")
Expand Down
1 change: 1 addition & 0 deletions qsiprep/workflows/dwi/intramodal_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def init_intramodal_template_wf(
dimension=3, iteration_limit=num_iterations, **runtime_opts
),
name="ants_mvtc2",
n_procs=omp_nthreads,
)

workflow.connect([
Expand Down