How to use the spikeextractors.SortingExtractor.__init__ function in spikeextractors

To help you get started, we’ve selected a few spikeextractors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SpikeInterface / spiketoolkit / spiketoolkit / validation / quality_metric_classes / utils / curationsortingextractor.py View on Github external
def __init__(self, parent_sorting):
        SortingExtractor.__init__(self)
        self._parent_sorting = parent_sorting
        self._original_unit_ids = list(np.copy(parent_sorting.get_unit_ids()))
        self._all_ids = list(np.copy(parent_sorting.get_unit_ids()))

        # Create and store roots with original unit ids and cached spiketrains
        self._roots = []
        for unit_id in self._original_unit_ids:
            root = Unit(unit_id)
            root.set_spike_train(parent_sorting.get_unit_spike_train(unit_id))
            self._roots.append(root)
        '''
        Copies over properties and spike features from parent_sorting.
        Only spike features will be preserved with merges and splits, properties
        cannot be resolved in these cases.
        '''
        self.copy_unit_properties(parent_sorting)
github SpikeInterface / spikeextractors / spikeextractors / extractors / nwbextractors / nwbextractors.py View on Github external
def __init__(self, path, electrical_series=None):
        """

        Parameters
        ----------
        path: path to NWB file
        electrical_series: pynwb.ecephys.ElectricalSeries object
        """
        check_nwb_install()
        se.SortingExtractor.__init__(self)
        self._path = path
        with NWBHDF5IO(self._path, 'r') as io:
            nwbfile = io.read()
            # defines the electrical series from where the sorting came from
            # important to know the associated fs and t0
            if electrical_series is None:
                if len(nwbfile.acquisition) > 1:
                    raise Exception('More than one acquisition found. You must specify electrical_series.')
                if len(nwbfile.acquisition) == 0:
                    raise Exception('No acquisitions found in the .nwb file.')
                es = list(nwbfile.acquisition.values())[0]
            else:
                es = electrical_series

            # get rate
            if es.rate is not None:
github SpikeInterface / spikeextractors / spikeextractors / extractors / klustaextractors / klustaextractors.py View on Github external
def __init__(self, file_or_folder_path, exclude_cluster_groups=None):
        assert HAVE_KLSX, self.installation_mesg
        SortingExtractor.__init__(self)
        kwik_file_or_folder = Path(file_or_folder_path)
        kwikfile = None
        klustafolder = None
        if kwik_file_or_folder.is_file():
            assert kwik_file_or_folder.suffix == '.kwik', "Not a '.kwik' file"
            kwikfile = Path(kwik_file_or_folder).absolute()
            klustafolder = kwikfile.parent
        elif kwik_file_or_folder.is_dir():
            klustafolder = kwik_file_or_folder
            kwikfiles = [f for f in kwik_file_or_folder.iterdir() if f.suffix == '.kwik']
            if len(kwikfiles) == 1:
                kwikfile = kwikfiles[0]
        assert kwikfile is not None, "Could not load '.kwik' file"

        try:
            config_file = [f for f in klustafolder.iterdir() if f.suffix == '.prm'][0]
github SpikeInterface / spikeextractors / spikeextractors / extractors / npzsortingextractor / npzsortingextractor.py View on Github external
def __init__(self, file_path):
        SortingExtractor.__init__(self)
        self.npz_filename = file_path

        npz = np.load(file_path)

        self.unit_ids = npz['unit_ids']
        self.spike_indexes = npz['spike_indexes']
        self.spike_labels = npz['spike_labels']

        if 'sampling_frequency' in npz:
            self._sampling_frequency = float(npz['sampling_frequency'][0])
        else:
            self._sampling_frequency = None
        self._kwargs = {'file_path': str(Path(file_path).absolute())}
github SpikeInterface / spikeextractors / spikeextractors / extractors / shybridextractors / shybridextractors.py View on Github external
def __init__(self, file_path, delimiter=','):
        assert HAVE_SBEX, self.installation_mesg
        SortingExtractor.__init__(self)

        if os.path.isfile(file_path):
            self._spike_clusters = sbio.SpikeClusters()
            self._spike_clusters.fromCSV(file_path, None, delimiter=delimiter)
        else:
            raise FileNotFoundError('the ground truth file "{}" could not be found'.format(file_path))
        self._kwargs = {'file_path': str(Path(file_path).absolute()), 'delimiter': delimiter}