19
19
20
20
from ...utils .misc import package_check
21
21
from ...utils .filemanip import fname_presuffix
22
- from ..base import (TraitedSpec , File , Undefined , traits , BaseInterface ,
22
+ from .base import NitimeBaseInterface
23
+ from ..base import (TraitedSpec , File , Undefined , traits ,
23
24
isdefined , BaseInterfaceInputSpec )
24
25
25
26
have_nitime = True
26
27
try :
27
28
package_check ('nitime' )
28
- except Exception as e :
29
+ except ImportError :
29
30
have_nitime = False
30
- else :
31
- import nitime .analysis as nta
32
- from nitime .timeseries import TimeSeries
33
- import nitime .viz as viz
34
31
35
32
36
33
class CoherenceAnalyzerInputSpec (BaseInterfaceInputSpec ):
@@ -116,7 +113,7 @@ class CoherenceAnalyzerOutputSpec(TraitedSpec):
116
113
timedelay_fig = File (desc = ('Figure representing coherence values' ))
117
114
118
115
119
- class CoherenceAnalyzer (BaseInterface ):
116
+ class CoherenceAnalyzer (NitimeBaseInterface ):
120
117
121
118
input_spec = CoherenceAnalyzerInputSpec
122
119
output_spec = CoherenceAnalyzerOutputSpec
@@ -148,6 +145,7 @@ def _read_csv(self):
148
145
149
146
def _csv2ts (self ):
150
147
""" Read data from the in_file and generate a nitime TimeSeries object"""
148
+ from nitime .timeseries import TimeSeries
151
149
data , roi_names = self ._read_csv ()
152
150
153
151
TS = TimeSeries (
@@ -159,6 +157,7 @@ def _csv2ts(self):
159
157
160
158
# Rewrite _run_interface, but not run
161
159
def _run_interface (self , runtime ):
160
+ import nitime .analysis as nta
162
161
lb , ub = self .inputs .frequency_range
163
162
164
163
if self .inputs .in_TS is Undefined :
@@ -253,6 +252,7 @@ def _make_output_figures(self):
253
252
self.inputs.output_figure_file
254
253
255
254
"""
255
+ import nitime .viz as viz
256
256
if self .inputs .figure_type == 'matrix' :
257
257
fig_coh = viz .drawmatrix_channels (
258
258
self .coherence , channel_names = self .ROIs , color_anchor = 0 )
@@ -281,16 +281,3 @@ def _make_output_figures(self):
281
281
fig_dt .savefig (
282
282
fname_presuffix (
283
283
self .inputs .output_figure_file , suffix = '_delay' ))
284
-
285
-
286
- class GetTimeSeriesInputSpec (object ):
287
- pass
288
-
289
-
290
- class GetTimeSeriesOutputSpec (object ):
291
- pass
292
-
293
-
294
- class GetTimeSeries (object ):
295
- # getting time series data from nifti files and ROIs
296
- pass
0 commit comments