Skip to content

Commit eb4d72f

Browse files
committed
fix: resolved conflicts
2 parents fe08e18 + 31968f1 commit eb4d72f

File tree

4 files changed

+115
-1
lines changed

4 files changed

+115
-1
lines changed

.zenodo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,4 +527,4 @@
527527
],
528528
"license": "Apache-2.0",
529529
"upload_type": "software"
530-
}
530+
}

nipype/interfaces/dipy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
from .preprocess import Resample, Denoise
55
from .reconstruction import RESTORE, EstimateResponseSH, CSD
66
from .simulate import SimulateMultiTensor
7+
from .anisotropic_power import APMQball
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# -*- coding: utf-8 -*-
2+
"""Change directory to provide relative paths for doctests
3+
>>> import os
4+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
5+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
6+
>>> os.chdir(datadir)
7+
"""
8+
9+
from __future__ import print_function, division, unicode_literals, absolute_import
10+
11+
import nibabel as nb
12+
13+
from ... import logging
14+
from ..base import TraitedSpec, File, isdefined
15+
from .base import DipyDiffusionInterface, DipyBaseInterfaceInputSpec
16+
17+
IFLOGGER = logging.getLogger('interface')
18+
19+
20+
class APMQballInputSpec(DipyBaseInterfaceInputSpec):
21+
mask_file = File(exists=True,
22+
desc='An optional brain mask')
23+
24+
25+
class APMQballOutputSpec(TraitedSpec):
26+
out_file = File(exists=True)
27+
28+
29+
class APMQball(DipyDiffusionInterface):
30+
"""
31+
Calculates the anisotropic power map
32+
33+
Example
34+
-------
35+
36+
>>> import nipype.interfaces.dipy as dipy
37+
>>> apm = dipy.APMQball()
38+
>>> apm.inputs.in_file = 'diffusion.nii'
39+
>>> apm.inputs.in_bvec = 'bvecs'
40+
>>> apm.inputs.in_bval = 'bvals'
41+
>>> apm.run() # doctest: +SKIP
42+
"""
43+
input_spec = APMQballInputSpec
44+
output_spec = APMQballOutputSpec
45+
46+
def _run_interface(self, runtime):
47+
from dipy.reconst import shm
48+
from dipy.data import get_sphere
49+
from dipy.reconst.peaks import peaks_from_model
50+
51+
gtab = self._get_gradient_table()
52+
53+
img = nb.load(self.inputs.in_file)
54+
data = img.get_data()
55+
affine = img.affine
56+
mask = None
57+
if isdefined(self.inputs.mask_file):
58+
mask = nb.load(self.inputs.mask_file).get_data()
59+
60+
# Fit it
61+
model = shm.QballModel(gtab,8)
62+
sphere = get_sphere('symmetric724')
63+
peaks = peaks_from_model(model=model, data=data,
64+
relative_peak_threshold=.5,
65+
min_separation_angle=25,
66+
sphere=sphere, mask=mask)
67+
apm = shm.anisotropic_power(peaks.shm_coeff)
68+
out_file = self._gen_filename('apm')
69+
nb.Nifti1Image(apm.astype("float32"), affine).to_filename(out_file)
70+
IFLOGGER.info('APM qball image saved as {i}'.format(i=out_file))
71+
72+
return runtime
73+
74+
def _list_outputs(self):
75+
outputs = self._outputs().get()
76+
outputs['out_file'] = self._gen_filename('apm')
77+
78+
return outputs
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from __future__ import unicode_literals
3+
from ..anisotropic_power import APMQball
4+
5+
6+
def test_APMQball_inputs():
7+
input_map = dict(b0_thres=dict(usedefault=True,
8+
),
9+
ignore_exception=dict(nohash=True,
10+
usedefault=True,
11+
),
12+
in_bval=dict(mandatory=True,
13+
),
14+
in_bvec=dict(mandatory=True,
15+
),
16+
in_file=dict(mandatory=True,
17+
),
18+
mask_file=dict(),
19+
out_prefix=dict(),
20+
)
21+
inputs = APMQball.input_spec()
22+
23+
for key, metadata in list(input_map.items()):
24+
for metakey, value in list(metadata.items()):
25+
assert getattr(inputs.traits()[key], metakey) == value
26+
27+
28+
def test_APMQball_outputs():
29+
output_map = dict(out_file=dict(),
30+
)
31+
outputs = APMQball.output_spec()
32+
33+
for key, metadata in list(output_map.items()):
34+
for metakey, value in list(metadata.items()):
35+
assert getattr(outputs.traits()[key], metakey) == value

0 commit comments

Comments
 (0)