Skip to content

Commit fbf24fa

Browse files
committed
adding an example to RegistrationSynQuick; using LOCAL_DEFAULT_NUMBER_OF_THREADS env var as num_threads
1 parent 66b28df commit fbf24fa

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

nipype/interfaces/ants/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"""Top-level namespace for ants."""
55

66
# Registraiton programs
7-
from .registration import ANTS, Registration, MeasureImageSimilarity
7+
from .registration import (ANTS, Registration, RegistrationSynQuick,
8+
MeasureImageSimilarity)
89

910
# Resampling Programs
1011
from .resampling import (ApplyTransforms, ApplyTransformsToPoints,

nipype/interfaces/ants/registration.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
from ..base import TraitedSpec, File, Str, traits, InputMultiPath, isdefined
1818
from .base import ANTSCommand, ANTSCommandInputSpec
1919

20+
try:
21+
LOCAL_DEFAULT_NUMBER_OF_THREADS = int(os.getenv("LOCAL_DEFAULT_NUMBER_OF_THREADS"))
22+
except TypeError:
23+
LOCAL_DEFAULT_NUMBER_OF_THREADS = 1
24+
2025

2126
class ANTSInputSpec(ANTSCommandInputSpec):
2227
dimension = traits.Enum(
@@ -1516,9 +1521,8 @@ class RegistrationSynQuickInputSpec(ANTSCommandInputSpec):
15161521
desc='Moving image or target image')
15171522
output_prefix = Str("transform", usedefault=True, argstr='-o %s',
15181523
desc="A prefix that is prepended to all output files")
1519-
1520-
# todo ANTSCommandInputSpec already has this, but I can't figure out how to set it without defining it again
1521-
num_threads = traits.Int(default_value=1, desc='Number of threads (default = 1)', argstr='-n %d')
1524+
num_threads = traits.Int(default_value=LOCAL_DEFAULT_NUMBER_OF_THREADS, usedefault=True,
1525+
desc='Number of threads (default = 1)', argstr='-n %d')
15221526

15231527
transform_type = traits.Enum('s', 't', 'r', 'a', 'sr', 'b', 'br', argstr='-t %s',
15241528
desc="""
@@ -1554,11 +1558,24 @@ class RegistrationSynQuickOutputSpec(TraitedSpec):
15541558

15551559
class RegistrationSynQuick(ANTSCommand):
15561560
"""
1561+
Reistration using a symmetric image normalization method (SyN).
1562+
You can read more in Avants et al.; Med Image Anal., 2008
1563+
(https://www.ncbi.nlm.nih.gov/pubmed/17659998).
1564+
15571565
Examples
15581566
--------
15591567
1568+
>>> import copy, pprint
1569+
>>> from nipype.interfaces.ants import Registration
1570+
>>> reg = RegistrationSynQuick()
1571+
>>> reg.inputs.fixed_image = 'fixed1.nii'
1572+
>>> reg.inputs.moving_image = 'moving1.nii'
1573+
>>> reg.inputs.num_threads = 2
1574+
>>> reg.cmdline
1575+
'antsRegistrationSynQuick.sh -d 3 -f fixed1.nii -m moving1.nii -n 2 -o transform -p d -t s'
1576+
>>> reg.run() # doctest: +SKIP
15601577
"""
1561-
# todo examples
1578+
15621579

15631580
_cmd = 'antsRegistrationSynQuick.sh'
15641581
input_spec = RegistrationSynQuickInputSpec

0 commit comments

Comments
 (0)