示例#1
0
def test_widget_traces_gotoepoch(qtbot):

    w = MainWindow()
    w.show()
    w.info.open_dataset(str(gui_file))
    channel_make_group(w)
    w.channels.button_apply.click()

    menubar = w.menuBar()

    act_navigation = find_in_qt(menubar, QAction, 'Navigation')
    menubar.setActiveAction(act_navigation)
    act_navigation.menu().setActiveAction(w.traces.action['go_to_epoch'])

    screenshot(w, 'traces_01_gotoepoch.png')
    w.close()

    w.traces.go_to_epoch(test_text_str='xxx')
    assert w.statusBar().currentMessage() == 'Input can only contain digits and colons'

    w.traces.go_to_epoch(test_text_str='1130')
    assert w.value('window_start') == 1130

    w.traces.go_to_epoch(test_text_str='22:30')
    assert w.value('window_start') == 20400

    w.info.idx_start.setStyleSheet("background-color: red;")
    w.info.grab().save(str(GUI_PATH / 'traces_02_gotoepoch.png'))
    w.info.idx_start.setStyleSheet("")
示例#2
0
def test_widget_notes_remove_artf_evts(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    w.info.open_dataset(str(gui_file))
    channel_make_group(w)
    w.channels.button_apply.click()
    w.channels.new_group(test_name='eog')
    w.notes.update_notes(annot_psg_path)

    w.notes.new_eventtype(test_type_str='Artefact')
    w.notes.action['new_event'].setChecked(True)
    w.notes.add_event('Artefact', (1, 2), 'EEG Pz-Oz (scalp)')
    w.notes.add_event('Artefact', (3, 6), 'EEG Pz-Oz (scalp)')
    w.notes.add_event('Artefact', (7, 10), 'EEG Pz-Oz (scalp)')
    w.notes.add_event('Artefact', (14, 31), '')
    w.notes.add_event('Artefact', (70, 85), 'EEG Pz-Oz (scalp)')
    w.notes.add_event('Artefact', (87, 90), '')
    w.notes.add_event('Artefact', (90, 92), 'EEG Pz-Oz (scalp)')
    w.notes.add_event('Artefact', (105, 120), 'EEG Pz-Oz (scalp)')
    w.notes.add_event('Artefact', (125.0, 125.2), 'EEG Pz-Oz (scalp)')
    w.notes.add_event('Artefact', (132, 142), 'EEG Pz-Oz (scalp)')

    times = [(8, 15), (30, 50), (56, 100), (100, 111), (135, 140), (150, 160)]
    new_times = remove_artf_evts(times, w.notes.annot)

    assert new_times == [(10, 14), (31, 50), (56, 70), (85, 87), (92, 100),
                         (100, 105), (150, 160)]

    w.notes.delete_eventtype(test_type_str='Artefact')
    w.close()
示例#3
0
def test_widget_notes_mark_event(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    w.info.open_dataset(str(gui_file))
    channel_make_group(w)
    w.channels.button_apply.click()
    w.channels.new_group(test_name='eog')
    w.notes.update_notes(annot_psg_path)
    w.traces.Y_wider()
    w.traces.Y_wider()
    w.traces.action['cross_chan_mrk'].setChecked(True)
    w.traces.go_to_epoch(test_text_str='23:34:45')

    w.notes.new_eventtype(test_type_str='spindle')
    w.notes.action['new_event'].setChecked(True)
    w.notes.add_event('spindle', (24293.01, 24294.65), 'EEG Pz-Oz (scalp)')

    screenshot(w, 'notes_14_mark_event.png')

    w.notes.add_event('spindle', (24288.01, 24288.90), 'EEG Fpz-Cz (scalp)')
    w.notes.add_event('spindle', (24297.5, 24298.00), 'EEG Fpz-Cz (scalp)')

    screenshot(w, 'notes_20_mark_short_event.png')

    pos = w.traces.mapFromScene(QPointF(24294, 75))
    mouseclick = QMouseEvent(QEvent.MouseButtonPress, pos, Qt.LeftButton,
                             Qt.NoButton, Qt.NoModifier)
    w.traces.mousePressEvent(mouseclick)

    screenshot(w, 'notes_15_highlight_event.png')

    w.notes.delete_eventtype(test_type_str='spindle')
    w.close()
示例#4
0
def test_widget_exportsvg(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    w.show()
    w.info.open_dataset(str(gui_file))
    channel_make_group(w)
    w.channels.button_apply.click()

    menubar = w.menuBar()
    act_view = find_in_qt(menubar, QAction, 'View')
    menubar.setActiveAction(act_view)
    act_view.menu().setActiveAction(w.traces.action['export_svg'])

    screenshot(w, 'exportsvg_01.png')

    export_graphics(w, test=str(svg_file))  # without extension
    assert svg_file.with_suffix('.svg').exists()
    w.close()

    svg_d = SVGDialog(str(svg_file))
    svg_d.button_clicked(svg_d.idx_ok)
    svg_d.button_clicked(svg_d.idx_cancel)
    svg_d.grab().save(str(GUI_PATH / 'exportsvg_02.png'))
示例#5
0
def test_widget_notes_export_csv(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    menubar = w.menuBar()

    act_annot = find_in_qt(menubar, QAction, 'Annotations')
    menubar.setActiveAction(act_annot)
    act_annot.menu().setActiveAction(w.notes.action['export_to_csv'])

    screenshot(w, 'notes_06_export.png')
    w.close()
示例#6
0
def test_widget_analysis_event(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    w.info.open_dataset(str(gui_file))
    channel_make_group(w)
    w.channels.button_apply.click()
    w.notes.update_notes(annot_psg_path)
    w.traces.go_to_epoch(test_text_str='23:34:45')

    w.notes.delete_eventtype(test_type_str='spindle')
    w.notes.new_eventtype(test_type_str='spindle')
    w.notes.action['new_event'].setChecked(True)
    w.notes.add_event('spindle', (24293.01, 24294.65), 'EEG Pz-Oz (scalp)')
    w.notes.add_event('spindle', (24288.01, 24288.90), 'EEG Fpz-Cz (scalp)')
    w.notes.add_event('spindle', (24290.5, 24291.00), 'EEG Fpz-Cz (scalp)')

    w.notes.action['analyze']
    ad = w.analysis_dialog
    ad.update_evt_types()
    ad.update_groups()

    ad.filename = analysis_export_path
    ad.chunk['event'].setChecked(True)
    ad.idx_evt_type.setCurrentRow(1)
    ad.idx_chan.setCurrentRow(0)
    evt = ad.event
    evt['global']['count'].set_value(True)
    evt['global']['density'].set_value(True)
    evt['f1'].set_value(10)
    evt['f2'].set_value(16)
    evt['global']['all_local'].set_value(True)
    evt['sw']['avg_slope'].set_value(True)
    evt['sw']['max_slope'].set_value(True)
    ad.check_all_local()

    ad.button_clicked(ad.idx_ok)
    w.notes.delete_eventtype(test_type_str='spindle')
    w.close()

    evt_path = EXPORTED_PATH / (splitext(basename(analysis_export_path))[0] +
                                '_params.csv')
    with open(evt_path) as f:
        reader = csv.reader(f)
        rows = [row for row in reader]
    assert approx(float(rows[1][1])) == 2
    assert approx(float(rows[2][1])) == 0.0020768431983
    assert approx(float(rows[4][15])) == 9.81616222270557
    assert approx(float(rows[9][13])) == 7.052493472354065
示例#7
0
def test_widget_notes_export_csv(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    w.info.open_dataset(str(gui_file))
    w.notes.update_notes(annot_psg_path)

    menubar = w.menuBar()

    act_annot = find_in_qt(menubar, QAction, 'Annotations')
    menubar.setActiveAction(act_annot)
    act_annot.menu().setActiveAction(w.notes.action['export_sleepstats'])

    screenshot(w, 'analysis_02_statistics.png')
    w.close()
示例#8
0
def test_widget_notes_import_fasst(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    menubar = w.menuBar()

    act_annot = find_in_qt(menubar, QAction, 'Annotations')
    menubar.setActiveAction(act_annot)

    act_import = find_in_qt(act_annot.menu(), QAction, 'Import Staging')
    act_annot.menu().setActiveAction(act_import)

    act_import.menu().setActiveAction(w.notes.action['import_fasst'])

    screenshot(w, 'notes_04_import_fasst.png')
    w.close()
示例#9
0
def test_widget_notes_cycle(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    w.info.open_dataset(str(gui_file))
    channel_make_group(w)
    w.channels.button_apply.click()
    w.channels.new_group(test_name='eog')
    w.notes.update_notes(annot_psg_path)
    w.traces.Y_wider()
    w.traces.Y_wider()
    w.traces.go_to_epoch(test_text_str='22:28')

    menubar = w.menuBar()

    act_annot = find_in_qt(menubar, QAction, 'Annotations')
    menubar.setActiveAction(act_annot)

    act_cycle = find_in_qt(act_annot.menu(), QAction, 'Cycle')
    act_annot.menu().setActiveAction(act_cycle)

    act_cycle.menu().setActiveAction(w.notes.action['cyc_start'])

    screenshot(w, 'notes_11_set_cycle_start.png')

    w.notes.get_cycle_mrkr()

    w.overview.grab().save(str(GUI_PATH / 'notes_12_cycle_marker.png'))

    w.traces.go_to_epoch(test_text_str='23:24')
    w.notes.get_cycle_mrkr(end=True)
    w.traces.go_to_epoch(test_text_str='23:29')
    w.notes.get_cycle_mrkr()
    w.traces.go_to_epoch(test_text_str='00:43')
    w.notes.get_cycle_mrkr()
    w.traces.go_to_epoch(test_text_str='02:14:30')
    w.notes.get_cycle_mrkr(end=True)

    w.overview.grab().save(str(GUI_PATH / 'notes_13_all_cycle_markers.png'))
    w.notes.clear_cycle_mrkrs(test=True)

    w.close()
示例#10
0
def test_widget_notes_toolbar(qtbot):

    w = MainWindow()
    qtbot.addWidget(w)

    w.info.open_dataset(str(gui_file))
    channel_make_group(w)
    w.channels.button_apply.click()
    w.channels.new_group(test_name='eog')
    w.notes.update_notes(annot_psg_path)
    w.traces.Y_wider()
    w.traces.go_to_epoch(test_text_str='23:00')

    toolbar = w.findChild(QToolBar, 'Annotations')

    button_event = find_in_qt(toolbar, QToolButton, 'Event Mode')
    button_event.setStyleSheet("background-color: red;")
    w.grab().save(str(GUI_PATH / 'notes_07_event_mode.png'))
    button_event.setStyleSheet("")

    box_evttype = find_in_qt_by_idx(toolbar, QComboBox, 0)
    box_evttype.setStyleSheet("background-color: red;")
    w.grab().save(str(GUI_PATH / 'notes_08_evt_type_box.png'))
    box_evttype.setStyleSheet("")

    box_stage = find_in_qt_by_idx(toolbar, QComboBox, 1)
    box_stage.setStyleSheet("background-color: red;")
    w.grab().save(str(GUI_PATH / 'notes_09_stage_box.png'))
    box_stage.setStyleSheet("")

    box_qual = find_in_qt_by_idx(toolbar, QComboBox, 2)
    box_qual.setStyleSheet("background-color: red;")
    w.grab().save(str(GUI_PATH / 'notes_10_quality_box.png'))
    box_qual.setStyleSheet("")

    w.close()