Skip to main content

Crate openreadout_neuralynx

Crate openreadout_neuralynx 

Source
Expand description

Reader for Neuralynx Cheetah/Pegasus files: NCS continuous channels, NEV events, and NSE/NST/NTT spike waveforms.

Layout and vocabulary: docs/formats/neuralynx.md. Provenance: docs/provenance/neuralynx.md (Neuralynx’s public “Data File Formats” document; Neo, BSD-3, read as documentation). Every file is a 16 KiB text header followed by fixed-size records. An NCS file is one trace whose sweeps are its gap-free segments; event and spike files are tables.

§Example

Every reader implements openreadout_core::FormatReader: descriptor says what it reads, sniff recognises a file from its first bytes, and open returns a openreadout_core::Dataset with a header-only info() summary and lazy data access.

use openreadout_core::FormatReader;
use openreadout_neuralynx::NeuralynxReader;

let format = NeuralynxReader.descriptor();
assert_eq!(format.id, openreadout_neuralynx::FORMAT_ID);
println!("{} ({}): .{}", format.name, format.family, format.extensions.join(", ."));

Reading a file:

use std::path::Path;

use openreadout_core::FormatReader;
use openreadout_neuralynx::NeuralynxReader;

let mut dataset = NeuralynxReader.open(Path::new("CSC1.ncs"))?;
let info = dataset.info()?; // headers only
let trace = &info.traces[0];
println!("{} sweep(s) at {} Hz, {} channel(s)", trace.sweep_count, trace.sample_rate_hz, trace.channels.len());
// The first 1000 samples of sweep 0, every channel, scaled to physical units.
let samples = dataset.read_trace(0, 0, 0, 1000)?;
for (channel, values) in trace.channels.iter().zip(&samples.channels) {
    println!("{} ({}): {:?}", channel.name, channel.unit.as_deref().unwrap_or("?"), values.first());
}

Applications that accept any instrument file usually register every reader in an openreadout_core::Registry and let it detect the format; that is what the openreadout command-line tool does.

§API stability

The supported API is what this page documents. The parser modules are public only so that tests and fuzz targets can reach them: they are hidden from this documentation and may change in any release.

Structs§

NeuralynxReader
The Neuralynx reader.

Constants§

EXTENSIONS
Extensions this reader opens.
FORMAT_ID
Format id used on the command line and in JSON.
SESSION_COMPANIONS
Files next to the recording that a session directory may hold besides the data files: logs, settings, and the raw-data files this reader does not decode.

Functions§

looks_like_neuralynx
True when the head looks like a Neuralynx text header: the header line, or -FileType / -RecordSize / NLX_Base_Class keys in the first kilobytes.
open_session
Open a Neuralynx recording directory: every .ncs channel on the same sample grid (rate, segments and their start stamps) joins one multi-channel trace, and each .nev / .nse / .nst / .ntt file is a table.
session_files
The data files of a Neuralynx recording directory, or None when dir is not one (see openreadout_core::session::session_files). Continuous files holding only the text header (no records) are left out.