def test_cli_defaults(self): """Test CLI default values match factory defaults""" argv = ['neurotic'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) # should match factory defaults because setUp() explicitly reset the # defaults to the factory defaults factory_defaults = neurotic._global_config_factory_defaults['defaults'] self.assertEqual(win.do_toggle_debug_logging.isChecked(), factory_defaults['debug'], 'debug setting has unexpected default') self.assertEqual(win.lazy, factory_defaults['lazy'], 'lazy setting has unexpected default') self.assertEqual(win.support_increased_line_width, factory_defaults['thick_traces'], 'thick traces setting has unexpected default') self.assertEqual(win.show_datetime, factory_defaults['show_datetime'], 'show_datetime has unexpected default') self.assertEqual(win.ui_scale, factory_defaults['ui_scale'], 'ui_scale has unexpected default') self.assertEqual(win.theme, factory_defaults['theme'], 'theme has unexpected default') self.assertEqual(win.metadata_selector.file, self.example_file, 'file has unexpected default') self.assertEqual(win.metadata_selector._selection, self.example_dataset, 'dataset has unexpected default')
def test_EpochEncoder(): possible_labels = ['AAA', 'BBB', 'CCC', 'DDD'] ep_times = np.arange(0, 10., .5) ep_durations = np.ones(ep_times.shape) * .25 ep_labels = np.random.choice(possible_labels, ep_times.size) epoch = { 'time': ep_times, 'duration': ep_durations, 'label': ep_labels, 'name': 'MyFactor' } source = WritableEpochSource(epoch=epoch, possible_labels=possible_labels) app = ephyviewer.mkQApp() view = ephyviewer.EpochEncoder(source=source, name='Epoch encoder') win = ephyviewer.MainViewer(show_step=False, show_global_xsize=True, debug=False) win.add_view(view) win.show() app.exec_()
def test_mainviewer(): class FakeView(ViewerBase): def refresh(self): self.v = self.t #~ print('refresh', self.name, self.t) pass def set_settings(self, value): self.v = value def get_settings(self): return self.v app = ephyviewer.mkQApp() view1 = FakeView(name='view1') view2 = FakeView(name='view2') view3 = FakeView(name='view3') view4 = FakeView(name='view4') view5 = FakeView(name='view5') win = ephyviewer.MainViewer(settings_name='test0') win.add_view(view1) win.add_view(view2) win.add_view(view3, tabify_with='view2') win.add_view(view4, split_with='view1', orientation='horizontal') win.add_view(view5, location='bottom', orientation='horizontal') win.show() app.exec_()
def test_mne_raw_source(): #reader = neo.MicromedIO(filename='File_micromed_1.TRC') vhdr_fname = 'small_BrainAmp.vhdr' raw = mne.io.read_raw_brainvision( vhdr_fname, montage='standard_1020', eog=['EOG'], preload=True, ) # raw.set_montage #~ raw = raw.crop(0, 10) source = MneRawSource(raw) #you must first create a main Qt application (for event loop) app = mkQApp() win = MainViewer(show_auto_scale=True) view1 = TraceViewer(source=source, name='sigs') win.add_view(view1) #show main window and run Qapp win.show() app.exec_()
def test_neoviewer(interactive=False): #~ from neo.rawio.tdtrawio import TdtRawIO #~ local_tdt_folder = get_tdt_test_files() #~ neorawio = TdtRawIO(dirname=local_tdt_folder) #~ neorawio.parse_header() #~ print(neorawio) from neo.rawio.blackrockrawio import BlackrockRawIO filename = get_blackrock_files() neorawio = BlackrockRawIO(filename=filename) neorawio.parse_header() print(neorawio) sources = ephyviewer.get_sources_from_neo_rawio(neorawio) print(sources) app = ephyviewer.mkQApp() win = ephyviewer.MainViewer(debug=True, show_auto_scale=True) for i, sig_source in enumerate(sources['signal']): view = ephyviewer.TraceViewer(source=sig_source, name='signal {}'.format(i)) win.add_view(view) for i, ep_source in enumerate(sources['epoch']): view = ephyviewer.EpochViewer(source=ep_source, name='epochs') win.add_view(view) if interactive: win.show() app.exec_() else: # close thread properly win.close()
def test_spikeinterface_viewer(interactive=False): import spikeinterface as si from spikeinterface.core.testing_tools import generate_recording, generate_sorting recording = generate_recording() sig_source = ephyviewer.SpikeInterfaceRecordingSource(recording=recording) sorting = generate_sorting() spike_source = ephyviewer.SpikeInterfaceSortingSource(sorting=sorting) app = ephyviewer.mkQApp() win = ephyviewer.MainViewer(debug=True, show_auto_scale=True) view = ephyviewer.TraceViewer(source=sig_source, name='signals') win.add_view(view) view = ephyviewer.SpikeTrainViewer(source=spike_source, name='spikes') win.add_view(view) if interactive: win.show() app.exec_() else: # close thread properly win.close()
def test_neoviewer(interactive=False): from neo.rawio.tdtrawio import TdtRawIO local_test_dir = get_tdt_test_files() dirname = os.path.join(local_test_dir, 'aep_05') neorawio = TdtRawIO(dirname=dirname) neorawio.parse_header() print(neorawio) sources = ephyviewer.get_sources_from_neo_rawio(neorawio) app = ephyviewer.mkQApp() win = ephyviewer.MainViewer(debug=True, show_auto_scale=True) for i, sig_source in enumerate(sources['signal']): view = ephyviewer.TraceViewer(source=sig_source, name='signal {}'.format(i)) win.add_view(view) for i, ep_source in enumerate(sources['epoch']): view = ephyviewer.EpochViewer(source=ep_source, name='epochs') win.add_view(view) if interactive: win.show() app.exec_() else: # close thread properly win.close()
def test_mainviewer2(): from ephyviewer.tests.testing_tools import make_fake_video_source from ephyviewer.tests.testing_tools import make_fake_signals from ephyviewer.tests.testing_tools import make_fake_event_source from ephyviewer.tests.testing_tools import make_fake_epoch_source app = ephyviewer.mkQApp() view1 = ephyviewer.TraceViewer(source=make_fake_signals(), name='signals') view2 = ephyviewer.VideoViewer(source=make_fake_video_source(), name='video') view3 = ephyviewer.EventList(source=make_fake_event_source(), name='events') view4 = ephyviewer.EpochViewer(source=make_fake_epoch_source(), name='epoch') view5 = ephyviewer.TimeFreqViewer(source=make_fake_signals(), name='timefreq') win = ephyviewer.MainViewer(debug=True, settings_name='test1', show_global_xsize=True, show_auto_scale=True) #TODO bug because new params!!!!!!! #~ win = ephyviewer.MainViewer(debug=True, show_global_xsize=True) win.add_view(view1) win.add_view(view5) win.add_view(view2) win.add_view(view4) win.add_view(view3, location='bottom', orientation='horizontal') win.show() app.exec_()
def test_show_datetime(self): """Test that --show-datetime enables display of real-world datetime""" argv = ['neurotic', '--show-datetime'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertTrue(win.show_datetime, 'datetime not displayed with --show-datetime')
def test_thick_traces(self): """Test that --thick-traces enables support for thick traces""" argv = ['neurotic', '--thick-traces'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertTrue(win.support_increased_line_width, 'thick traces disabled with --thick-traces')
def test_no_show_datetime(self): """Test that --no-show-datetime hides the real-world datetime""" argv = ['neurotic', '--no-show-datetime'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertFalse(win.show_datetime, 'datetime displayed with --no-show-datetime')
def test_icons(interactive=False): app = mkQApp() w = QT.QWidget() w.setWindowIcon(QT.QIcon(':/media-playback-start.svg')) if interactive: w.show() app.exec_()
def launch_ephyviewer(self, theme='light', support_increased_line_width=False, show_datetime=False, datetime_format='%Y-%m-%d %H:%M:%S'): """ Start a Qt app and create an ephyviewer window. """ app = ephyviewer.mkQApp() win = self.create_ephyviewer_window(theme=theme, support_increased_line_width=support_increased_line_width, show_datetime=show_datetime, datetime_format=datetime_format) win.show() app.exec_()
def test_epoch_viewer(): source = make_fake_epoch_source() app = ephyviewer.mkQApp() view = ephyviewer.EpochViewer(source=source, name='epoch') win = ephyviewer.MainViewer(debug=True) win.add_view(view) win.show() app.exec_()
def test_spiketrain_viewer(): source = make_fake_spiketrain_source() app = ephyviewer.mkQApp() view = ephyviewer.SpikeTrainViewer(source=source, name='spikes') win = ephyviewer.MainViewer(debug=True) win.add_view(view) win.show() app.exec_()
def test_eventlist(): source = make_fake_event_source() app = ephyviewer.mkQApp() view = ephyviewer.EventList(source=source, name='events') win = ephyviewer.MainViewer(debug=True) win.add_view(view) win.show() app.exec_()
def test_traceviewer(): source = make_fake_signals() app = ephyviewer.mkQApp() view = ephyviewer.TraceViewer(source=source, name='trace') #~ view.refresh() win = ephyviewer.MainViewer(debug=True, show_auto_scale=True) win.add_view(view) win.show() app.exec_()
def test_traceviewer_cls_method_numpy(): sigs = np.random.rand(100000, 16) sample_rate = 1000. t_start = 0. app = ephyviewer.mkQApp() view = ephyviewer.TraceViewer.from_numpy(sigs, sample_rate, t_start, 'sigs') win = ephyviewer.MainViewer(debug=True, show_auto_scale=True) win.add_view(view) win.show() app.exec_()
def test_videoviewer(): source = make_fake_video_source() #~ exit() #~ print('*'*50) app = ephyviewer.mkQApp() view = ephyviewer.VideoViewer(source=source, name='video') view.params['nb_column'] = 2 win = ephyviewer.MainViewer(debug=True) win.add_view(view) win.show() app.exec_()
def test_eventlist(interactive=False): source = make_fake_event_source() app = ephyviewer.mkQApp() view = ephyviewer.EventList(source=source, name='events') win = ephyviewer.MainViewer(debug=True) win.add_view(view) if interactive: win.show() app.exec_() else: # close thread properly win.close()