def make_viewer(): source_sig, source_filtered_sig = make_sig_sources() #source_spike = make_spike_source() win = MainViewer(debug=False, show_global_xsize=True, show_auto_scale=True) view1 = TraceViewer(source=source_sig, name='trace') view1.params['scale_mode'] = 'same_for_all' view1.auto_scale() view2 = TraceViewer(source=source_filtered_sig, name='trace filtred') view2.params['scale_mode'] = 'same_for_all' view2.auto_scale() view3 = TimeFreqViewer(source=source_sig, name='tfr') view3.params['show_axis'] = False view3.params['timefreq', 'deltafreq'] = 1 #~ view3.by_channel_params['ch3', 'visible'] = True #view4 = SpikeTrainViewer(source=source_spike) win.add_view(view1) win.add_view(view2, tabify_with='trace') win.add_view(view3) #win.add_view(view4) return win
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_open_topo_viewer(): #~ reader = neo.MicromedIO(filename='File_micromed_1.TRC') #~ seg = reader.read_segment() #~ n_chan = seg.analogsignals[0].shape[1] #~ channel_positions = np.random.randn(n_chan, 2) #~ source = NeoAnalogSignalSource(seg.analogsignals[0]) montage_name = 'standard_1020' vhdr_fname = 'small_BrainAmp.vhdr' raw = mne.io.read_raw_brainvision(vhdr_fname, montage=montage_name, eog=['EOG'], preload=True) raw = raw.pick('eeg') source = MneRawSource(raw) #~ montage = mne.channels.make_standard_montage('standard_1020') #~ print(montage) #~ pos = np.array(list(montage._get_ch_pos().values())) #~ print(pos) #~ n_chan = len(raw.info['ch_names']) #~ channel_positions = np.random.randn(n_chan, 2) channel_positions = _find_topomap_coords(raw.info, None) #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) view3 = TopoEegViewer(source=source, name='topo', channel_positions=channel_positions) win.add_view(view3) #show main window and run Qapp win.show() app.exec_()
#you must first create a main Qt application (for event loop) app = mkQApp() #create fake 16 signals with 100000 at 10kHz sigs = np.random.rand(100000,16) sample_rate = 1000. t_start = 0. #Create the main window that can contain several viewers win = MainViewer(debug=True, show_auto_scale=True) #Create a datasource for the viewer # here we use InMemoryAnalogSignalSource but # you can alose use your custum datasource by inheritance source = InMemoryAnalogSignalSource(sigs, sample_rate, t_start) #create a viewer for signal with TraceViewer # TraceViewer normally accept a AnalogSignalSource but # TraceViewer.from_numpy is facitilty function to bypass that view1 = TraceViewer(source=source) #put this veiwer in the main window win.add_view(view1) #show main window and run Qapp win.show() app.exec_()
# here we generate a segment with several objects # (this is a bad example because it mimics old neo behavior for signals (one channel=one object)) neo_seg = generate_one_simple_segment(supported_objects=[ neo.Segment, neo.AnalogSignal, neo.Event, neo.Epoch, neo.SpikeTrain ]) # the global QT app app = mkQApp() ############################## # case 1 : create viewers one at a time directly from neo objects in memory win = MainViewer(show_auto_scale=True) # from one neo.AnalogSignal view1 = TraceViewer.from_neo_analogsignal(neo_seg.analogsignals[0], 'sigs') win.add_view(view1) # from several neo.SpikeTrains (3 spiketrains here) view2 = SpikeTrainViewer.from_neo_spiketrains(neo_seg.spiketrains[0:3], 'spikes') win.add_view(view2) # from several neo.Epoch view3 = EpochViewer.from_neo_epochs(neo_seg.epochs, 'epochs') win.add_view(view3) # from several neo.Event view4 = EventList.from_neo_events(neo_seg.events, 'events') win.add_view(view4, location='bottom', orientation='horizontal')
duration = 10. times = np.arange(0, duration, 1. / sample_rate, dtype='float64') sigs = np.random.rand(times.size, 1) t_start = 0. instantaneous_freqs = np.linspace(500, 3000, times.size) instantaneous_phase = np.cumsum(instantaneous_freqs / sample_rate) * 2 * np.pi sigs[:, 0] += np.sin(instantaneous_phase) #Create the main window that can contain several viewers win = MainViewer(debug=True, show_auto_scale=True) #Create a signal source for the viewer source = InMemoryAnalogSignalSource(sigs, sample_rate, t_start) #create a viewer for signal with TraceViewer view1 = TraceViewer(source=source, name='trace') view1.params['scale_mode'] = 'same_for_all' view1.params['xsize'] = 5. view1.auto_scale() #create a SpectrogramViewer on the same source view2 = SpectrogramViewer(source=source, name='spectrogram') view2.params['xsize'] = 5. view2.params['colormap'] = 'inferno' view2.params['scalogram', 'binsize'] = .1 view2.params['scalogram', 'scale'] = 'dB' view2.params['scalogram', 'scaling'] = 'spectrum' #add them to mainwindow win.add_view(view1)
#you must first create a main Qt application (for event loop) app = mkQApp() #create fake 16 signals with 100000 at 10kHz sigs = np.random.rand(100000,16) sample_rate = 1000. t_start = 0. #Create the main window that can contain several viewers win = MainViewer(debug=True, show_auto_scale=True) #create a viewer for signal with TraceViewer # TraceViewer normally accept a AnalogSignalSource but # TraceViewer.from_numpy is facitilty function to bypass that view1 = TraceViewer.from_numpy(sigs, sample_rate, t_start, 'Signals') #Parameters can be set in script view1.params['scale_mode'] = 'same_for_all' view1.params['display_labels'] = True #And also parameters for each channel view1.by_channel_params['ch0', 'visible'] = False view1.by_channel_params['ch15', 'color'] = '#FF00AA' #This is needed when scale_mode='same_for_all' #to recompute the gain #this avoid to push auto_scale button view1.auto_scale() #put this veiwer in the main window
#detect some crossing zeros s0 = signals[:-2, 0] s1 = signals[1:-1,0] s2 = signals[2:,0] peaks0, = np.nonzero((s0<s1) & (s2<s1)) peaks1, = np.nonzero((s0>s1) & (s2>s1)) #create 2 familly scatters from theses 2 indexes scatter_indexes = {0: peaks0, 1: peaks1} #and asign them to some channels each scatter_channels = {0: [0, 5, 8], 1: [0, 5, 10]} source = AnalogSignalSourceWithScatter(signals, sample_rate, t_start, scatter_indexes, scatter_channels) #Create the main window that can contain several viewers win = MainViewer(debug=True, show_auto_scale=True) #create a viewer for signal with TraceViewer #connected to the signal source view1 = TraceViewer(source=source) view1.params['scale_mode'] = 'same_for_all' view1.auto_scale() #put this veiwer in the main window win.add_view(view1) #show main window and run Qapp win.show() app.exec_()