1
1
# -*- 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 )
3
4
from builtins import str , bytes
4
5
5
6
import os .path as op
6
7
import glob
7
8
8
9
from ... import logging
9
10
from ...utils .filemanip import simplify_list
10
- from ..base import traits , File , Directory , TraitedSpec , OutputMultiPath
11
+ from ..base import ( traits , File , Directory , TraitedSpec , OutputMultiPath )
11
12
from ..freesurfer .base import FSCommand , FSTraitedSpec
12
13
13
- iflogger = logging .getLogger (" nipype.interface" )
14
+ iflogger = logging .getLogger (' nipype.interface' )
14
15
15
16
16
17
class WatershedBEMInputSpec (FSTraitedSpec ):
17
18
subject_id = traits .Str (
18
- argstr = " --subject %s" ,
19
+ argstr = ' --subject %s' ,
19
20
mandatory = True ,
20
- desc = "Subject ID (must have a complete Freesurfer directory)" ,
21
- )
21
+ desc = 'Subject ID (must have a complete Freesurfer directory)' )
22
22
subjects_dir = Directory (
23
23
exists = True ,
24
24
mandatory = True ,
25
25
usedefault = True ,
26
- desc = "Path to Freesurfer subjects directory" ,
27
- )
26
+ desc = 'Path to Freesurfer subjects directory' )
28
27
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' ,
37
36
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)' )
40
38
overwrite = traits .Bool (
41
39
True ,
42
40
usedefault = True ,
43
- argstr = "--overwrite" ,
44
- desc = "Overwrites the existing files" ,
45
- )
41
+ argstr = '--overwrite' ,
42
+ desc = 'Overwrites the existing files' )
46
43
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)' )
50
46
51
47
52
48
class WatershedBEMOutputSpec (TraitedSpec ):
53
49
mesh_files = OutputMultiPath (
54
50
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)' ))
60
53
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)' )
63
57
inner_skull_surface = File (
64
58
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)' )
68
61
outer_skull_surface = File (
69
62
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)' )
73
65
outer_skin_surface = File (
74
66
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)' )
78
69
fif_file = File (
79
70
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' )
84
74
cor_files = OutputMultiPath (
85
75
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' )
90
79
91
80
92
81
class WatershedBEM (FSCommand ):
@@ -100,23 +89,23 @@ class WatershedBEM(FSCommand):
100
89
>>> bem.inputs.subject_id = 'subj1'
101
90
>>> bem.inputs.subjects_dir = '.'
102
91
>>> bem.cmdline
103
- 'mne watershed_bem --overwrite --subject subj1 --volume T1'
92
+ 'mne_watershed_bem --overwrite --subject subj1 --volume T1'
104
93
>>> bem.run() # doctest: +SKIP
105
94
106
95
"""
107
96
108
- _cmd = "mne watershed_bem"
97
+ _cmd = 'mne_watershed_bem'
109
98
input_spec = WatershedBEMInputSpec
110
99
output_spec = WatershedBEMOutputSpec
111
- _additional_metadata = [" loc" , " altkey" ]
100
+ _additional_metadata = [' loc' , ' altkey' ]
112
101
113
102
def _get_files (self , path , key , dirval , altkey = None ):
114
- globsuffix = "*"
115
- globprefix = "*"
103
+ globsuffix = '*'
104
+ globprefix = '*'
116
105
keydir = op .join (path , dirval )
117
106
if altkey :
118
107
key = altkey
119
- globpattern = op .join (keydir , "" .join ((globprefix , key , globsuffix )))
108
+ globpattern = op .join (keydir , '' .join ((globprefix , key , globsuffix )))
120
109
return glob .glob (globpattern )
121
110
122
111
def _list_outputs (self ):
@@ -126,13 +115,10 @@ def _list_outputs(self):
126
115
output_traits = self ._outputs ()
127
116
mesh_paths = []
128
117
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 )
136
122
if val :
137
123
value_list = simplify_list (val )
138
124
if isinstance (value_list , list ):
@@ -144,7 +130,7 @@ def _list_outputs(self):
144
130
else :
145
131
raise TypeError
146
132
outputs [k ] = out_files
147
- if not k .rfind (" surface" ) == - 1 :
133
+ if not k .rfind (' surface' ) == - 1 :
148
134
mesh_paths .append (out_files )
149
- outputs [" mesh_files" ] = mesh_paths
135
+ outputs [' mesh_files' ] = mesh_paths
150
136
return outputs
0 commit comments