示例#1
0
文件: __init__.py 项目: nikolaims/nfb
 def __init__(self, app, **kwargs):
     super().__init__(**kwargs)
     self.app = app
     v_layout = QtWidgets.QVBoxLayout()
     layout = QtWidgets.QHBoxLayout()
     self.params = xml_file_to_params()
     self.general_settings = GeneralSettingsWidget(parent=self)
     v_layout.addWidget(self.general_settings)
     v_layout.addLayout(layout)
     self.protocols_list = ProtocolsSettingsWidget(parent=self)
     self.signals_list = SignalsSettingsWidget(parent=self)
     self.composite_signals_list = CompositeSignalsSettingsWidget(parent=self)
     self.protocol_groups_list = ProtocolGroupsSettingsWidget(parent=self)
     self.protocols_sequence_list = ProtocolSequenceSettingsWidget(parent=self)
     # layout.addWidget(self.general_settings)
     layout.addWidget(self.signals_list)
     layout.addWidget(self.composite_signals_list)
     layout.addWidget(self.protocols_list)
     layout.addWidget(self.protocol_groups_list)
     layout.addWidget(self.protocols_sequence_list)
     start_button = QtWidgets.QPushButton('Start')
     start_button.setIcon(QtGui.QIcon(static_path + '/imag/power-button.png'))
     start_button.setMinimumHeight(50)
     start_button.setMinimumWidth(300)
     start_button.clicked.connect(self.onClicked)
     name_layout = QtWidgets.QHBoxLayout()
     v_layout.addWidget(start_button, alignment=QtCore.Qt.AlignCenter)
     self.setLayout(v_layout)
示例#2
0
def restore_online_signal(h5_dataset,
                          signal_name,
                          band=None,
                          spatial_filter=None,
                          smoothing_factor=0.999):
    df, fs, channels, p_names = load_data(h5_dataset)
    n_channels = len(channels)

    with h5py.File(h5_dataset) as f:
        last_block = len(df.block_number.unique())
        if spatial_filter is None:
            spatial_filter = f['protocol{}/signals_stats/Signal/spatial_filter'
                               .format(last_block)][:]
        if band is None:
            band = f['protocol{}/signals_stats/Signal/bandpass'.format(
                last_block)][:]

    xml_settings = load_xml_str_from_hdf5_dataset(h5_dataset, 'settings.xml')
    params = xml_file_to_params(xml_settings)
    signals_params_list = params['vSignals']['DerivedSignal']
    signals_names = [s['sSignalName'] for s in signals_params_list]
    signal = signals_params_list[signals_names.index(signal_name)]

    signal['fBandpassLowHz'], signal['fBandpassHighHz'] = band
    signal['sTemporalFilterType'] = 'butter'
    signal['fSmoothingFactor'] = smoothing_factor
    signal = DerivedSignal.from_params(0, fs, n_channels, channels, signal,
                                       spatial_filter)

    time_series = signal.update(df[channels].values)
    return signal, time_series
示例#3
0
 def __init__(self, app, **kwargs):
     super().__init__(**kwargs)
     self.app = app
     v_layout = QtWidgets.QVBoxLayout()
     layout = QtWidgets.QHBoxLayout()
     self.params = xml_file_to_params()
     self.general_settings = GeneralSettingsWidget(parent=self)
     v_layout.addWidget(self.general_settings)
     v_layout.addLayout(layout)
     self.protocols_list = ProtocolsSettingsWidget(parent=self)
     self.signals_list = SignalsSettingsWidget(parent=self)
     self.composite_signals_list = CompositeSignalsSettingsWidget(
         parent=self)
     self.protocol_groups_list = ProtocolGroupsSettingsWidget(parent=self)
     self.protocols_sequence_list = ProtocolSequenceSettingsWidget(
         parent=self)
     # layout.addWidget(self.general_settings)
     layout.addWidget(self.signals_list)
     layout.addWidget(self.composite_signals_list)
     layout.addWidget(self.protocols_list)
     layout.addWidget(self.protocol_groups_list)
     layout.addWidget(self.protocols_sequence_list)
     start_button = QtWidgets.QPushButton('Start')
     start_button.setIcon(
         QtGui.QIcon(static_path + '/imag/power-button.png'))
     start_button.setMinimumHeight(50)
     start_button.setMinimumWidth(300)
     start_button.clicked.connect(self.onClicked)
     name_layout = QtWidgets.QHBoxLayout()
     v_layout.addWidget(start_button, alignment=QtCore.Qt.AlignCenter)
     self.setLayout(v_layout)
示例#4
0
def restore_online_signal(h5_dataset, signal_name, band=None, spatial_filter=None, smoothing_factor=0.999):
    df, fs, channels, p_names = load_data(h5_dataset)
    n_channels = len(channels)

    with h5py.File(h5_dataset) as f:
        last_block = len(df.block_number.unique())
        if spatial_filter is None:
            spatial_filter = f['protocol{}/signals_stats/Signal/spatial_filter'.format(last_block)][:]
        if band is None:
            band = f['protocol{}/signals_stats/Signal/bandpass'.format(last_block)][:]

    xml_settings = load_xml_str_from_hdf5_dataset(h5_dataset, 'settings.xml')
    params = xml_file_to_params(xml_settings)
    signals_params_list = params['vSignals']['DerivedSignal']
    signals_names = [s['sSignalName'] for s in signals_params_list]
    signal = signals_params_list[signals_names.index(signal_name)]

    signal['fBandpassLowHz'], signal['fBandpassHighHz'] = band
    signal['sTemporalFilterType'] = 'butter'
    signal['fSmoothingFactor'] = smoothing_factor
    signal = DerivedSignal.from_params(0, fs, n_channels, channels, signal, spatial_filter)

    time_series = signal.update(df[channels].values)
    return signal, time_series
示例#5
0
def main():

    app = QtWidgets.QApplication(sys.argv)
    experiment = Experiment(app, xml_file_to_params('bci_default.xml'))
    sys.exit(app.exec_())
示例#6
0
# parse arguments
parser = argparse.ArgumentParser()
parser.add_argument('--nfblab')
parser.add_argument('--design')
args = parser.parse_args()

# validate arguments
if args.design is None or args.nfblab is None:
    raise SyntaxError('\nPlease provide all arguments: '
                      '\n\t --nfblab Path to nfb directory'
                      '\n\t --design Path to design file')

if not os.path.isfile(args.design):
    raise FileNotFoundError('No such design file {}. Please, correct --design value.'.format(args.design))

if not os.path.isdir(args.nfblab):
    raise FileNotFoundError("Path to nfblab doesn't exist. Please, correct --nfblab value.")

sys.path.insert(0, args.nfblab)
if importlib.util.find_spec('pynfb') is None:
    raise ImportError('Cannot import nfblab package. Please, correct --nfblab value')

# import NFBLab
from pynfb.experiment import Experiment
from pynfb.serializers.xml_ import xml_file_to_params

# run experiment
app = QtWidgets.QApplication(sys.argv)
experiment = Experiment(app, xml_file_to_params(args.design))
sys.exit(app.exec_())
示例#7
0
def main():

    app = QtWidgets.QApplication(sys.argv)
    experiment = Experiment(app, xml_file_to_params('bci_default.xml'))
    sys.exit(app.exec_())
示例#8
0
args = parser.parse_args()

# validate arguments
if args.design is None or args.nfblab is None:
    raise SyntaxError('\nPlease provide all arguments: '
                      '\n\t --nfblab Path to nfb directory'
                      '\n\t --design Path to design file')

if not os.path.isfile(args.design):
    raise FileNotFoundError(
        'No such design file {}. Please, correct --design value.'.format(
            args.design))

if not os.path.isdir(args.nfblab):
    raise FileNotFoundError(
        "Path to nfblab doesn't exist. Please, correct --nfblab value.")

sys.path.insert(0, args.nfblab)
if importlib.util.find_spec('pynfb') is None:
    raise ImportError(
        'Cannot import nfblab package. Please, correct --nfblab value')

# import NFBLab
from pynfb.experiment import Experiment
from pynfb.serializers.xml_ import xml_file_to_params

# run experiment
app = QtWidgets.QApplication(sys.argv)
experiment = Experiment(app, xml_file_to_params(args.design))
sys.exit(app.exec_())