def __init__(self, folder_path, chan_grp=None): assert HAVE_TDC, self.installation_mesg tdc_folder = Path(folder_path) SortingExtractor.__init__(self) dataio = tdc.DataIO(str(tdc_folder)) if chan_grp is None: # if chan_grp is not provided, take the first one if unique chan_grps = list(dataio.channel_groups.keys()) assert len( chan_grps ) == 1, 'There are several groups in the folder, specify chan_grp=...' chan_grp = chan_grps[0] self.chan_grp = chan_grp catalogue = dataio.load_catalogue(name='initial', chan_grp=chan_grp) labels = catalogue['clusters']['cluster_label'] labels = labels[labels >= 0] self._unit_ids = list(labels) # load all spike in memory (this avoid to lock the folder with memmap throug dataio self._all_spikes = dataio.get_spikes(seg_num=0, chan_grp=self.chan_grp, i_start=None, i_stop=None).copy() self._sampling_frequency = dataio.sample_rate self._kwargs = { 'folder_path': str(Path(folder_path).absolute()), 'chan_grp': chan_grp }
def __init__(self, folder_path, chan_grp=None): try: import tridesclous as tdc HAVE_TDC = True except ImportError: HAVE_TDC = False assert HAVE_TDC, self.installation_mesg tdc_folder = Path(folder_path) dataio = tdc.DataIO(str(tdc_folder)) if chan_grp is None: # if chan_grp is not provided, take the first one if unique chan_grps = list(dataio.channel_groups.keys()) assert len(chan_grps) == 1, 'There are several groups in the folder, specify chan_grp=...' chan_grp = chan_grps[0] catalogue = dataio.load_catalogue(name='initial', chan_grp=chan_grp) labels = catalogue['clusters']['cluster_label'] labels = labels[labels >= 0] unit_ids = list(labels) sampling_frequency = dataio.sample_rate BaseSorting.__init__(self, sampling_frequency, unit_ids) for seg_num in range(dataio.nb_segment): # load all spike in memory (this avoid to lock the folder with memmap throug dataio all_spikes = dataio.get_spikes(seg_num=seg_num, chan_grp=chan_grp, i_start=None, i_stop=None).copy() self.add_sorting_segment(TridesclousSortingSegment(all_spikes)) self._kwargs = {'folder_path': str(Path(folder_path).absolute()), 'chan_grp': chan_grp}
def _run(self, recording, output_folder): nb_chan = recording.get_num_channels() # check params and OpenCL when many channels use_sparse_template = False use_opencl_with_sparse = False if nb_chan >64: # this limit depend on the platform of course if tdc.cltools.HAVE_PYOPENCL: # force opencl self.params['fullchain_kargs']['preprocessor']['signalpreprocessor_engine'] = 'opencl' use_sparse_template = True use_opencl_with_sparse = True else: print('OpenCL is not available processing will be slow, try install it') tdc_dataio = tdc.DataIO(dirname=str(output_folder)) # make catalogue nested_params = make_nested_tdc_params(**self.params) chan_grps = list(tdc_dataio.channel_groups.keys()) for chan_grp in chan_grps: cc = tdc.CatalogueConstructor(dataio=tdc_dataio, chan_grp=chan_grp) tdc.apply_all_catalogue_steps(cc, verbose=self.debug, **nested_params) if self.debug: print(cc) cc.make_catalogue_for_peeler() # apply Peeler (template matching) initial_catalogue = tdc_dataio.load_catalogue(chan_grp=chan_grp) peeler = tdc.Peeler(tdc_dataio) peeler.change_params(catalogue=initial_catalogue, use_sparse_template=use_sparse_template, sparse_threshold_mad=1.5, use_opencl_with_sparse=use_opencl_with_sparse,) peeler.run(duration=None, progressbar=self.debug)
def export_spike_and_report(): files = pd.read_excel(basedir + 'file_list.xlsx') group_names = np.unique(files['group_name']) for group_name in group_names: print('*******') print(group_name) dirname = tdc_workdir + group_name dataio = tdc.DataIO(dirname=dirname) try: dataio.export_spikes( export_path=None, # None is inside the workir split_by_cluster=False, use_cell_label=True, formats='csv') # csv' or 'mat' or 'xlsx' print('Export OK') except: print('Erreur in exporting spikes') try: tdc.generate_report( dataio, export_path=None, neighborhood_radius=None) # None is inside the workir print('Report OK') except: print('Erreur in reporting')
def _run(self, recording, output_folder): recording = recover_recording(recording) tdc_dataio = tdc.DataIO(dirname=str(output_folder)) params = dict(self.params) del params["chunk_mb"], params["n_jobs_bin"] clean_catalogue_gui = params.pop('clean_catalogue_gui') # make catalogue chan_grps = list(tdc_dataio.channel_groups.keys()) for chan_grp in chan_grps: # parameters can change depending the group catalogue_nested_params = make_nested_tdc_params( tdc_dataio, chan_grp, **params) if self.verbose: print('catalogue_nested_params') pprint(catalogue_nested_params) peeler_params = tdc.get_auto_params_for_peelers( tdc_dataio, chan_grp) if self.verbose: print('peeler_params') pprint(peeler_params) cc = tdc.CatalogueConstructor(dataio=tdc_dataio, chan_grp=chan_grp) tdc.apply_all_catalogue_steps(cc, catalogue_nested_params, verbose=self.verbose) if clean_catalogue_gui: import pyqtgraph as pg app = pg.mkQApp() win = tdc.CatalogueWindow(cc) win.show() app.exec_() if self.verbose: print(cc) if distutils.version.LooseVersion(tdc.__version__) < '1.6.0': print('You should upgrade tridesclous') t0 = time.perf_counter() cc.make_catalogue_for_peeler() if self.verbose: t1 = time.perf_counter() print('make_catalogue_for_peeler', t1 - t0) # apply Peeler (template matching) initial_catalogue = tdc_dataio.load_catalogue(chan_grp=chan_grp) peeler = tdc.Peeler(tdc_dataio) peeler.change_params(catalogue=initial_catalogue, **peeler_params) t0 = time.perf_counter() peeler.run(duration=None, progressbar=False) if self.verbose: t1 = time.perf_counter() print('peeler.tun', t1 - t0)
def run_all_catalogues(): files = pd.read_excel(basedir + 'file_list.xlsx') group_names = np.unique(files['group_name']) for group_name in group_names: print('*******') print(group_name) dirname = tdc_workdir + group_name dataio = tdc.DataIO(dirname=dirname) print(dataio) for chan_grp in dataio.channel_groups.keys(): cc = tdc.CatalogueConstructor(dataio=dataio, chan_grp=chan_grp) print(cc) fullchain_kargs = { 'duration': 300., 'preprocessor': { 'highpass_freq': 400., 'lowpass_freq': 5000., 'smooth_size': 0, 'chunksize': 1024, 'lostfront_chunksize': 128, 'signalpreprocessor_engine': 'numpy', }, 'peak_detector': { 'peakdetector_engine': 'numpy', 'peak_sign': '-', 'relative_threshold': 4.5, 'peak_span': 0.0002, }, 'noise_snippet': { 'nb_snippet': 300, }, 'extract_waveforms': { 'n_left': -20, 'n_right': 30, 'mode': 'rand', 'nb_max': 20000, 'align_waveform': False, }, 'clean_waveforms': { 'alien_value_threshold': 25., }, } feat_method = 'global_pca' feat_kargs = {} clust_method = 'sawchaincut' clust_kargs = {} tdc.apply_all_catalogue_steps(cc, fullchain_kargs, feat_method, feat_kargs, clust_method, clust_kargs) print(cc)
def _run(self, recording, output_folder): nb_chan = recording.get_num_channels() tdc_dataio = tdc.DataIO(dirname=str(output_folder)) params = dict(self.params) clean_catalogue_gui = params.pop('clean_catalogue_gui') # make catalogue chan_grps = list(tdc_dataio.channel_groups.keys()) for chan_grp in chan_grps: # parameters can change depending the group catalogue_nested_params = make_nested_tdc_params(tdc_dataio, chan_grp, **params) if self.verbose: print('catalogue_nested_params') pprint(catalogue_nested_params) peeler_params = tdc.get_auto_params_for_peelers(tdc_dataio, chan_grp) if self.verbose: print('peeler_params') pprint(peeler_params) # check params and OpenCL when many channels use_sparse_template = False use_opencl_with_sparse = False if nb_chan > 64 and not peeler_params['use_sparse_template']: print('OpenCL is not available processing will be slow, try install it') cc = tdc.CatalogueConstructor(dataio=tdc_dataio, chan_grp=chan_grp) tdc.apply_all_catalogue_steps(cc, catalogue_nested_params, verbose=self.verbose) if clean_catalogue_gui: import pyqtgraph as pg app = pg.mkQApp() win = tdc.CatalogueWindow(cc) win.show() app.exec_() if self.verbose: print(cc) t0 = time.perf_counter() cc.make_catalogue_for_peeler() if self.verbose: t1 = time.perf_counter() print('make_catalogue_for_peeler', t1-t0) # apply Peeler (template matching) initial_catalogue = tdc_dataio.load_catalogue(chan_grp=chan_grp) peeler = tdc.Peeler(tdc_dataio) peeler.change_params(catalogue=initial_catalogue, **peeler_params) t0 = time.perf_counter() peeler.run(duration=None, progressbar=False) if self.verbose: t1 = time.perf_counter() print('peeler.tun', t1-t0)
def _setup_recording(cls, recording, output_folder, params, verbose): import tridesclous as tdc # save prb file probegroup = recording.get_probegroup() prb_file = output_folder / 'probe.prb' write_prb(prb_file, probegroup) num_seg = recording.get_num_segments() sr = recording.get_sampling_frequency() # source file if isinstance(recording, BinaryRecordingExtractor ) and recording._kwargs['time_axis'] == 0: # no need to copy kwargs = recording._kwargs file_paths = kwargs['file_paths'] dtype = kwargs['dtype'] num_chan = kwargs['num_chan'] file_offset = kwargs['file_offset'] else: if verbose: print('Local copy of recording') # save binary file (chunk by chunk) into a new file num_chan = recording.get_num_channels() dtype = recording.get_dtype().str file_paths = [ str(output_folder / f'raw_signals_{i}.raw') for i in range(num_seg) ] BinaryRecordingExtractor.write_recording( recording, file_paths=file_paths, dtype=dtype, total_memory=params["total_memory"], n_jobs=params["n_jobs_bin"], verbose=False, progress_bar=verbose) file_offset = 0 # initialize source and probe file tdc_dataio = tdc.DataIO(dirname=str(output_folder)) tdc_dataio.set_data_source(type='RawData', filenames=file_paths, dtype=dtype, sample_rate=float(sr), total_channel=int(num_chan), offset=int(file_offset)) tdc_dataio.set_probe_file(str(prb_file)) if verbose: print(tdc_dataio)
def __init__(self, tdc_folder, chan_grp=None): assert HAVE_TDC, "must install tridesclous" tdc_folder = Path(tdc_folder) SortingExtractor.__init__(self) self.dataio = tdc.DataIO(str(tdc_folder)) if chan_grp is None: # if chan_grp is not provided, take the first one if unique chan_grps = list(self.dataio.channel_groups.keys()) assert len(chan_grps) == 1, 'There are several in the folder chan_grp, specify it' chan_grp = chan_grps[0] self.chan_grp = chan_grp self.catalogue = self.dataio.load_catalogue(name='initial', chan_grp=chan_grp)
def load_dataset(self, filepath=None): """Load dataset.""" if filepath is None: filepath = filedialog.askopenfilename(title="Select dataset.", initialdir='/', filetypes=[('MEA files', self.filetypes), ('all files', '*.*')]) self.filepath = filepath has_file = self.check_dataset_filepath(filepath) if not has_file: return basepath, extension = os.path.splitext(filepath) dirname, basename = os.path.split(basepath) # Do not change output path if it already exists (e.g. if we only load # the dataset due to a change in the duration settings). if self.output_path is None: self.output_path = os.path.join(dirname, 'tdc_output', time.strftime("%Y%m%d-%H%M%S")) if not os.path.exists(self.output_path): os.makedirs(self.output_path) self.dataio = tdc.DataIO(self.output_path) self.show_wait_window() self.dataio.set_data_source(type=extension[1:], filenames=[filepath], gui=self) # Update layout (depending on the dataset, some electrodes may have to # be disabled). self.find_channels_without_data() self.electrode_window.destroy() self.electrode_window.update() self.electrode_selection_frame() # Find stimulus files to update settings dialog. paths = os.listdir(dirname) trigger_paths = [p for p in paths if basename + '_stimulus' in p] if len(trigger_paths): self.preprocessing_dialog.params.param( 'stimulus_generator').setLimits(trigger_paths) self.close_wait_window() self.log("TOOLTIP: Select which channels to process.")
def _setup_recording(self, recording, output_folder): # reset the output folder output_folder.mkdir(parents=True, exist_ok=True) p = self.params # save prb file # note: only one group here, the split is done in basesorter probe_file = output_folder / 'probe.prb' recording.save_to_probe_file(probe_file, grouping_property=None) # source file if isinstance( recording, se.BinDatRecordingExtractor) and recording._time_axis == 0: # no need to copy raw_filename = recording._datfile dtype = recording._timeseries.dtype.str nb_chan = len(recording._channels) offset = recording._timeseries.offset else: if self.verbose: print('Local copy of recording') # save binary file (chunk by hcunk) into a new file raw_filename = output_folder / 'raw_signals.raw' recording.write_to_binary_dat_format(raw_filename, time_axis=0, dtype='float32', chunk_mb=p["chunk_mb"], n_jobs=p["n_jobs_bin"], verbose=self.verbose) dtype = 'float32' offset = 0 # initialize source and probe file tdc_dataio = tdc.DataIO(dirname=str(output_folder)) nb_chan = recording.get_num_channels() tdc_dataio.set_data_source( type='RawData', filenames=[str(raw_filename)], dtype=dtype, sample_rate=recording.get_sampling_frequency(), total_channel=nb_chan, offset=offset) tdc_dataio.set_probe_file(str(probe_file)) if self.verbose: print(tdc_dataio)
def _setup_recording(self, recording, output_folder): # reset the output folder if output_folder.is_dir(): shutil.rmtree(str(output_folder)) os.makedirs(str(output_folder)) # save prb file: probe_file = output_folder / 'probe.prb' se.save_probe_file(recording, probe_file, format='spyking_circus') # source file if isinstance(recording, se.BinDatRecordingExtractor) and recording._frame_first: # no need to copy raw_filename = recording._datfile dtype = recording._timeseries.dtype.str nb_chan = len(recording._channels) offset = recording._timeseries.offset else: if self.debug: print('Local copy of recording') # save binary file (chunk by hcunk) into a new file raw_filename = output_folder / 'raw_signals.raw' n_chan = recording.get_num_channels() chunksize = 2**24 // n_chan se.write_binary_dat_format(recording, raw_filename, time_axis=0, dtype='float32', chunksize=chunksize) dtype = 'float32' offset = 0 # initialize source and probe file tdc_dataio = tdc.DataIO(dirname=str(output_folder)) nb_chan = recording.get_num_channels() tdc_dataio.set_data_source( type='RawData', filenames=[str(raw_filename)], dtype=dtype, sample_rate=recording.get_sampling_frequency(), total_channel=nb_chan, offset=offset) tdc_dataio.set_probe_file(str(probe_file)) if self.debug: print(tdc_dataio)
def create_tridesclous_workdir(): files = pd.read_excel(basedir + 'file_list.xlsx') group_names = np.unique(files['group_name']) print(group_names) for group_name in group_names: print('*******') print(group_name) dirname = tdc_workdir + group_name print(dirname) if os.path.exists(dirname): print('Already exists', dirname) continue keep = files['group_name'] == group_name #~ print(keep) filenames = files.loc[keep, 'filename'].tolist() #~ print(filenames) #~ exit() filenames = [os.path.join(datadir, f) for f in filenames] print(filenames) #~ exit() dataio = tdc.DataIO(dirname=dirname) # feed DataIO with one file dataio.set_data_source(type='RawData', filenames=filenames, sample_rate=20000., dtype='float64', total_channel=16, bit_to_microVolt=1. / 1e6) print(dataio) # set the probe file dataio.set_probe_file(basedir + 'good_atlas_probe.prb')
def _run_from_folder(cls, output_folder, params, verbose): import tridesclous as tdc tdc_dataio = tdc.DataIO(dirname=str(output_folder)) params = params.copy() # make catalogue chan_grps = list(tdc_dataio.channel_groups.keys()) for chan_grp in chan_grps: # parameters can change depending the group catalogue_nested_params = make_nested_tdc_params( tdc_dataio, chan_grp, **params) if verbose: print('catalogue_nested_params') pprint(catalogue_nested_params) peeler_params = tdc.get_auto_params_for_peelers( tdc_dataio, chan_grp) if verbose: print('peeler_params') pprint(peeler_params) cc = tdc.CatalogueConstructor(dataio=tdc_dataio, chan_grp=chan_grp) tdc.apply_all_catalogue_steps(cc, catalogue_nested_params, verbose=verbose) if verbose: print(cc) # apply Peeler (template matching) initial_catalogue = tdc_dataio.load_catalogue(chan_grp=chan_grp) peeler = tdc.Peeler(tdc_dataio) peeler.change_params(catalogue=initial_catalogue, **peeler_params) t0 = time.perf_counter() peeler.run(duration=None, progressbar=False) if verbose: t1 = time.perf_counter() print('peeler.tun', t1 - t0)
def _run(self, recording, output_folder): nb_chan = recording.get_num_channels() tdc_dataio = tdc.DataIO(dirname=str(output_folder)) # make catalogue chan_grps = list(tdc_dataio.channel_groups.keys()) for chan_grp in chan_grps: # parameters can change depending the group catalogue_nested_params = make_nested_tdc_params( tdc_dataio, chan_grp, **self.params) #~ print(catalogue_nested_params) peeler_params = tdc.get_auto_params_for_peelers( tdc_dataio, chan_grp) #~ print(peeler_params) # check params and OpenCL when many channels use_sparse_template = False use_opencl_with_sparse = False if nb_chan > 64 and not peeler_params['use_sparse_template']: print( 'OpenCL is not available processing will be slow, try install it' ) cc = tdc.CatalogueConstructor(dataio=tdc_dataio, chan_grp=chan_grp) tdc.apply_all_catalogue_steps( cc, catalogue_nested_params, verbose=self.debug, ) if self.debug: print(cc) cc.make_catalogue_for_peeler() # apply Peeler (template matching) initial_catalogue = tdc_dataio.load_catalogue(chan_grp=chan_grp) peeler = tdc.Peeler(tdc_dataio) peeler.change_params(catalogue=initial_catalogue, **peeler_params) peeler.run(duration=None, progressbar=self.debug)
def __init__(self, folder_path, chan_grp=None): assert HAVE_TDC, self.installation_mesg tdc_folder = Path(folder_path) SortingExtractor.__init__(self) self.dataio = tdc.DataIO(str(tdc_folder)) if chan_grp is None: # if chan_grp is not provided, take the first one if unique chan_grps = list(self.dataio.channel_groups.keys()) assert len( chan_grps ) == 1, 'There are several in the folder chan_grp, specify it' chan_grp = chan_grps[0] self.chan_grp = chan_grp self.catalogue = self.dataio.load_catalogue(name='initial', chan_grp=chan_grp) self._sampling_frequency = self.dataio.sample_rate self._kwargs = { 'folder_path': str(Path(folder_path).absolute()), 'chan_grp': chan_grp }
def tdc_helper(*, tmpdir, params, recording): import tridesclous as tdc # nb_chan = recording.get_num_channels() # check params and OpenCL when many channels use_sparse_template = False use_opencl_with_sparse = False # if nb_chan > 64: # this limit depend on the platform of course # if tdc.cltools.HAVE_PYOPENCL: # # force opencl # self.params['fullchain_kargs']['preprocessor']['signalpreprocessor_engine'] = 'opencl' # use_sparse_template = True # use_opencl_with_sparse = True # else: # print('OpenCL is not available processing will be slow, try install it') tdc_dataio = tdc.DataIO(dirname=str(tmpdir)) # make catalogue chan_grps = list(tdc_dataio.channel_groups.keys()) for chan_grp in chan_grps: cc = tdc.CatalogueConstructor(dataio=tdc_dataio, chan_grp=chan_grp) tdc.apply_all_catalogue_steps(cc, verbose=True, **params) cc.make_catalogue_for_peeler() # apply Peeler (template matching) initial_catalogue = tdc_dataio.load_catalogue(chan_grp=chan_grp) peeler = tdc.Peeler(tdc_dataio) peeler.change_params( catalogue=initial_catalogue, use_sparse_template=use_sparse_template, sparse_threshold_mad=1.5, use_opencl_with_sparse=use_opencl_with_sparse, ) peeler.run(duration=None, progressbar=False) sorting = se.TridesclousSortingExtractor(tmpdir) return sorting
def run(self): import tridesclous as tdc tmpdir = Path(_get_tmpdir('tdc')) recording = SFMdaRecordingExtractor(self.recording_dir) params = { 'fullchain_kargs': { 'duration': 300., 'preprocessor': { 'highpass_freq': self.freq_min, 'lowpass_freq': self.freq_max, 'smooth_size': 0, 'chunksize': 1024, 'lostfront_chunksize': 128, 'signalpreprocessor_engine': 'numpy', 'common_ref_removal': self.common_ref_removal, }, 'peak_detector': { 'peakdetector_engine': 'numpy', 'peak_sign': '-', 'relative_threshold': self.detection_threshold, 'peak_span': self.peak_span, }, 'noise_snippet': { 'nb_snippet': 300, }, 'extract_waveforms': { 'n_left': self.waveforms_n_left, 'n_right': self.waveforms_n_right, 'mode': 'rand', 'nb_max': 20000, 'align_waveform': self.align_waveform, }, 'clean_waveforms': { 'alien_value_threshold': self.alien_value_threshold, }, }, 'feat_method': 'peak_max', 'feat_kargs': {}, 'clust_method': 'sawchaincut', 'clust_kargs': { 'kde_bandwith': 1. }, } # save prb file: probe_file = tmpdir / 'probe.prb' se.save_probe_file(recording, probe_file, format='spyking_circus') # source file if isinstance(recording, se.BinDatRecordingExtractor) and recording._frame_first: # no need to copy raw_filename = recording._datfile dtype = recording._timeseries.dtype.str nb_chan = len(recording._channels) offset = recording._timeseries.offset else: # save binary file (chunk by hcunk) into a new file raw_filename = tmpdir / 'raw_signals.raw' n_chan = recording.get_num_channels() chunksize = 2**24 // n_chan se.write_binary_dat_format(recording, raw_filename, time_axis=0, dtype='float32', chunksize=chunksize) dtype = 'float32' offset = 0 # initialize source and probe file tdc_dataio = tdc.DataIO(dirname=str(tmpdir)) nb_chan = recording.get_num_channels() tdc_dataio.set_data_source( type='RawData', filenames=[str(raw_filename)], dtype=dtype, sample_rate=recording.get_sampling_frequency(), total_channel=nb_chan, offset=offset) tdc_dataio.set_probe_file(str(probe_file)) try: sorting = tdc_helper(tmpdir=tmpdir, params=params, recording=recording) SFMdaSortingExtractor.write_sorting(sorting=sorting, save_path=self.firings_out) except: if os.path.exists(tmpdir): if not getattr(self, '_keep_temp_files', False): shutil.rmtree(tmpdir) raise if not getattr(self, '_keep_temp_files', False): shutil.rmtree(tmpdir)
def spikeviewer(SPIKES): all_spikes = [] for label in range(len(SPIKES)): spike_name = 'Unit {}#{}'.format(chan_grp, label) all_spikes.append({'time': SPIKES[label], 'name': spike_name}) spike_source = InMemorySpikeSource(all_spikes=all_spikes) win = MainViewer(debug=False, show_global_xsize=True, show_auto_scale=True) view1 = SpikeTrainViewer(source=spike_source) win.add_view(view1) return (win) #----------------------------------------------------------------------------- #Load the catalogue dataio = tdc.DataIO(path) #Number of segments n_seg = dataio.nb_segment #Compute time vector of the whole trace sampling_period = 1.0 / sampling_rate len_trace = 0 for seg_num in range(n_seg): len_seg = dataio.get_segment_length(seg_num) len_trace += len_seg time_vector = np.arange(0, len_trace, 1) * sampling_period #Mean episode lenght ep_len = (len_trace / n_seg) * sampling_period
import matplotlib.pyplot as plt from sklearn.metrics import silhouette_samples, silhouette_score from sklearn.cluster import KMeans, MeanShift from sklearn.mixture import GaussianMixture #~ p = '../example/' #~ dirname = p + 'tridesclous_locust' #~ dirname = p +'tridesclous_olfactory_bulb' #~ dirname = p +'tridesclous_purkinje' #~ dirname = '/media/samuel/SamCNRS/DataSpikeSorting/pierre/GT 252/tridesclous_GT256_20160426' #~ dirname = '/home/samuel/Documents/projet/DataSpikeSorting/david robbe/test_2017_03_24_14_35/tdc_test_2017_03_24_14_35/' dirname = '/home/samuel/Documents/projet/DataSpikeSorting/kampff/2014_11_25_Pair_3_0/tdc_adc2014-11-25T23_00_08/' dataio = tdc.DataIO(dirname=dirname) cc = catalogueconstructor = tdc.CatalogueConstructor(dataio=dataio) print(cc) #~ wf = cc.some_waveforms #~ data = wf.reshape(wf.shape[0], -1) def test_silouhette_or_bic(): data = cc.some_features labels = cc.all_peaks['label'][cc.some_peaks_index] keep = labels >= 0 labels = labels[keep]
def main(): argv = sys.argv[1:] parser = argparse.ArgumentParser(description='tridesclous') parser.add_argument('command', help='command in [{}]'.format(txt_command_list), default='mainwin', nargs='?') parser.add_argument('-d', '--dirname', help='working directory', default=None) parser.add_argument('-c', '--chan_grp', type=int, help='channel group index', default=0) parser.add_argument('-p', '--parameters', help='JSON parameter file', default=None) args = parser.parse_args(argv) #~ print(sys.argv) #~ print(args) #~ print(args.command) command = args.command if not command in comand_list: print('command should be in [{}]'.format(txt_command_list)) exit() dirname = args.dirname if dirname is None: dirname = os.getcwd() #~ print(command) if command in ['cataloguewin', 'peelerwin']: if not tdc.DataIO.check_initialized(dirname): print('{} is not initialized'.format(dirname)) exit() dataio = tdc.DataIO(dirname=dirname) print(dataio) if command == 'mainwin': open_mainwindow() elif command == 'makecatalogue': pass elif command == 'runpeeler': pass elif command == 'cataloguewin': catalogueconstructor = tdc.CatalogueConstructor(dataio=dataio, chan_grp=args.chan_grp) app = pg.mkQApp() win = tdc.CatalogueWindow(catalogueconstructor) win.show() app.exec_() elif command == 'peelerwin': initial_catalogue = dataio.load_catalogue(chan_grp=args.chan_grp) app = pg.mkQApp() win = tdc.PeelerWindow(dataio=dataio, catalogue=initial_catalogue) win.show() app.exec_() elif command == 'init': app = pg.mkQApp() win = tdc.InitializeDatasetWindow() win.show() app.exec_()