Metadata-Version: 2.4
Name: intan-importer
Version: 0.1.2
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering
Requires-Dist: numpy>=1.20
License-File: LICENSE
Summary: Fast Python bindings for reading Intan RHS files
Author: JB
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/brant01/python-intan-importer
Project-URL: Issues, https://github.com/brant01/python-intan-importer/issues


# intan-importer

Fast Python bindings for reading Intan RHS files, powered by Rust for high performance.

## Installation

```bash
pip install intan-importer
```

## Quick Start

```python
import intan_importer

# Load a single RHS file or a directory of files
rec = intan_importer.load("data.rhs")

# Access the data
time = rec.time  # Time vector in seconds
data = rec.data.amplifier_data  # Neural data in microvolts
```

## Data Structure

```
Recording object (rec)
│
├── .time                    → numpy array of time in seconds
├── .duration                → total duration in seconds
├── .num_samples             → total number of samples
├── .sample_rate             → sampling rate in Hz
├── .num_channels            → number of amplifier channels
├── .data_present            → bool, whether data exists
├── .source_files            → list of source files (if multiple)
│
├── .header
│   ├── .sample_rate         → sampling rate in Hz
│   ├── .notch_filter_frequency → 50, 60, or None
│   ├── .reference_channel   → reference channel name
│   ├── .note1, .note2, .note3 → user notes
│   ├── .amplifier_channels  → list of channel info
│   └── .board_adc_channels  → list of ADC channel info
│
├── .data (if present)
│   ├── .timestamps          → sample numbers (int32)
│   ├── .amplifier_data      → neural data (µV, int32)
│   ├── .board_adc_data      → auxiliary inputs (V, int32)
│   ├── .board_dig_in_data   → digital inputs (0 or 1)
│   ├── .stim_data           → stimulation current (µA)
│   └── ... (other optional data types)
│
└── Methods:
    ├── .get_channel_data(channel, start_time, end_time)
    ├── .get_time_slice(start_time, end_time) 
    └── .summary()
```

## Key Features

### Time Vector
The `.time` property gives you a time vector in seconds, automatically computed from timestamps and sampling rate:
```python
time = rec.time  # Computed once and cached
plt.plot(time, rec.data.amplifier_data[0, :])
```

### Channel Access
Access channels by index or name:
```python
# By index
data = rec.get_channel_data(0)

# By channel name
data = rec.get_channel_data("CA1")

# With time window (in seconds)
data = rec.get_channel_data("CA1", start_time=10.0, end_time=20.0)
```

### Channel Information
```python
for i, ch in enumerate(rec.header.amplifier_channels):
    print(f"Channel {i}: {ch.custom_channel_name} ({ch.electrode_impedance_magnitude:.0f} Ω)")
```

## Data Types

- **Timestamps**: Sample numbers (divide by sample_rate for seconds)
- **Amplifier data**: Microvolts (µV)
- **ADC data**: Volts (V)
- **Digital data**: Binary (0 or 1)
- **Stimulation data**: Microamps (µA)

