Skip to content

Commit

Permalink
[FIX] Constrain threading for intramodal template (#825)
Browse files Browse the repository at this point in the history
Change threading for intramodal template
  • Loading branch information
mattcieslak authored Oct 11, 2024
1 parent 8802df4 commit 5ff5caa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 5ff5caa

Please sign in to comment.