# adinstruments_sdk_python
Use this code to read .adicht (Labchart) files into Python. Interfacing with the ADIstruments DLL is done via [cffi](https://cffi.readthedocs.io/en/latest/).
- 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](https://github.com/JimHokanson/adinstruments_sdk_matlab).
- 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 ##
```python
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 ##
- [cffi](https://cffi.readthedocs.io/en/latest/)
- [NumPy](https://numpy.org/)
- Python 3.6-3.11
----
## 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).
![image](https://github.com/JimHokanson/adinstruments_sdk_python/assets/1593287/c94114a7-4cc1-4c59-a25a-f319d02402d9)
```python
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 drive `e:` changes to the E drive and then cd'd to the directory to run:
- `python setup.py sdist bdist_wheel`
- `twine upload dist/*`
## Improvements ##
This was written extremely quickly and is missing some features. Feel free to open pull requests or to open issues.
Raw data
{
"_id": null,
"home_page": "https://github.com/JimHokanson/adinstruments_sdk_python/",
"name": "adi-reader",
"maintainer": null,
"docs_url": null,
"requires_python": "<=3.13,>=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Jim Hokanson",
"author_email": "jim.hokanson@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/13/fb/84142d084bf641e348c19449e595e5edc92c65fddbd37f058c1474ce6d14/adi_reader-0.0.13.tar.gz",
"platform": null,
"description": "# adinstruments_sdk_python\r\n\r\nUse this code to read .adicht (Labchart) files into Python. Interfacing with the ADIstruments DLL is done via [cffi](https://cffi.readthedocs.io/en/latest/).\r\n\r\n- The code utilizes the SDK from ADIstruments to read files in Python as NumPy arrays.\r\n- **Currently only works for Windows. Not fixable by me, requires changes by ADInstruments**\r\n- A slightly more fleshed out Matlab version can be found [here](https://github.com/JimHokanson/adinstruments_sdk_matlab).\r\n- 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)\r\n\r\n---\r\n\r\n## Installation ##\r\n\r\n\tpip install adi-reader\r\n\r\n----\r\n\r\n## Test code ##\r\n\r\n```python\r\n import adi\r\n f = adi.read_file(r'C:\\Users\\RNEL\\Desktop\\test\\test_file.adicht')\r\n # All id numbering is 1 based, first channel, first block\r\n # When indexing in Python we need to shift by 1 for 0 based indexing\r\n # Functions however respect the 1 based notation ...\r\n \r\n # These may vary for your file ...\r\n channel_id = 2\r\n record_id = 1\r\n data = f.channels[channel_id-1].get_data(record_id)\r\n import matplotlib.pyplot as plt\r\n plt.plot(data)\r\n plt.show()\r\n```\r\n----\r\n\r\n## Dependencies ##\r\n- [cffi](https://cffi.readthedocs.io/en/latest/)\r\n- [NumPy](https://numpy.org/)\r\n- Python 3.6-3.11\r\n----\r\n\r\n## Setup for other Python versions ##\r\n\r\n- Running the code might require compiling the cffi code depending on your Python version. \r\n- This requires running cffi_build.py in the adi package. \r\n- This might require installing cffi as well as some version of Visual Studio. \r\n- The currently released code was compiled for Python 3.6-3.9 on Visual Studio 14.0 or greater was required.\r\n\r\nFor upgrading to 3.8, I installed Python 3.8. Within the interpreter I ran the following:\r\n\r\n- Jim note to self, rather than installing Anaconda I simply:\r\n - download Python from https://www.python.org/downloads/windows/\r\n - cd to Python directory or run directly, these go to something like: `C:\\Users\\RNEL\\AppData\\Local\\Programs\\Python\\Python39-32\\python` \r\n - Note the above path is specific to my computer, might need to change user name\r\n - 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).\r\n \r\n ![image](https://github.com/JimHokanson/adinstruments_sdk_python/assets/1593287/c94114a7-4cc1-4c59-a25a-f319d02402d9)\r\n\r\n\r\n```python\r\nimport subprocess\r\nimport sys\r\n\r\n#https://stackoverflow.com/questions/12332975/installing-python-module-within-code\r\ndef install(package):\r\n subprocess.call([sys.executable, \"-m\", \"pip\", \"install\", package])\r\n\r\ninstall(\"setuptools\")\r\ninstall(\"cffi\")\r\n\r\nimport os\r\n#This would need to be changed based on where you keep the code\r\nos.chdir('E:/repos/python/adinstruments_sdk_python/adi')\r\n\r\n# For 64 bit windows\r\nexec(open(\"cffi_build.py\").read())\r\n\r\n\r\n\r\n#------------------------- ONLY IF 32 BIT WINDOWS -------------------\r\n# For 32 bit windows\r\nexec(open(\"cffi_build_win32.py\").read())\r\n```\r\n----\r\n\r\n## PyPi Notes ##\r\n\r\n- update version in setup.py\r\n- update Python version in setup.py\r\n- from Anaconda I ran the command line in my enviroment and made sure twine was installed `pip install twine`. Then I changed my drive `e:` changes to the E drive and then cd'd to the directory to run:\r\n - `python setup.py sdist bdist_wheel`\r\n - `twine upload dist/*`\r\n\r\n\r\n## Improvements ##\r\n\r\nThis was written extremely quickly and is missing some features. Feel free to open pull requests or to open issues.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Reading LabChart recorded data",
"version": "0.0.13",
"project_urls": {
"Homepage": "https://github.com/JimHokanson/adinstruments_sdk_python/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fff9fcf042145766ee879c379ce625e48ca54f783d73c8c314a1de2b90121573",
"md5": "2a4a99686a455ef15116be9762c0ce65",
"sha256": "be2897c3dd3ff98c33a81ad8d5e342df2b62b7dd3ffc306012717957c98f4f3d"
},
"downloads": -1,
"filename": "adi_reader-0.0.13-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2a4a99686a455ef15116be9762c0ce65",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<=3.13,>=3.6",
"size": 1437014,
"upload_time": "2024-12-02T02:28:35",
"upload_time_iso_8601": "2024-12-02T02:28:35.502884Z",
"url": "https://files.pythonhosted.org/packages/ff/f9/fcf042145766ee879c379ce625e48ca54f783d73c8c314a1de2b90121573/adi_reader-0.0.13-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "13fb84142d084bf641e348c19449e595e5edc92c65fddbd37f058c1474ce6d14",
"md5": "8610ab5117a2bf69fdae114c7302f46d",
"sha256": "657a15a5824b1a4182d1f16583e58703d67b002f91585e427588389067fddeb8"
},
"downloads": -1,
"filename": "adi_reader-0.0.13.tar.gz",
"has_sig": false,
"md5_digest": "8610ab5117a2bf69fdae114c7302f46d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<=3.13,>=3.6",
"size": 1361923,
"upload_time": "2024-12-02T02:28:41",
"upload_time_iso_8601": "2024-12-02T02:28:41.931678Z",
"url": "https://files.pythonhosted.org/packages/13/fb/84142d084bf641e348c19449e595e5edc92c65fddbd37f058c1474ce6d14/adi_reader-0.0.13.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-02 02:28:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "JimHokanson",
"github_project": "adinstruments_sdk_python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "adi-reader"
}