This is a Rust project that provides a fast and memory-efficient way to read ABF (Axon Binary Format) files commonly used in electrophysiology.
Add this library to your Cargo.toml
:
toml
[dependencies]
rust-abf-reader = "0.1.3"
In your Rust code:
```rust use rust_abf::AbfBuilder;
fn main() { let abf = AbfBuilder::fromfile("path/to/your/file.abf"); match abf { Ok(abf) => { let channelscount = abf.getchannelscount(); let sweepscount = abf.getsweepscount(); println!("There are {:?} channels and {:?} sweeps", channelscount, sweepscount); (0..channelscount).foreach(|ch| { (0..sweepscount).foreach(|s|{ let data = abf.getsweepinchannel( s, ch).unwrap(); println!("First 10 elements from ch {:?} and sweep {:?}: {:?}", ch, s, &data[0..10]); }); }); }, _ => println!("File not found"), } } ```
If you prefer to work on channels, you can have direct access to them by using the following code:
...
let ch0 = abf.get_channel(0).unwrap();
println!("Channel 0 has the following unit of measurement {:?} and the following label {:?}", ch0.get_uom(), ch0.get_label());
for s in 0..abf.get_sweeps_count() {
let data = ch0.get_sweep(s).unwrap();
println!("Sweep {:?} has {:?} points", s, data.len());
}
...
Contributions are welcome! If you encounter issues or have suggestions, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.