How to use the nixio.FileMode function in nixio

To help you get started, we’ve selected a few nixio 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 / spikeextractors / spikeextractors / extractors / nixioextractors / nixioextractors.py View on Github external
def write_sorting(sorting, save_path, overwrite=False):
        assert HAVE_NIXIO, NIXIOSortingExtractor.installation_mesg

        if os.path.exists(save_path) and not overwrite:
            raise FileExistsError("File exists: {}".format(save_path))

        sfreq = sorting.get_sampling_frequency()
        if sfreq is None:
            unit = None
        elif sfreq == 1:
            unit = "s"
        else:
            unit = "{} s".format(1./sfreq)

        nf = nix.File.open(save_path, nix.FileMode.Overwrite)
        # use the file name to name the top-level block
        fname = os.path.basename(save_path)
        block = nf.create_block(fname, "spikeinterface.sorting")
        commonmd = nf.create_section(fname, "spikeinterface.sorting.metadata")
        if sfreq is not None:
            commonmd["sampling_frequency"] = sfreq

        spikes_das = list()
        for unit_id in sorting.get_unit_ids():
            spikes = sorting.get_unit_spike_train(unit_id)
            name = "spikes-{}".format(unit_id)
            da = block.create_data_array(name, "spikeinterface.spikes",
                                         data=spikes)
            da.unit = unit
            da.label = str(unit_id)
            spikes_das.append(da)

nixio

Python reimplementation of NIXIO (http://g-node.github.io/nix/)

BSD-2-Clause
Latest version published 14 days ago

Package Health Score

65 / 100
Full package analysis