def setUpClass(cls): Debouncer.delay = 1 cls._qtbot = QtBot(create_app()) cls._tempdir_ = tempfile.mkdtemp() cls._tempdir = Path(cls._tempdir_) cls._controller = cls.get_controller(cls._tempdir) cls._create_gui()
def export_best_channels(path): create_app() chdir(path) all_clusters = np.load(path + '\\spike_clusters.npy') cluster_quality = pd.read_csv(path + '\\cluster_groups.csv', sep = "\t") tc = TemplateController(**_read_python(path + '\\params.py')) cluster_best_dict = dict() for cluster in all_clusters: cluster_best_dict.update({cluster: tc.get_best_channel(cluster)}) cluster_best_df = pd.DataFrame.from_dict(cluster_best_dict, orient='index') cluster_best_df.reset_index(level=0, inplace=True) cluster_best_df.columns = ['Cluster_id', 'Best_channel'] cluster_best_df.to_csv(path + '\\best_channels.csv', index=False)
def launch_phy(probe_name, eid=None, subj=None, date=None, sess_no=None, one=None): """ Launch phy given an eid and probe name. TODO calculate metrics and save as .tsvs to include in GUI when launching? """ # This is a first draft, no error handling and a draft dataset list. # Load data from probe # # -------------------- # if one is None: one = ONE() dtypes = [ 'spikes.times', 'spikes.clusters', 'spikes.amps', 'spikes.templates', 'spikes.samples', 'spikes.depths', 'templates.waveforms', 'templates.waveformsChannels', 'clusters.uuids', 'clusters.metrics', 'clusters.waveforms', 'clusters.waveformsChannels', 'clusters.depths', 'clusters.amps', 'clusters.channels', 'channels.probes', 'channels.rawInd', 'channels.localCoordinates', # 'ephysData.raw.ap' '_phy_spikes_subset.waveforms', '_phy_spikes_subset.spikes', '_phy_spikes_subset.channels' ] if eid is None: eid = one.search(subject=subj, date=date, number=sess_no)[0] _ = one.load(eid, dataset_types=dtypes, download_only=True) ses_path = one.path_from_eid(eid) alf_probe_dir = os.path.join(ses_path, 'alf', probe_name) ephys_file_dir = os.path.join(ses_path, 'raw_ephys_data', probe_name) raw_files = glob.glob(os.path.join(ephys_file_dir, '*ap.*bin')) raw_file = [raw_files[0]] if raw_files else None # TODO download ephys meta-data, and extract TemplateController input arg params # Launch phy # # -------------------- # add_default_handler('DEBUG', logging.getLogger("phy")) add_default_handler('DEBUG', logging.getLogger("phylib")) create_app() controller = TemplateController( dat_path=raw_file, dir_path=alf_probe_dir, dtype=np.int16, n_channels_dat=384, sample_rate=3e4, plugins=['IBLMetricsPlugin'], plugin_dirs=[Path(__file__).resolve().parent / 'plugins']) gui = controller.create_gui() gui.show() run_app() gui.close() controller.model.close()
def stop(self): # pragma: no cover """Used for debugging.""" create_app().exec_() self.gui.close()