Skip to content

Commit 5b9fc04

Browse files
committed
Merge branch 'enh/activations-count-map' of github.com:oesteban/nipype into enh/activations-count-map
2 parents 4cf7f66 + 068dda0 commit 5b9fc04

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

nipype/algorithms/stats.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@ class ACM(SimpleInterface):
4141
output_spec = ACMOutputSpec
4242

4343
def _run_interface(self, runtime):
44-
allmaps = nb.concat_images(
45-
[nb.load(f) for f in self.inputs.in_files]).get_data()
46-
acm_pos = (allmaps > self.inputs.threshold).astype(
47-
float).mean(3)
48-
acm_neg = (allmaps < -1.0 * self.inputs.threshold).astype(
49-
float).mean(3)
50-
44+
allmaps = nb.concat_images(self.inputs.in_files).get_data()
45+
acm_pos = np.mean(allmaps > self.inputs.threshold,
46+
axis=3, dtype=np.float32)
47+
acm_neg = np.mean(allmaps < -1.0 * self.inputs.threshold,
48+
axis=3, dtype=np.float32)
5149
acm_diff = acm_pos - acm_neg
5250

5351
nii = nb.load(self.inputs.in_files[0])
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from __future__ import unicode_literals
3+
from ..stats import ACM
4+
5+
6+
def test_ACM_inputs():
7+
input_map = dict(
8+
ignore_exception=dict(
9+
deprecated='1.0.0',
10+
nohash=True,
11+
usedefault=True,
12+
),
13+
in_files=dict(mandatory=True, ),
14+
threshold=dict(usedefault=True, ),
15+
)
16+
inputs = ACM.input_spec()
17+
18+
for key, metadata in list(input_map.items()):
19+
for metakey, value in list(metadata.items()):
20+
assert getattr(inputs.traits()[key], metakey) == value
21+
def test_ACM_outputs():
22+
output_map = dict(
23+
acm_neg=dict(),
24+
acm_pos=dict(),
25+
out_file=dict(),
26+
)
27+
outputs = ACM.output_spec()
28+
29+
for key, metadata in list(output_map.items()):
30+
for metakey, value in list(metadata.items()):
31+
assert getattr(outputs.traits()[key], metakey) == value

0 commit comments

Comments
 (0)