Skip to main content

adinstruments_sdk_python

Use this code to read .adicht (Labchart) files into Python. Interfacing with the ADIstruments DLL is done via cffi.

  • The code utilizes the SDK from ADIstruments to read files in Python as NumPy arrays.
  • Currently only works for Windows. Not fixable by me, requires changes by ADInstruments
  • A slightly more fleshed out MATLAB version can be found here.
  • Currently requires Python 3.6-3.14 with some of the newer versions requiring 64 bit Python (this can change but requires some work on my end)

Installation

pip install adi-reader

Support Notes

My ability to work on this code was supported, in part, by a grant from the NIH NIDDK (grant: R21DK140694)

Dependencies

  • cffi
  • NumPy
  • Python 3.7-3.14
    • might be able to do 3.6 but requires future annotations
  • Pandas - optional

Demo code

import adi
f = adi.read_file(r'C:\Users\RNEL\Desktop\test\test_file.adicht')
# All id numbering is 1 based, first channel, first block
# When indexing in Python we need to shift by 1 for 0 based indexing
# Functions however respect the 1 based notation ...

# These may vary for your file ...
channel_id = 2
record_id = 1
data = f.channels[channel_id-1].get_data(record_id)

import matplotlib.pyplot as plt
plt.plot(data)
plt.show()
	

Grabbing data from a specific channel. Some advanced data retrieval functionality is also shown.

import adi
f = adi.read_file(r'C:\Users\RNEL\Desktop\test\test_file.adicht')
#Note, this defaults to a partial, case insensitive match
p = f.get_channel_by_name('pres')

record_id = 1
#time units are in seconds
time,data = p.get_data(record_id,start_time=10,return_time=True)


plt.plot(time,data)
plt.xlabel('time (s)')
plt.ylabel(f'{p.name} ({p.units[record_id]})')
plt.show()

Here's an example of working with comment data.

import adi

fp = r"D:\Data\Duke\PGE2_2017\140414_C_01_pelvic and hypogastric recording PGE2 model .adicht"

f = adi.read_file(fp)

#default is a list, could also return as a dataframe
comments = f.get_comments(return_as='object')

#You can throw a warning or an error (or ignore) unmatched pairs
# - 'ignore'
# - 'error'
# - 'warn'
#You can skip, allow, or throw an error for matches spanning records
# - 'skip'
# - 'allow'
# - 'error'
pairs = comments.get_comment_pairs("start pump","stop pump",unmatched='ignore',record_split="skip")

p_chan = adi.get_channel_by_name('pres')
id_pair = [pairs.id1[0],pairs.id2[0]]
#Passing in a pair of IDs for comment_range is sufficient to identify
#the time range. Note they currently need to be in the same record_id
#
#The record_id input is ignored, so I just pass in -1
time,data = p_chan.get_data(-1, comment_range=id_pair,return_time=True)

import matplotlib.pyplot as plt
plt.plot(time,data)
plt.show()

Data Model

Data are collected in blocks or records, starting at record 1. For each record the channel properties can change (units, sampling rate). Every time settings are changed or recording stops, a new block is created (once recording starts again).

The two primary data types that are exposed through the SDK are:

  • channel data
  • comments - time of comment and text information (along with an id and info on which channel the comment applies to)

There are other things that are collected in LabChart files, but these are not exposed via the SDK.

  • file
    • records
      • timing info
      • comments
    • channels
      • data

Improvements

Feel free to open pull requests or to open issues.

Things I would like to add at some point:

  • a general review tool that plots a file
  • even simpler, plotting a channel with comments
  • better method support for getting specific info
  • better functionality of data retrieval

Change Notes

  • 2026-04-12 :
    • Added 3.14 support
    • Improved documentation

Metadata

Release files for adi-reader 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adi-reader 0.2.0
File Size Uploaded
adi_reader-0.2.0.tar.gz 1.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for adi-reader 0.2.0
File Interpreter ABI Platform
adi_reader-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.8 MB

Release files / adi_reader-0.2.0.tar.gz

Download URL adi_reader-0.2.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
55e93998407b2cf6e9a347eee7c4cbcf583e4aa3961357124d432806e901a4a5
BLAKE2b-256 checksum
How to use checksums
0a3199eb78fb548872832bf7e94e9250f57825a79f1cb0f9e839a363590d8d71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / adi_reader-0.2.0-py3-none-any.whl

Download URL adi_reader-0.2.0-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0da80dcaa89e9a578fa1809df9e68101ccabfa2d2fbba5b11737b86f7dd99118
BLAKE2b-256 checksum
How to use checksums
c725f45e4980dd830bdac9c02f1f5f06d2855ac4006737c3ab364dfcc98ed96b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page