|
15 | 15 |
|
16 | 16 | from ...utils.filemanip import filename_to_list
|
17 | 17 | from ..base import TraitedSpec, File, Str, traits, InputMultiPath, isdefined
|
18 |
| -from .base import ANTSCommand, ANTSCommandInputSpec |
19 |
| - |
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 |
| 18 | +from .base import ANTSCommand, ANTSCommandInputSpec, LOCAL_DEFAULT_NUMBER_OF_THREADS |
24 | 19 |
|
25 | 20 |
|
26 | 21 | class ANTSInputSpec(ANTSCommandInputSpec):
|
@@ -1565,38 +1560,52 @@ class RegistrationSynQuick(ANTSCommand):
|
1565 | 1560 | Examples
|
1566 | 1561 | --------
|
1567 | 1562 |
|
1568 |
| - >>> import copy, pprint |
1569 |
| - >>> from nipype.interfaces.ants import Registration |
| 1563 | + >>> from nipype.interfaces.ants import RegistrationSynQuick |
1570 | 1564 | >>> reg = RegistrationSynQuick()
|
1571 | 1565 | >>> reg.inputs.fixed_image = 'fixed1.nii'
|
1572 | 1566 | >>> reg.inputs.moving_image = 'moving1.nii'
|
1573 | 1567 | >>> reg.inputs.num_threads = 2
|
1574 | 1568 | >>> reg.cmdline
|
1575 | 1569 | 'antsRegistrationSynQuick.sh -d 3 -f fixed1.nii -m moving1.nii -n 2 -o transform -p d -t s'
|
1576 | 1570 | >>> reg.run() # doctest: +SKIP
|
| 1571 | +
|
| 1572 | + example for multiple images |
| 1573 | +
|
| 1574 | + >>> from nipype.interfaces.ants import RegistrationSynQuick |
| 1575 | + >>> reg = RegistrationSynQuick() |
| 1576 | + >>> reg.inputs.fixed_image = ['fixed1.nii', 'fixed2.nii'] |
| 1577 | + >>> reg.inputs.moving_image = ['moving1.nii', 'moving2.nii'] |
| 1578 | + >>> reg.inputs.num_threads = 2 |
| 1579 | + >>> reg.cmdline |
| 1580 | + 'antsRegistrationSynQuick.sh -d 3 -f fixed1.nii fixed2.nii -m moving1.nii moving2.nii -n 2 -o transform -p d -t s' |
| 1581 | + >>> reg.run() # doctest: +SKIP |
1577 | 1582 | """
|
1578 | 1583 |
|
1579 | 1584 |
|
1580 | 1585 | _cmd = 'antsRegistrationSynQuick.sh'
|
1581 | 1586 | input_spec = RegistrationSynQuickInputSpec
|
1582 | 1587 | output_spec = RegistrationSynQuickOutputSpec
|
1583 | 1588 |
|
| 1589 | + def _num_threads_update(self): |
| 1590 | + """ |
| 1591 | + antsRegistrationSynQuick.sh ignores environment variables, |
| 1592 | + so override environment update frm ANTSCommand class |
| 1593 | + """ |
| 1594 | + pass |
| 1595 | + |
1584 | 1596 | def _format_arg(self, name, spec, value):
|
1585 | 1597 | if name == 'precision_type':
|
1586 | 1598 | return spec.argstr % value[0]
|
1587 | 1599 | return super(RegistrationSynQuick, self)._format_arg(name, spec, value)
|
1588 | 1600 |
|
1589 | 1601 | def _list_outputs(self):
|
1590 | 1602 | outputs = self.output_spec().get()
|
1591 |
| - outputs['warped_image'] = os.path.abspath(self.inputs.output_prefix + 'Warped.nii.gz') |
1592 |
| - outputs['inverse_warped_image'] = os.path.abspath( |
1593 |
| - self.inputs.output_prefix + 'InverseWarped.nii.gz') |
1594 |
| - outputs['out_matrix'] = os.path.abspath(self.inputs.output_prefix + '0GenericAffine.mat') |
| 1603 | + out_base = os.path.abspath(self.inputs.output_prefix) |
| 1604 | + outputs['warped_image'] = out_base + 'Warped.nii.gz' |
| 1605 | + outputs['inverse_warped_image'] = out_base + 'InverseWarped.nii.gz' |
| 1606 | + outputs['out_matrix'] = out_base + '0GenericAffine.mat' |
1595 | 1607 |
|
1596 |
| - # todo in the case of linear transformation-only there won't be fields. is there a more elegant way to specify that? |
1597 | 1608 | if self.inputs.transform_type not in ('t', 'r', 'a'):
|
1598 |
| - outputs['forward_warp_field'] = os.path.abspath( |
1599 |
| - self.inputs.output_prefix + '1Warp.nii.gz') |
1600 |
| - outputs['inverse_warp_field'] = os.path.abspath( |
1601 |
| - self.inputs.output_prefix + '1InverseWarp.nii.gz') |
| 1609 | + outputs['forward_warp_field'] = out_base + '1Warp.nii.gz' |
| 1610 | + outputs['inverse_warp_field'] = out_base + '1InverseWarp.nii.gz' |
1602 | 1611 | return outputs
|
0 commit comments