Reading LabChart recorded data
Project description
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.11 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
Test 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()
Dependencies
Setup for other Python versions
- Running the code might require compiling the cffi code depending on your Python version.
- This requires running cffi_build.py in the adi package.
- This might require installing cffi as well as some version of Visual Studio.
- The currently released code was compiled for Python 3.6-3.9 on Visual Studio 14.0 or greater was required.
For upgrading to 3.8, I installed Python 3.8. Within the interpreter I ran the following:
-
Jim note to self, rather than installing Anaconda I simply:
- download Python from https://www.python.org/downloads/windows/
- cd to Python directory or run directly, these go to something like:
C:\Users\RNEL\AppData\Local\Programs\Python\Python39-32\python - Note the above path is specific to my computer, might need to change user name
- This has result in an error that I need MS C++ Build tools : "Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/" Ultimately I had to install the package along with the correct OS SDK (Windows 10 SDK for me).
import subprocess
import sys
#https://stackoverflow.com/questions/12332975/installing-python-module-within-code
def install(package):
subprocess.call([sys.executable, "-m", "pip", "install", package])
install("setuptools")
install("cffi")
import os
#This would need to be changed based on where you keep the code
os.chdir('E:/repos/python/adinstruments_sdk_python/adi')
# For 64 bit windows
exec(open("cffi_build.py").read())
#------------------------- ONLY IF 32 BIT WINDOWS -------------------
# For 32 bit windows
exec(open("cffi_build_win32.py").read())
PyPi Notes
- update version in setup.py
- update Python version in setup.py
- from Anaconda I ran the command line in my enviroment and made sure twine was installed
pip install twine. Then I changed my drivee:changes to the E drive and then cd'd to the directory to run:python setup.py sdist bdist_wheeltwine upload dist/*
Improvements
This was written extremely quickly and is missing some features. Feel free to open pull requests or to open issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adi_reader-0.0.13.tar.gz.
File metadata
- Download URL: adi_reader-0.0.13.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
657a15a5824b1a4182d1f16583e58703d67b002f91585e427588389067fddeb8
|
|
| MD5 |
8610ab5117a2bf69fdae114c7302f46d
|
|
| BLAKE2b-256 |
13fb84142d084bf641e348c19449e595e5edc92c65fddbd37f058c1474ce6d14
|
File details
Details for the file adi_reader-0.0.13-py3-none-any.whl.
File metadata
- Download URL: adi_reader-0.0.13-py3-none-any.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be2897c3dd3ff98c33a81ad8d5e342df2b62b7dd3ffc306012717957c98f4f3d
|
|
| MD5 |
2a4a99686a455ef15116be9762c0ce65
|
|
| BLAKE2b-256 |
fff9fcf042145766ee879c379ce625e48ca54f783d73c8c314a1de2b90121573
|