Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #341 from satra/fix/spmmodel

Fix/spmmodel
  • Loading branch information...
commit 1764f0f7d8a54245cc7bced1e2156b30a74a4ad1 2 parents 2416b65 + 394ecfb
Chris Filo Gorgolewski authored
5 CHANGES
... ... @@ -1,3 +1,8 @@
  1 +Since 0.5.2
  2 +===========
  3 +
  4 +* FIX: SPM model generation when output units is in scans
  5 +
1 6 Release 0.5.2 (Mar 14, 2012)
2 7 ============================
3 8
7 nipype/algorithms/modelgen.py
@@ -271,6 +271,9 @@ def _generate_standard_design(self, infolist,
271 271 each run
272 272 """
273 273 sessinfo = []
  274 + output_units = 'secs'
  275 + if 'output_units' in self.inputs.traits():
  276 + output_units = self.inputs.output_units
274 277 for i, info in enumerate(infolist):
275 278 sessinfo.insert(i, dict(cond=[]))
276 279 if isdefined(self.inputs.high_pass_filter_cutoff):
@@ -281,11 +284,11 @@ def _generate_standard_design(self, infolist,
281 284 sessinfo[i]['cond'][cid]['name'] = info.conditions[cid]
282 285 sessinfo[i]['cond'][cid]['onset'] = scale_timings(info.onsets[cid],
283 286 self.inputs.input_units,
284   - 'secs',
  287 + output_units,
285 288 self.inputs.time_repetition)
286 289 sessinfo[i]['cond'][cid]['duration'] = scale_timings(info.durations[cid],
287 290 self.inputs.input_units,
288   - 'secs',
  291 + output_units,
289 292 self.inputs.time_repetition)
290 293 if hasattr(info, 'amplitudes') and info.amplitudes:
291 294 sessinfo[i]['cond'][cid]['amplitudes'] = info.amplitudes[cid]
31 nipype/algorithms/tests/test_modelgen.py
... ... @@ -1,5 +1,6 @@
1 1 # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2 2 # vi: set ft=python sts=4 ts=4 sw=4 et:
  3 +from copy import deepcopy
3 4 import os
4 5 from shutil import rmtree
5 6 from tempfile import mkdtemp
@@ -44,27 +45,35 @@ def test_modelgen_spm_concat():
44 45 tempdir = mkdtemp()
45 46 filename1 = os.path.join(tempdir, 'test1.nii')
46 47 filename2 = os.path.join(tempdir, 'test2.nii')
47   - Nifti1Image(np.random.rand(10, 10, 10, 50), np.eye(4)).to_filename(filename1)
48   - Nifti1Image(np.random.rand(10, 10, 10, 50), np.eye(4)).to_filename(filename2)
  48 + Nifti1Image(np.random.rand(10, 10, 10, 30), np.eye(4)).to_filename(filename1)
  49 + Nifti1Image(np.random.rand(10, 10, 10, 30), np.eye(4)).to_filename(filename2)
49 50 s = SpecifySPMModel()
50 51 s.inputs.input_units = 'secs'
51   - s.inputs.output_units = 'scans'
52 52 s.inputs.concatenate_runs = True
53   - setattr(s.inputs, 'output_units', 'scans')
54   - yield assert_equal, s.inputs.output_units, 'scans'
  53 + setattr(s.inputs, 'output_units', 'secs')
  54 + yield assert_equal, s.inputs.output_units, 'secs'
55 55 s.inputs.functional_runs = [filename1, filename2]
56 56 s.inputs.time_repetition = 6
57 57 s.inputs.high_pass_filter_cutoff = 128.
58   - info = [Bunch(conditions=['cond1'], onsets=[[2, 50, 100, 180]], durations=[[1]], amplitudes=None,
59   - pmod=None, regressors=None, regressor_names=None, tmod=None),
60   - Bunch(conditions=['cond1'], onsets=[[30, 40, 100, 150]], durations=[[1]], amplitudes=None,
61   - pmod=None, regressors=None, regressor_names=None, tmod=None)]
62   - s.inputs.subject_info = info
  58 + info = [Bunch(conditions=['cond1'], onsets=[[2, 50, 100, 170]], durations=[[1]]),
  59 + Bunch(conditions=['cond1'], onsets=[[30, 40, 100, 150]], durations=[[1]])]
  60 + s.inputs.subject_info = deepcopy(info)
63 61 res = s.run()
64 62 yield assert_equal, len(res.outputs.session_info), 1
65 63 yield assert_equal, len(res.outputs.session_info[0]['regress']), 1
  64 + yield assert_equal, np.sum(res.outputs.session_info[0]['regress'][0]['val']), 30
66 65 yield assert_equal, len(res.outputs.session_info[0]['cond']), 1
67   - yield assert_almost_equal, np.array(res.outputs.session_info[0]['cond'][0]['onset']), np.array([2.0, 50.0, 100.0, 180.0, 330.0, 340.0, 400.0, 450.0])
  66 + yield assert_almost_equal, np.array(res.outputs.session_info[0]['cond'][0]['onset']), np.array([2.0, 50.0, 100.0, 170.0, 210.0, 220.0, 280.0, 330.0])
  67 + setattr(s.inputs, 'output_units', 'scans')
  68 + yield assert_equal, s.inputs.output_units, 'scans'
  69 + s.inputs.subject_info = deepcopy(info)
  70 + res = s.run()
  71 + yield assert_almost_equal, np.array(res.outputs.session_info[0]['cond'][0]['onset']), np.array([2.0, 50.0, 100.0, 170.0, 210.0, 220.0, 280.0, 330.0])/6
  72 + s.inputs.concatenate_runs = False
  73 + s.inputs.subject_info = deepcopy(info)
  74 + s.inputs.output_units = 'secs'
  75 + res = s.run()
  76 + yield assert_almost_equal, np.array(res.outputs.session_info[0]['cond'][0]['onset']), np.array([2.0, 50.0, 100.0, 170.0])
68 77 rmtree(tempdir)
69 78
70 79
2  nipype/workflows/dmri/fsl/tbss.py
@@ -504,7 +504,7 @@ def create_tbss_non_FA(name='tbss_non_FA'):
504 504 inputnode.distance_map
505 505
506 506 Outputs::
507   -
  507 +
508 508 outputnode.projected_nonFA_file
509 509
510 510 """
2  tools/build_interface_docs.py
@@ -42,7 +42,7 @@
42 42 'FSL',
43 43 'FS',
44 44 'Info',
45   - 'SPM',
  45 + '^SPM',
46 46 'Tester',
47 47 'Spec$',
48 48 'Numpy'

0 comments on commit 1764f0f

Please sign in to comment.
Something went wrong with that request. Please try again.