Crate intan_importer

Crate intan_importer 

Source
Expand description

§Intan Importer

A Rust library for importing and processing Intan Technologies RHS data files. This crate provides strongly-typed interfaces to Intan’s neural recording file formats, used in electrophysiology research.

§Overview

Intan Technologies manufactures hardware for neural recording, including systems that record electrical signals from the brain and nervous system. These systems generate data files in proprietary formats (RHS/RHD). This library provides tools to read and process these files, making the data accessible for analysis.

§Main Features

  • Single File or Directory Loading: Load individual RHS files or automatically combine multiple files from a directory
  • Comprehensive Parsing: Read and parse Intan RHS files with full support for all sections
  • Strong Typing: All data structures are strongly typed with appropriate Rust types
  • Automatic Processing:
    • Signal scaling to meaningful units (μV, V)
    • Notch filter application for line noise removal
    • Timestamp alignment and verification
  • Efficient Implementation:
    • Fast binary parsing with minimal allocations
    • Proper error handling with descriptive messages
    • Memory-efficient data structures

§Quick Start

use intan_importer::load;

// Load single RHS file
let result = load("path/to/your/file.rhs");

// Or load all RHS files from a directory
let result = load("path/to/recording/directory");

match result {
    Ok(rhs_file) => {
        // Access header information
        println!("Sample rate: {} Hz", rhs_file.header.sample_rate);
        println!("Number of channels: {}", rhs_file.header.amplifier_channels.len());
        
        // Access recording data if present
        if rhs_file.data_present {
            if let Some(data) = &rhs_file.data {
                if let Some(amp_data) = &data.amplifier_data {
                    // Process amplifier data
                    println!("Data dimensions: {:?}", amp_data.shape());
                }
            }
        }
    },
    Err(e) => println!("Error loading file: {}", e),
}

§Data Structure

The crate organizes Intan data into a hierarchy of structs:

  • RhsFile: Top-level container with header and data
    • RhsHeader: Configuration, channel info, and recording parameters
      • Version, Notes, FrequencyParameters, etc.
      • Lists of channels: amplifier_channels, board_adc_channels, etc.
    • RhsData: Actual recorded signals
      • timestamps, amplifier_data, stim_data, etc.

§Error Handling

The library provides descriptive errors for various failure scenarios (file format errors, I/O failures, etc.) through the IntanError type.

Re-exports§

pub use types::*;

Modules§

types

Functions§

load
Loads RHS data from a file or directory.