def gui(tempdir, qtbot): gui = GUI(position=(200, 200), size=(800, 600), config_dir=tempdir) gui.set_default_actions() gui.show() qtbot.wait(1) #qtbot.addWidget(gui) #qtbot.waitForWindowShown(gui) yield gui qtbot.wait(1) gui.close() qtbot.wait(1)
def create_trace_gui(obj, **kwargs): """Create the Trace GUI. Parameters ---------- obj : str or Path Path to the raw data file. sample_rate : float The data sampling rate, in Hz. n_channels_dat : int The number of columns in the raw data file. dtype : str The NumPy data type of the raw binary file. offset : int The header offset in bytes. """ gui_name = 'TraceGUI' # Support passing a params.py file. if str(obj).endswith('.py'): params = get_template_params(str(obj)) return create_trace_gui(next(iter(params.pop('dat_path'))), **params) kwargs = { k: v for k, v in kwargs.items() if k in ('sample_rate', 'n_channels_dat', 'dtype', 'offset') } traces = get_ephys_reader(obj, **kwargs) create_app() gui = GUI(name=gui_name, subtitle=obj.resolve(), enable_threading=False) gui.set_default_actions() def _get_traces(interval): return Bunch(data=select_traces( traces, interval, sample_rate=traces.sample_rate)) # TODO: load channel information view = TraceView( traces=_get_traces, n_channels=traces.n_channels, sample_rate=traces.sample_rate, duration=traces.duration, enable_threading=False, ) view.attach(gui) return gui
def gui(tempdir, qtbot): # NOTE: mock patch show box exec_ _supervisor._show_box = lambda _: _ gui = GUI(position=(200, 100), size=(500, 500), config_dir=tempdir) gui.set_default_actions() gui.show() qtbot.waitForWindowShown(gui) yield gui qtbot.wait(5) gui.close() del gui qtbot.wait(5)
def create_gui(self): """Create the spike sorting GUI.""" gui = GUI(name=self.gui_name, subtitle=self.dat_path.resolve(), enable_threading=False) gui.has_save_action = False gui.set_default_actions() self.create_actions(gui) self.create_params_widget(gui) self.create_ipython_view(gui) self.create_trace_view(gui) self.create_probe_view(gui) return gui
def create_trace_gui(dat_path, **kwargs): """Create the Trace GUI. Parameters ---------- dat_path : str or Path Path to the raw data file. sample_rate : float The data sampling rate, in Hz. n_channels_dat : int The number of columns in the raw data file. dtype : str The NumPy data type of the raw binary file. """ gui_name = 'TraceGUI' dat_path = Path(dat_path) # Support passing a params.py file. if dat_path.suffix == '.py': params = get_template_params(str(dat_path)) return create_trace_gui(next(iter(params.pop('dat_path'))), **params) if dat_path.suffix == '.cbin': # pragma: no cover data = load_raw_data(path=dat_path) sample_rate = data.sample_rate n_channels_dat = data.shape[1] else: sample_rate = float(kwargs['sample_rate']) assert sample_rate > 0. n_channels_dat = int(kwargs['n_channels_dat']) dtype = np.dtype(kwargs['dtype']) offset = int(kwargs['offset'] or 0) order = kwargs.get('order', None) # Memmap the raw data file. data = load_raw_data( path=dat_path, n_channels_dat=n_channels_dat, dtype=dtype, offset=offset, order=order, ) duration = data.shape[0] / sample_rate create_app() gui = GUI(name=gui_name, subtitle=dat_path.resolve(), enable_threading=False) gui.set_default_actions() def _get_traces(interval): return Bunch( data=select_traces(data, interval, sample_rate=sample_rate)) # TODO: load channel information view = TraceView( traces=_get_traces, n_channels=n_channels_dat, sample_rate=sample_rate, duration=duration, enable_threading=False, ) view.attach(gui) return gui