4
4
import pyqtgraph as pg
5
5
import pyqtgraph .opengl as gl
6
6
import pyqtgraph .exporters as pgexp
7
- from ecog . utils import bands as default_bands
8
- from ecog .signal_processing .preprocess_data import preprocess_data
7
+ from ecogvis . signal_processing import bands as default_bands
8
+ from ecogvis .signal_processing .preprocess_data import preprocess_data
9
9
from .FS_colorLUT import get_lut
10
10
from threading import Event , Thread
11
11
import numpy as np
12
12
from scipy import signal
13
13
import os
14
14
import time
15
15
16
- path = os .path .dirname (__file__ )
16
+ ui_path = os .path .join ( os . path . dirname (__file__ ), '..' , 'ui' )
17
17
18
18
# Creates custom interval type -------------------------------------------------
19
- Ui_CustomInterval , _ = uic .loadUiType (os .path .join (path ,"intervals_gui.ui" ))
19
+ Ui_CustomInterval , _ = uic .loadUiType (os .path .join (ui_path ,"intervals_gui.ui" ))
20
20
class CustomIntervalDialog (QtGui .QDialog , Ui_CustomInterval ):
21
21
def __init__ (self ):
22
22
super ().__init__ ()
@@ -143,7 +143,7 @@ def cancel(self):
143
143
144
144
145
145
# Exit confirmation ------------------------------------------------------------
146
- Ui_Exit , _ = uic .loadUiType (os .path .join (path ,"exit_gui.ui" ))
146
+ Ui_Exit , _ = uic .loadUiType (os .path .join (ui_path ,"exit_gui.ui" ))
147
147
class ExitDialog (QtGui .QDialog , Ui_Exit ):
148
148
def __init__ (self , parent ):
149
149
super ().__init__ ()
@@ -241,7 +241,7 @@ def unselect_all(self):
241
241
242
242
243
243
# Creates Spectral Analysis choice dialog --------------------------------------
244
- Ui_SpectralChoice , _ = uic .loadUiType (os .path .join (path ,"spectral_choice_gui.ui" ))
244
+ Ui_SpectralChoice , _ = uic .loadUiType (os .path .join (ui_path ,"spectral_choice_gui.ui" ))
245
245
class SpectralChoiceDialog (QtGui .QDialog , Ui_SpectralChoice ):
246
246
def __init__ (self , nwb , fpath , fname ):
247
247
super ().__init__ ()
@@ -252,7 +252,7 @@ def __init__(self, nwb, fpath, fname):
252
252
253
253
self .data_exists = False #Indicates if data already exists or will be created
254
254
self .decomp_type = None #Indicates the chosen decomposition type
255
- self .custom_bands = None #Values for custom filter bands (user input)
255
+ self .chosen_bands = None #Values for custom filter bands (user input)
256
256
self .value = - 1 #Reference value for user pressed exit button
257
257
258
258
self .radioButton_1 .clicked .connect (self .choice_default )
@@ -269,7 +269,6 @@ def __init__(self, nwb, fpath, fname):
269
269
270
270
def choice_default (self ): # default chosen
271
271
self .decomp_type = 'default'
272
- self .custom_bands = None
273
272
self .pushButton_1 .setEnabled (False )
274
273
self .pushButton_2 .setEnabled (False )
275
274
self .tableWidget .setEditTriggers (QtGui .QAbstractItemView .NoEditTriggers )
@@ -306,25 +305,15 @@ def choice_default(self): # default chosen
306
305
307
306
def choice_highgamma (self ): # default chosen
308
307
self .decomp_type = 'high_gamma'
309
- self .custom_bands = None
310
308
self .pushButton_1 .setEnabled (False )
311
309
self .pushButton_2 .setEnabled (False )
312
310
self .tableWidget .setEditTriggers (QtGui .QAbstractItemView .NoEditTriggers )
313
311
try : # if data already exists in file
314
312
decomp = self .nwb .modules ['ecephys' ].data_interfaces ['high_gamma' ]
315
- text = "'High gamma' frequency decomposition data already exists in current file.\n " \
316
- "It corresponds to the averaged power of the bands shown in the table."
313
+ text = "'High gamma' frequency decomposition data already exists in current file."
317
314
self .label_1 .setText (text )
318
315
self .data_exists = True
319
316
self .runButton .setEnabled (False )
320
- # Populate table with values
321
- self .tableWidget .setHorizontalHeaderLabels (['center [Hz]' ,'sigma [Hz]' ])
322
- p0 = default_bands .chang_lab ['cfs' ][29 :37 ]
323
- p1 = default_bands .chang_lab ['sds' ][29 :37 ]
324
- self .tableWidget .setRowCount (len (p0 ))
325
- for i in np .arange (len (p0 )):
326
- self .tableWidget .setItem (i , 0 , QTableWidgetItem (str (round (p0 [i ],1 ))))
327
- self .tableWidget .setItem (i , 1 , QTableWidgetItem (str (round (p1 [i ],1 ))))
328
317
except : # if data does not exist in file
329
318
text = "'High gamma' frequency decomposition data does not exist in current file.\n " \
330
319
"It can be created from the averaged power of the bands shown in the table. " \
@@ -340,11 +329,14 @@ def choice_highgamma(self): # default chosen
340
329
for i in np .arange (len (p0 )):
341
330
self .tableWidget .setItem (i , 0 , QTableWidgetItem (str (round (p0 [i ],1 ))))
342
331
self .tableWidget .setItem (i , 1 , QTableWidgetItem (str (round (p1 [i ],1 ))))
332
+ # Allows user to populate table with values
333
+ self .tableWidget .setEditTriggers (QtGui .QAbstractItemView .DoubleClicked )
334
+ self .pushButton_1 .setEnabled (True )
335
+ self .pushButton_2 .setEnabled (True )
343
336
344
337
345
338
def choice_custom (self ): # default chosen
346
339
self .decomp_type = 'custom'
347
- self .custom_bands = None
348
340
try : # if data already exists in file
349
341
decomp = self .nwb .modules ['ecephys' ].data_interfaces ['Bandpower_custom' ]
350
342
text = "'Custom' frequency decomposition data already exists in current file.\n " \
@@ -357,12 +349,9 @@ def choice_custom(self): # default chosen
357
349
p0 = decomp .bands ['filter_param_0' ]
358
350
p1 = decomp .bands ['filter_param_1' ]
359
351
self .tableWidget .setRowCount (len (p0 ))
360
- self .custom_bands = np .zeros ((2 ,len (p0 )))
361
352
for i in np .arange (len (p0 )):
362
353
self .tableWidget .setItem (i , 0 , QTableWidgetItem (str (round (p0 [i ],1 ))))
363
354
self .tableWidget .setItem (i , 1 , QTableWidgetItem (str (round (p1 [i ],1 ))))
364
- self .custom_bands [i ,0 ] = round (p0 [i ],1 )
365
- self .custom_bands [i ,1 ] = round (p1 [i ],1 )
366
355
except : # if data does not exist in file
367
356
text = "'Custom' frequency decomposition data does not exist in current file.\n " \
368
357
"To create it, add the bands of interest to the table. " \
@@ -390,12 +379,12 @@ def del_band(self):
390
379
self .tableWidget .removeRow (nRows - 1 )
391
380
392
381
def run_decomposition (self ):
393
- if self .decomp_type == 'custom ' :
382
+ if self .decomp_type != 'default ' :
394
383
nRows = self .tableWidget .rowCount ()
395
- self .custom_bands = np .zeros ((2 ,nRows ))
384
+ self .chosen_bands = np .zeros ((2 ,nRows ))
396
385
for i in np .arange (nRows ):
397
- self .custom_bands [0 ,i ] = float (self .tableWidget .item (i , 0 ).text ())
398
- self .custom_bands [1 ,i ] = float (self .tableWidget .item (i , 1 ).text ())
386
+ self .chosen_bands [0 ,i ] = float (self .tableWidget .item (i , 0 ).text ())
387
+ self .chosen_bands [1 ,i ] = float (self .tableWidget .item (i , 1 ).text ())
399
388
# If Decomposition data does not exist in NWB file and user decides to create it
400
389
self .label_2 .setText ('Processing spectral decomposition. Please wait...' )
401
390
self .pushButton_1 .setEnabled (False )
@@ -409,7 +398,7 @@ def run_decomposition(self):
409
398
block = [ aux .split ('.' )[0 ][1 :] ]
410
399
self .thread = ChildProgram (path = self .fpath , subject = subj ,
411
400
blocks = block , filter = self .decomp_type ,
412
- bands_vals = self .custom_bands )
401
+ bands_vals = self .chosen_bands )
413
402
self .thread .finished .connect (self .out_close )
414
403
self .thread .start ()
415
404
0 commit comments