bioread

Utilities to work with files from BIOPAC's AcqKnowlege software

https://github.com/uwmadison-chm/bioread

Science Score: 46.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    3 of 9 committers (33.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.7%) to scientific vocabulary
Last synced: 7 months ago · JSON representation

Repository

Utilities to work with files from BIOPAC's AcqKnowlege software

Basic Info
  • Host: GitHub
  • Owner: uwmadison-chm
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 12.1 MB
Statistics
  • Stars: 76
  • Watchers: 14
  • Forks: 25
  • Open Issues: 0
  • Releases: 12
Created over 15 years ago · Last pushed 11 months ago
Metadata Files
Readme Changelog License Zenodo

README.md

Libraries for reading BIOPAC files

DOI

These utilities are for reading the files produced by BIOPAC's AcqKnowledge software. Much of the information is based on Application Note 156 from BIOPAC; however, newer file formats were decoded through the tireless efforts of John Ollinger, Nate Vack, and Mike Davison. Updated file structure documentation from Mike is in the notes/ directory.

This library is mostly concerned with getting you the data, and less so with interpreting UI-related header values.

Status

As far as I know, this should read any AcqKnowledge file you throw at it. Windows, Mac, uncompressed, compressed, old, new... it should happily read 'em all. If you have trouble with a file, I'd love to get a copy and make bioread work with it.

Installation

We're up in pypi, so installing should be as simple as:

pip install bioread

Some of the optional parts of bioread depend on external libraries. acq2hdf5 depends on h5py and acq2mat depends on scipy, but as neither of those are core parts of bioread (and can be hairy to get working on some systems), they aren't installed by default. To get them, do:

```

Just h5py

pip install bioread[hdf5]

Just scipy

pip install bioread[mat]

The whole shebang

pip install bioread[all] ```

As of March 2025, we're testing with python 3.10 — 3.13. bioread 1.0.4 and below should work with Python 2.7 and up.

API Usage:

Command-line usage:

acq2hdf5

If you want to convert files out of AcqKnowledge, this is probably what you want to use -- Matlab can read these out of the box and there are libraries for R and such. This converts the file, storing channels as datasets with names like /channels/channel_0 and metadata in attributes. Event markers are stored in /event_markers/marker_X

``` Convert an AcqKnowledge file to an HDF5 file.

Usage: acq2hdf5 [options] acq2hdf5 -h | --help acq2hdf5 --version

Options: --values-as= Save raw measurement values, stored as integers in the base file, as either 'raw' or 'scaled'. If stored as raw, you can convert to scaled using the scale and offset attributes on the channel. If storing scaled values, scale and offset will be 1 and 0. [default: scaled] --compress= How to compress data. Options are gzip, lzf, none. [default: gzip] --data-only Only save data and required headers -- do not save journal or marker information. -v, --verbose Print extra messages for debugging. ```

Note this does not need to read the entire dataset into memory, so if you have a 2G dataset, this will work great.

To get the values you see in AcqKnowledge, leave the --values-as option to its default ('scaled'). For faster performance, less memory usage, and smaller files, you can use 'raw' and convert the channel later (if you care) with the scale and offset attributes.

Generally, gzip compression seems to work very well, but if you're making something really big you might want to use lzf (worse compression, much faster).

What you'll find in the file:

Root-level attributes:

  • file_revision The internal AckKnowledge file version number
  • samples_per_second The base sampling rate of the file
  • byte_order The original file's byte ordering
  • journal The file's journal data.

Channel-level attributes:

  • scale The scale factor of raw data (for float-type data, will be 1)
  • offset The offset of raw data (for float-type data, will be 0)
  • frequency_divider The sampling rate divider for this channel
  • samples_per_second The channel's sampling rate
  • name The name of the channel
  • units The units for the channel
  • channel_number The display number for the channel (used in markers)

Markers

  • label A text label for the channel
  • type A description of this marker's type
  • type_code A short, 4-character code for type
  • global_sample_index The index, in units of the main sampling rate, of this marker
  • channel A hard link to the referred channel (only for non-global events)
  • channel_number The display number for the channel (only for non-global events)
  • channel_sample_index The in the channel's data where this marker belongs (only for non-global events)

acq2mat

Note: I recommend acq2hdf5 for exporting to Matlab. This program is still around because hey: It works.

This program creates a Matlab (version 5) file from an AcqKnowledge file. On the back-end, it uses scipy.io.savemat. Channels are stored in a cell array named 'channels'.

``` Convert an AcqKnowledge file to a MATLAB file.

This program is deprecated -- MATLAB can read HDF5 files natively, so I highly recommend using acq2hdf5 instead.

Usage: acq2mat [options] acq2mat -h | --help acq2mat --version

Options: -c, --compress Save compressed Matlab file -s, --single Save data in single precision format --data-only Only save data and required metadata -- do not save event markers, journal, or most header information

Note: scipy is required for this program. ```

If you've saved a file as myfile.mat, you can, in Matlab:

```

data = load('myfile.mat')

data =

          channels: {1x2 cell}
           markers: {1x3 cell}
           headers: [1x1 struct]
samples_per_second: 1000

data.channels{1}

ans =

             units: 'Percent'
 frequency_divider: 1
samples_per_second: 1000
              data: [1x10002 double]
              name: 'CO2'

plot(data.channels{1}.data)

(Plots the data)

data.markers{1}

ans =

       style: 'apnd'
sample_index: 0
       label: 'Segment 1'
     channel: Global

```

acq2txt

acq2txt will take the data in an AcqKnowledge file and write it to a tab-delimited text file. By default, all channels (plus a time index) will be written.

``` Write the data from an AcqKnowledge file channel to a text file.

Usage: acq2txt [options] acq2txt -h | --help acq2txt --version

Options: --version Show program's version number and exit. -h, --help Show this help message and exit. --channel-indexes= The indexes of the channels to extract. Separate numbers with commas. Default is to extract all channels. -o, --outfile= Write to a file instead of standard out. --missing-as= What value to write where a channel is not sampled. [default: ]

The first column will always be time in seconds. Channel raw values are converted with scale and offset into native units. ```

acq_info

acq_info prints out some simple debugging information about an AcqKnowledge file. It'll do its best to print something out even for damaged files.

``` Print some information about an AcqKnowledge file.

Usage: acqinfo [options] <acqfile> acqinfo -h | --help acqinfo --version

Options: -d, --debug print lots of debugging data

Note: Using - for reads from stdin. ```

As noted in the usage instructions, acq_info will read from stdin, so if your files are gzipped, you can say:

zcat myfile.acq.gz | acq_info -

acq_markers

Prints all of the markers in an AcqKnowlege file to a tab-delimited format, either to stdout or to a specified file. Fields are:

filename time (s) label channel style

``` Print the event markers from an AcqKnowledge file.

Usage: acqmarkers [options] ... acqmarkers -h | --help acq_markers --version

Options: -o Write to a file instead of standard output. ```

Note that this one does not read from stdin; in this case, printing the markers from a large number of files was more important than feeding from zcat or something.

acq_layout

Useful for debugging and/or adding support for new AcqKnowledge versions, acq_layout prints the data layout of an AcqKnowledge file, and what header classes are used for all the parts.

``` Print the binary layout of an AcqKnowledge file.

Usage: acqlayout [options] <acqfile> acqlayout -h | --help acqlayout --version

Options: -t, --truncate=num Truncate arrays and byte strings to this length. 0 means no truncation. [default: 16] --max-data=num Maximum number of data bytes to print [default: 16] -x, --hex Print offsets and lengths in hex -d, --debug Print lots of debugging data ```

Notes

I've tested all the various vintages of files I can think of and find, except very old (AcqKnowledge 2.x) files.

Also, the channel order I read is not the one displayed in the AcqKnowledge interface. Neither the order of the data nor any channel header value I can find seems to entirely control that. I'm gonna just assume it's not a very big deal.

File Format Documentation

While there's no substite for code diving to see how things really work, I've written some quick documentation of the file format.

In addition, developer Mike Davison did a great job figuring out additional .acq file format information (far more than is implemented in bioread!); his contribuions are in notes/acqknowledgefilestructure.pdf

Credits

This code was pretty much all written by Nate Vack njvack@wisc.edu, with a lot of initial research done by John Ollinger.

Copyright & Disclaimers

bioread is distributed under the MIT license. For more details, see LICENSE.

BIOPAC and AcqKnowledge are trademarks of BIOPAC Systems, Inc. The authors of this software have no affiliation with BIOPAC Systems, Inc, and that company neither supports nor endorses this software package.

Owner

  • Name: Center for Healthy Minds
  • Login: uwmadison-chm
  • Kind: organization
  • Location: Madison, WI

The Center for Healthy Minds at UW-Madison

GitHub Events

Total
  • Create event: 5
  • Release event: 4
  • Issues event: 10
  • Watch event: 10
  • Issue comment event: 29
  • Push event: 28
  • Pull request event: 3
  • Fork event: 3
Last Year
  • Create event: 5
  • Release event: 4
  • Issues event: 10
  • Watch event: 10
  • Issue comment event: 29
  • Push event: 28
  • Pull request event: 3
  • Fork event: 3

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 339
  • Total Committers: 9
  • Avg Commits per committer: 37.667
  • Development Distribution Score (DDS): 0.112
Past Year
  • Commits: 6
  • Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Nate Vack n****k@w****u 301
Nate Vack n****k@z****) 9
Stefano Moia s****a@b****u 7
Dan Fitch d****h@g****m 5
pvelasco p****o@n****u 4
Louis Mayaud l****s@y****m 4
Daniel Hornung d****g@d****e 4
Nathan Vack n****e@g****s 4
Çağrı Özkurt c****t@p****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 38
  • Total pull requests: 13
  • Average time to close issues: 8 months
  • Average time to close pull requests: 7 months
  • Total issue authors: 25
  • Total pull request authors: 9
  • Average comments per issue: 3.79
  • Average comments per pull request: 3.23
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 2
  • Average time to close issues: 4 months
  • Average time to close pull requests: 6 months
  • Issue authors: 3
  • Pull request authors: 2
  • Average comments per issue: 6.0
  • Average comments per pull request: 3.5
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • njvack (12)
  • PhoenixAlx (2)
  • 2puppies (2)
  • bobchicken (1)
  • benoitvalery (1)
  • MitchFrankel (1)
  • expensne (1)
  • irmakoz1 (1)
  • bccummings (1)
  • dgfitch (1)
  • agharibans (1)
  • sakluk (1)
  • bpinsard (1)
  • basgoncalves (1)
  • dominik-weber-92 (1)
Pull Request Authors
  • dgfitch (4)
  • quazgar (3)
  • sdevenes (2)
  • cagriozkurt (1)
  • smoia (1)
  • louis-youpling (1)
  • DominiqueMakowski (1)
  • DerAndereJohannes (1)
  • pvelasco (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 2,082 last-month
  • Total docker downloads: 41
  • Total dependent packages: 8
    (may contain duplicates)
  • Total dependent repositories: 20
    (may contain duplicates)
  • Total versions: 39
  • Total maintainers: 4
pypi.org: bioread

Utilities to read BIOPAC AcqKnowledge files

  • Versions: 37
  • Dependent Packages: 8
  • Dependent Repositories: 20
  • Downloads: 2,069 Last month
  • Docker Downloads: 41
Rankings
Dependent packages count: 1.1%
Dependent repos count: 3.2%
Docker downloads count: 3.4%
Average: 5.5%
Downloads: 8.1%
Forks count: 8.2%
Stargazers count: 8.6%
Maintainers (3)
Last synced: 8 months ago
pypi.org: meng-bioread

A modified version of bioread

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 13 Last month
Rankings
Dependent packages count: 9.8%
Average: 32.4%
Dependent repos count: 55.0%
Maintainers (1)
Last synced: 8 months ago

Dependencies

.github/workflows/pythonpackage.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
pyproject.toml pypi
  • docopt >=0.6.1
  • numpy >=2.2.3
  • pytest >=8.3.4