@@ -456,39 +456,44 @@ def _make_matlab_command(self, _):
456
456
contrasts [i ].weights = cont [3 ]
457
457
if len (cont ) >= 5 :
458
458
contrasts [i ].sessions = cont [4 ]
459
- script = ["""\
460
- % generated by nipype.interfaces.spm
459
+ script = [
460
+ """\
461
+ %% generated by nipype.interfaces.spm
461
462
spm_defaults;
462
463
jobs{1}.stats{1}.con.spmmat = {'%s'};
463
464
load(jobs{1}.stats{1}.con.spmmat{:});
464
465
SPM.swd = '%s';
465
466
save(jobs{1}.stats{1}.con.spmmat{:},'SPM');
466
- names = SPM.xX.name;
467
- """ % (self .inputs .spm_mat_file , os .getcwd ())]
467
+ names = SPM.xX.name;"""
468
+ % (self .inputs .spm_mat_file , os .getcwd ())
469
+ ]
468
470
# get names for columns
469
471
if isdefined (self .inputs .group_contrast ) and self .inputs .group_contrast :
470
472
script += ["condnames=names;" ]
471
473
else :
472
474
if self .inputs .use_derivs :
473
475
script += [r"pat = 'Sn\([0-9]*\) (.*)';" ]
474
476
else :
475
- script += [r"""\
476
- pat = 'Sn\([0-9]*\) (.*)\*bf\(1\)|Sn\([0-9]*\) .*\*bf\([2-9]\)|Sn\([0-9]*\) (.*)';""" ]
477
+ script += [
478
+ r"pat = 'Sn\([0-9]*\) (.*)\*bf\(1\)|Sn\([0-9]*\) "
479
+ r".*\*bf\([2-9]\)|Sn\([0-9]*\) (.*)';"
480
+ ]
477
481
478
482
script += ["t = regexp(names,pat,'tokens');" ]
479
483
# get sessidx for columns
480
484
script += [r"pat1 = 'Sn\(([0-9].*)\)\s.*';" ]
481
485
script += ["t1 = regexp(names,pat1,'tokens');" ]
482
- script += ["""\
486
+ script += [
487
+ """\
483
488
for i0=1:numel(t)
484
489
condnames{i0}='';
485
490
condsess(i0)=0;
486
491
if ~isempty(t{i0}{1})
487
492
condnames{i0} = t{i0}{1}{1};
488
493
condsess(i0)=str2num(t1{i0}{1}{1});
489
494
end;
490
- end;
491
- """ ]
495
+ end;"""
496
+ ]
492
497
493
498
# BUILD CONTRAST SESSION STRUCTURE
494
499
for i , contrast in enumerate (contrasts ):
@@ -497,37 +502,42 @@ def _make_matlab_command(self, _):
497
502
script += ["consess{%d}.tcon.convec = zeros(1,numel(names));" % (i + 1 )]
498
503
for c0 , cond in enumerate (contrast .conditions ):
499
504
script += ["idx = strmatch('%s',condnames,'exact');" % cond ]
500
- script += ["""\
505
+ script += [
506
+ """\
501
507
if isempty(idx)
502
508
throw(MException('CondName:Chk', sprintf('Condition %%s not found in design','%s')));
503
- end;
504
- """ % cond ]
509
+ end;"""
510
+ % cond
511
+ ]
505
512
if contrast .sessions :
506
513
for sno , sw in enumerate (contrast .sessions ):
507
514
script += ["sidx = find(condsess(idx)==%d);" % (sno + 1 )]
508
- script += ["consess{%d}.tcon.convec(idx(sidx)) = %f;" % (
509
- i + 1 ,
510
- sw * contrast .weights [c0 ],
511
- ) ]
515
+ script += [
516
+ "consess{%d}.tcon.convec(idx(sidx)) = %f;"
517
+ % ( i + 1 , sw * contrast .weights [c0 ],)
518
+ ]
512
519
else :
513
- script += ["consess{%d}.tcon.convec(idx) = %f;" % (
514
- i + 1 ,
515
- contrast .weights [c0 ],
516
- ) ]
520
+ script += [
521
+ "consess{%d}.tcon.convec(idx) = %f;"
522
+ % ( i + 1 , contrast .weights [c0 ],)
523
+ ]
517
524
for i , contrast in enumerate (contrasts ):
518
525
if contrast .stat == "F" :
519
526
script += ["consess{%d}.fcon.name = '%s';" % (i + 1 , contrast .name )]
520
527
for cl0 , fcont in enumerate (contrast .conditions ):
521
528
tidx = cname .index (fcont [0 ])
522
- script += ["consess{%d}.fcon.convec{%d} = consess{%d}.tcon.convec;" %
523
- (i + 1 , cl0 + 1 , tidx + 1 )]
529
+ script += [
530
+ "consess{%d}.fcon.convec{%d} = consess{%d}.tcon.convec;"
531
+ % (i + 1 , cl0 + 1 , tidx + 1 )
532
+ ]
524
533
script += ["jobs{1}.stats{1}.con.consess = consess;" ]
525
- script += ["""\
534
+ script += [
535
+ """\
526
536
if strcmp(spm('ver'),'SPM8')
527
537
spm_jobman('initcfg');
528
538
jobs=spm_jobman('spm5tospm8',{jobs});
529
- end;
530
- """ ]
539
+ end;"""
540
+ ]
531
541
script += ["spm_jobman('run',jobs);" ]
532
542
return "\n " .join (script )
533
543
0 commit comments