1
1
# -*- coding: utf-8 -*-
2
- from __future__ import (print_function , division , unicode_literals ,
3
- absolute_import )
2
+ from __future__ import print_function , division , unicode_literals , absolute_import
4
3
from builtins import str , bytes
5
4
6
5
import os .path as op
7
6
import glob
8
7
9
8
from ... import logging
10
9
from ...utils .filemanip import simplify_list
11
- from ..base import ( traits , File , Directory , TraitedSpec , OutputMultiPath )
10
+ from ..base import traits , File , Directory , TraitedSpec , OutputMultiPath
12
11
from ..freesurfer .base import FSCommand , FSTraitedSpec
13
12
14
- iflogger = logging .getLogger (' nipype.interface' )
13
+ iflogger = logging .getLogger (" nipype.interface" )
15
14
16
15
17
16
class WatershedBEMInputSpec (FSTraitedSpec ):
18
17
subject_id = traits .Str (
19
- argstr = ' --subject %s' ,
18
+ argstr = " --subject %s" ,
20
19
mandatory = True ,
21
- desc = 'Subject ID (must have a complete Freesurfer directory)' )
20
+ desc = "Subject ID (must have a complete Freesurfer directory)" ,
21
+ )
22
22
subjects_dir = Directory (
23
23
exists = True ,
24
24
mandatory = True ,
25
25
usedefault = True ,
26
- desc = 'Path to Freesurfer subjects directory' )
26
+ desc = "Path to Freesurfer subjects directory" ,
27
+ )
27
28
volume = traits .Enum (
28
- 'T1' ,
29
- ' aparc+aseg' ,
30
- ' aseg' ,
31
- ' brain' ,
32
- ' orig' ,
33
- ' brainmask' ,
34
- ' ribbon' ,
35
- argstr = ' --volume %s' ,
29
+ "T1" ,
30
+ " aparc+aseg" ,
31
+ " aseg" ,
32
+ " brain" ,
33
+ " orig" ,
34
+ " brainmask" ,
35
+ " ribbon" ,
36
+ argstr = " --volume %s" ,
36
37
usedefault = True ,
37
- desc = 'The volume from the "mri" directory to use (defaults to T1)' )
38
+ desc = 'The volume from the "mri" directory to use (defaults to T1)' ,
39
+ )
38
40
overwrite = traits .Bool (
39
41
True ,
40
42
usedefault = True ,
41
- argstr = '--overwrite' ,
42
- desc = 'Overwrites the existing files' )
43
+ argstr = "--overwrite" ,
44
+ desc = "Overwrites the existing files" ,
45
+ )
43
46
atlas_mode = traits .Bool (
44
- argstr = '--atlas' ,
45
- desc = 'Use atlas mode for registration (default: no rigid alignment)' )
47
+ argstr = "--atlas" ,
48
+ desc = "Use atlas mode for registration (default: no rigid alignment)" ,
49
+ )
46
50
47
51
48
52
class WatershedBEMOutputSpec (TraitedSpec ):
49
53
mesh_files = OutputMultiPath (
50
54
File (exists = True ),
51
- desc = ('Paths to the output meshes (brain, inner '
52
- 'skull, outer skull, outer skin)' ))
55
+ desc = (
56
+ "Paths to the output meshes (brain, inner "
57
+ "skull, outer skull, outer skin)"
58
+ ),
59
+ )
53
60
brain_surface = File (
54
- exists = True ,
55
- loc = 'bem/watershed' ,
56
- desc = 'Brain surface (in Freesurfer format)' )
61
+ exists = True , loc = "bem/watershed" , desc = "Brain surface (in Freesurfer format)"
62
+ )
57
63
inner_skull_surface = File (
58
64
exists = True ,
59
- loc = 'bem/watershed' ,
60
- desc = 'Inner skull surface (in Freesurfer format)' )
65
+ loc = "bem/watershed" ,
66
+ desc = "Inner skull surface (in Freesurfer format)" ,
67
+ )
61
68
outer_skull_surface = File (
62
69
exists = True ,
63
- loc = 'bem/watershed' ,
64
- desc = 'Outer skull surface (in Freesurfer format)' )
70
+ loc = "bem/watershed" ,
71
+ desc = "Outer skull surface (in Freesurfer format)" ,
72
+ )
65
73
outer_skin_surface = File (
66
74
exists = True ,
67
- loc = 'bem/watershed' ,
68
- desc = 'Outer skin surface (in Freesurfer format)' )
75
+ loc = "bem/watershed" ,
76
+ desc = "Outer skin surface (in Freesurfer format)" ,
77
+ )
69
78
fif_file = File (
70
79
exists = True ,
71
- loc = 'bem' ,
72
- altkey = 'fif' ,
73
- desc = '"fif" format file for EEG processing in MNE' )
80
+ loc = "bem" ,
81
+ altkey = "fif" ,
82
+ desc = '"fif" format file for EEG processing in MNE' ,
83
+ )
74
84
cor_files = OutputMultiPath (
75
85
File (exists = True ),
76
- loc = 'bem/watershed/ws' ,
77
- altkey = 'COR' ,
78
- desc = '"COR" format files' )
86
+ loc = "bem/watershed/ws" ,
87
+ altkey = "COR" ,
88
+ desc = '"COR" format files' ,
89
+ )
79
90
80
91
81
92
class WatershedBEM (FSCommand ):
@@ -89,23 +100,23 @@ class WatershedBEM(FSCommand):
89
100
>>> bem.inputs.subject_id = 'subj1'
90
101
>>> bem.inputs.subjects_dir = '.'
91
102
>>> bem.cmdline
92
- 'mne_watershed_bem --overwrite --subject subj1 --volume T1'
103
+ 'mne watershed_bem --overwrite --subject subj1 --volume T1'
93
104
>>> bem.run() # doctest: +SKIP
94
105
95
106
"""
96
107
97
- _cmd = 'mne_watershed_bem'
108
+ _cmd = "mne watershed_bem"
98
109
input_spec = WatershedBEMInputSpec
99
110
output_spec = WatershedBEMOutputSpec
100
- _additional_metadata = [' loc' , ' altkey' ]
111
+ _additional_metadata = [" loc" , " altkey" ]
101
112
102
113
def _get_files (self , path , key , dirval , altkey = None ):
103
- globsuffix = '*'
104
- globprefix = '*'
114
+ globsuffix = "*"
115
+ globprefix = "*"
105
116
keydir = op .join (path , dirval )
106
117
if altkey :
107
118
key = altkey
108
- globpattern = op .join (keydir , '' .join ((globprefix , key , globsuffix )))
119
+ globpattern = op .join (keydir , "" .join ((globprefix , key , globsuffix )))
109
120
return glob .glob (globpattern )
110
121
111
122
def _list_outputs (self ):
@@ -115,10 +126,13 @@ def _list_outputs(self):
115
126
output_traits = self ._outputs ()
116
127
mesh_paths = []
117
128
for k in list (outputs .keys ()):
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 )
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
+ )
122
136
if val :
123
137
value_list = simplify_list (val )
124
138
if isinstance (value_list , list ):
@@ -130,7 +144,7 @@ def _list_outputs(self):
130
144
else :
131
145
raise TypeError
132
146
outputs [k ] = out_files
133
- if not k .rfind (' surface' ) == - 1 :
147
+ if not k .rfind (" surface" ) == - 1 :
134
148
mesh_paths .append (out_files )
135
- outputs [' mesh_files' ] = mesh_paths
149
+ outputs [" mesh_files" ] = mesh_paths
136
150
return outputs
0 commit comments