11# -*- coding: utf-8 -*-
2- from __future__ import print_function , division , unicode_literals , absolute_import
2+ from __future__ import (print_function , division , unicode_literals ,
3+ absolute_import )
34from builtins import str , bytes
45
56import os .path as op
67import glob
78
89from ... import logging
910from ...utils .filemanip import simplify_list
10- from ..base import traits , File , Directory , TraitedSpec , OutputMultiPath
11+ from ..base import ( traits , File , Directory , TraitedSpec , OutputMultiPath )
1112from ..freesurfer .base import FSCommand , FSTraitedSpec
1213
13- iflogger = logging .getLogger (" nipype.interface" )
14+ iflogger = logging .getLogger (' nipype.interface' )
1415
1516
1617class WatershedBEMInputSpec (FSTraitedSpec ):
1718 subject_id = traits .Str (
18- argstr = " --subject %s" ,
19+ argstr = ' --subject %s' ,
1920 mandatory = True ,
20- desc = "Subject ID (must have a complete Freesurfer directory)" ,
21- )
21+ desc = 'Subject ID (must have a complete Freesurfer directory)' )
2222 subjects_dir = Directory (
2323 exists = True ,
2424 mandatory = True ,
2525 usedefault = True ,
26- desc = "Path to Freesurfer subjects directory" ,
27- )
26+ desc = 'Path to Freesurfer subjects directory' )
2827 volume = traits .Enum (
29- "T1" ,
30- " aparc+aseg" ,
31- " aseg" ,
32- " brain" ,
33- " orig" ,
34- " brainmask" ,
35- " ribbon" ,
36- argstr = " --volume %s" ,
28+ 'T1' ,
29+ ' aparc+aseg' ,
30+ ' aseg' ,
31+ ' brain' ,
32+ ' orig' ,
33+ ' brainmask' ,
34+ ' ribbon' ,
35+ argstr = ' --volume %s' ,
3736 usedefault = True ,
38- desc = 'The volume from the "mri" directory to use (defaults to T1)' ,
39- )
37+ desc = 'The volume from the "mri" directory to use (defaults to T1)' )
4038 overwrite = traits .Bool (
4139 True ,
4240 usedefault = True ,
43- argstr = "--overwrite" ,
44- desc = "Overwrites the existing files" ,
45- )
41+ argstr = '--overwrite' ,
42+ desc = 'Overwrites the existing files' )
4643 atlas_mode = traits .Bool (
47- argstr = "--atlas" ,
48- desc = "Use atlas mode for registration (default: no rigid alignment)" ,
49- )
44+ argstr = '--atlas' ,
45+ desc = 'Use atlas mode for registration (default: no rigid alignment)' )
5046
5147
5248class WatershedBEMOutputSpec (TraitedSpec ):
5349 mesh_files = OutputMultiPath (
5450 File (exists = True ),
55- desc = (
56- "Paths to the output meshes (brain, inner "
57- "skull, outer skull, outer skin)"
58- ),
59- )
51+ desc = ('Paths to the output meshes (brain, inner '
52+ 'skull, outer skull, outer skin)' ))
6053 brain_surface = File (
61- exists = True , loc = "bem/watershed" , desc = "Brain surface (in Freesurfer format)"
62- )
54+ exists = True ,
55+ loc = 'bem/watershed' ,
56+ desc = 'Brain surface (in Freesurfer format)' )
6357 inner_skull_surface = File (
6458 exists = True ,
65- loc = "bem/watershed" ,
66- desc = "Inner skull surface (in Freesurfer format)" ,
67- )
59+ loc = 'bem/watershed' ,
60+ desc = 'Inner skull surface (in Freesurfer format)' )
6861 outer_skull_surface = File (
6962 exists = True ,
70- loc = "bem/watershed" ,
71- desc = "Outer skull surface (in Freesurfer format)" ,
72- )
63+ loc = 'bem/watershed' ,
64+ desc = 'Outer skull surface (in Freesurfer format)' )
7365 outer_skin_surface = File (
7466 exists = True ,
75- loc = "bem/watershed" ,
76- desc = "Outer skin surface (in Freesurfer format)" ,
77- )
67+ loc = 'bem/watershed' ,
68+ desc = 'Outer skin surface (in Freesurfer format)' )
7869 fif_file = File (
7970 exists = True ,
80- loc = "bem" ,
81- altkey = "fif" ,
82- desc = '"fif" format file for EEG processing in MNE' ,
83- )
71+ loc = 'bem' ,
72+ altkey = 'fif' ,
73+ desc = '"fif" format file for EEG processing in MNE' )
8474 cor_files = OutputMultiPath (
8575 File (exists = True ),
86- loc = "bem/watershed/ws" ,
87- altkey = "COR" ,
88- desc = '"COR" format files' ,
89- )
76+ loc = 'bem/watershed/ws' ,
77+ altkey = 'COR' ,
78+ desc = '"COR" format files' )
9079
9180
9281class WatershedBEM (FSCommand ):
@@ -100,23 +89,23 @@ class WatershedBEM(FSCommand):
10089 >>> bem.inputs.subject_id = 'subj1'
10190 >>> bem.inputs.subjects_dir = '.'
10291 >>> bem.cmdline
103- 'mne watershed_bem --overwrite --subject subj1 --volume T1'
92+ 'mne_watershed_bem --overwrite --subject subj1 --volume T1'
10493 >>> bem.run() # doctest: +SKIP
10594
10695 """
10796
108- _cmd = "mne watershed_bem"
97+ _cmd = 'mne_watershed_bem'
10998 input_spec = WatershedBEMInputSpec
11099 output_spec = WatershedBEMOutputSpec
111- _additional_metadata = [" loc" , " altkey" ]
100+ _additional_metadata = [' loc' , ' altkey' ]
112101
113102 def _get_files (self , path , key , dirval , altkey = None ):
114- globsuffix = "*"
115- globprefix = "*"
103+ globsuffix = '*'
104+ globprefix = '*'
116105 keydir = op .join (path , dirval )
117106 if altkey :
118107 key = altkey
119- globpattern = op .join (keydir , "" .join ((globprefix , key , globsuffix )))
108+ globpattern = op .join (keydir , '' .join ((globprefix , key , globsuffix )))
120109 return glob .glob (globpattern )
121110
122111 def _list_outputs (self ):
@@ -126,13 +115,10 @@ def _list_outputs(self):
126115 output_traits = self ._outputs ()
127116 mesh_paths = []
128117 for k in list (outputs .keys ()):
129- if k != "mesh_files" :
130- val = self ._get_files (
131- subject_path ,
132- k ,
133- output_traits .traits ()[k ].loc ,
134- output_traits .traits ()[k ].altkey ,
135- )
118+ if k != 'mesh_files' :
119+ val = self ._get_files (subject_path , k ,
120+ output_traits .traits ()[k ].loc ,
121+ output_traits .traits ()[k ].altkey )
136122 if val :
137123 value_list = simplify_list (val )
138124 if isinstance (value_list , list ):
@@ -144,7 +130,7 @@ def _list_outputs(self):
144130 else :
145131 raise TypeError
146132 outputs [k ] = out_files
147- if not k .rfind (" surface" ) == - 1 :
133+ if not k .rfind (' surface' ) == - 1 :
148134 mesh_paths .append (out_files )
149- outputs [" mesh_files" ] = mesh_paths
135+ outputs [' mesh_files' ] = mesh_paths
150136 return outputs
0 commit comments