Skip to content

Commit 0cb565d

Browse files
author
Clark
committed
PEP8 compliance for model.py (100%)
1 parent 9c2911e commit 0cb565d

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

nipype/interfaces/spm/model.py

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,16 @@ def _make_matlab_command(self, _):
399399
for c0, cond in enumerate(contrast.conditions):
400400
script += ("idx = strmatch('%s',condnames,'exact');\n"
401401
% (cond))
402-
script += "if isempty(idx), throw(MException('CondName:Chk', sprintf('Condition %%s not found in design','%s'))); end;\n" % cond
402+
script += (("if isempty(idx), throw(MException("
403+
"'CondName:Chk', sprintf('Condition %%s not "
404+
"found in design','%s'))); end;\n") % cond)
403405
if contrast.sessions:
404406
for sno, sw in enumerate(contrast.sessions):
405407
script += ("sidx = find(condsess(idx)==%d);\n"
406408
% (sno + 1))
407-
script += "consess{%d}.tcon.convec(idx(sidx)) = %f;\n" % (i + 1, sw * contrast.weights[c0])
409+
script += (("consess{%d}.tcon.convec(idx(sidx)) "
410+
"= %f;\n")
411+
% (i + 1, sw * contrast.weights[c0]))
408412
else:
409413
script += ("consess{%d}.tcon.convec(idx) = %f;\n"
410414
% (i + 1, contrast.weights[c0]))
@@ -419,7 +423,9 @@ def _make_matlab_command(self, _):
419423
Exception("Contrast Estimate: could not get index of"
420424
" T contrast. probably not defined prior "
421425
"to the F contrasts")
422-
script += "consess{%d}.fcon.convec{%d} = consess{%d}.tcon.convec;\n" % (i + 1, cl0 + 1, tidx + 1)
426+
script += (("consess{%d}.fcon.convec{%d} = "
427+
"consess{%d}.tcon.convec;\n")
428+
% (i + 1, cl0 + 1, tidx + 1))
423429
script += "jobs{1}.stats{1}.con.consess = consess;\n"
424430
script += ("if strcmp(spm('ver'),'SPM8'), spm_jobman('initcfg');"
425431
"jobs=spm_jobman('spm5tospm8',{jobs});end\n")
@@ -578,7 +584,9 @@ def _make_matlab_command(self, _):
578584
Zth = Z(Z >= cluster_forming_thr);
579585
580586
"""
581-
script += "spm_write_filtered(Zth,XYZth,stat_map_vol.dim',stat_map_vol.mat,'thresholded map', '%s');\n" % self._gen_pre_topo_map_filename()
587+
script += (("spm_write_filtered(Zth,XYZth,stat_map_vol.dim',"
588+
"stat_map_vol.mat,'thresholded map', '%s');\n")
589+
% self._gen_pre_topo_map_filename())
582590
script += """
583591
max_size = 0;
584592
max_size_index = 0;
@@ -590,7 +598,8 @@ def _make_matlab_command(self, _):
590598
else
591599
if use_topo_fdr
592600
V2R = 1/prod(FWHM(stat_map_vol.dim > 1));
593-
[uc,Pc,ue] = spm_uc_clusterFDR(cluster_extent_p_fdr_thr,df,STAT,R,n,Z,XYZ,V2R,cluster_forming_thr);
601+
[uc,Pc,ue] = spm_uc_clusterFDR(cluster_extent_p_fdr_thr,df,\
602+
STAT,R,n,Z,XYZ,V2R,cluster_forming_thr);
594603
end
595604
596605
voxel_labels = spm_clusters(XYZth);
@@ -601,8 +610,10 @@ def _make_matlab_command(self, _):
601610
602611
for i = 1:nclusters
603612
cluster_size = sum(voxel_labels==i);
604-
if cluster_size > extent_threshold && (~use_topo_fdr || (cluster_size - uc) > -1)
605-
thresholded_XYZ = cat(2, thresholded_XYZ, XYZth(:,voxel_labels == i));
613+
if cluster_size > extent_threshold && (~use_topo_fdr || \
614+
(cluster_size - uc) > -1)
615+
thresholded_XYZ = cat(2, thresholded_XYZ, \
616+
XYZth(:,voxel_labels == i));
606617
thresholded_Z = cat(2, thresholded_Z, Zth(voxel_labels == i));
607618
th_nclusters = th_nclusters + 1;
608619
end
@@ -636,13 +647,16 @@ def _make_matlab_command(self, _):
636647
fprintf('cluster_forming_thr = %f\\n',cluster_forming_thr);
637648
638649
"""
639-
script += "spm_write_filtered(thresholded_Z,thresholded_XYZ,stat_map_vol.dim',stat_map_vol.mat,'thresholded map', '%s');\n" % self._gen_thresholded_map_filename()
650+
script += (("spm_write_filtered(thresholded_Z,thresholded_XYZ,"
651+
"stat_map_vol.dim',stat_map_vol.mat,'thresholded map',"
652+
" '%s');\n") % self._gen_thresholded_map_filename())
640653

641654
return script
642655

643656
def aggregate_outputs(self, runtime=None):
644657
outputs = self._outputs()
645-
setattr(outputs, 'thresholded_map', self._gen_thresholded_map_filename())
658+
setattr(outputs, 'thresholded_map',
659+
self._gen_thresholded_map_filename())
646660
setattr(outputs, 'pre_topo_fdr_map', self._gen_pre_topo_map_filename())
647661
for line in runtime.stdout.split('\n'):
648662
if line.startswith("activation_forced = "):
@@ -735,7 +749,8 @@ def _make_matlab_command(self, _):
735749
voxelwise_P_uncor = (1-spm_Ncdf(cluster_forming_thr)).^n
736750
case 'T'
737751
VPs = (1 - spm_Tcdf(Zum,df(2))).^n;
738-
voxelwise_P_uncor = (1 - spm_Tcdf(cluster_forming_thr,df(2))).^n
752+
voxelwise_P_uncor = \
753+
(1 - spm_Tcdf(cluster_forming_thr,df(2))).^n
739754
case 'X'
740755
VPs = (1-spm_Xcdf(Zum,df(2))).^n;
741756
voxelwise_P_uncor = (1-spm_Xcdf(cluster_forming_thr,df(2))).^n
@@ -749,14 +764,17 @@ def _make_matlab_command(self, _):
749764
750765
V2R = 1/prod(FWHM(stat_map_vol.dim > 1));
751766
752-
clusterwise_P_RF = spm_P_RF(1,extent_threshold*V2R,cluster_forming_thr,df,STAT,R,n)
767+
clusterwise_P_RF = \
768+
spm_P_RF(1,extent_threshold*V2R,cluster_forming_thr,df,STAT,R,n)
753769
754770
[x,y,z] = ind2sub(size(stat_map_data),(1:numel(stat_map_data))');
755771
XYZ = cat(1, x', y', z');
756772
757-
[u, CPs, ue] = spm_uc_clusterFDR(0.05,df,STAT,R,n,Z,XYZ,V2R,cluster_forming_thr);
773+
[u, CPs, ue] = \
774+
spm_uc_clusterFDR(0.05,df,STAT,R,n,Z,XYZ,V2R,cluster_forming_thr);
758775
759-
clusterwise_P_FDR = spm_P_clusterFDR(extent_threshold*V2R,df,STAT,R,n,cluster_forming_thr,CPs')
776+
clusterwise_P_FDR = \
777+
spm_P_clusterFDR(extent_threshold*V2R,df,STAT,R,n,cluster_forming_thr,CPs')
760778
"""
761779
return script
762780

@@ -962,7 +980,8 @@ class PairedTTestDesign(FactorialDesign):
962980
--------
963981
964982
>>> pttest = PairedTTestDesign()
965-
>>> pttest.inputs.paired_files = [['cont1.nii','cont1a.nii'],['cont2.nii','cont2a.nii']]
983+
>>> pttest.inputs.paired_files = [['cont1.nii','cont1a.nii'],\
984+
['cont2.nii','cont2a.nii']]
966985
>>> pttest.run() # doctest: +SKIP
967986
"""
968987

0 commit comments

Comments
 (0)