/endaq-python-ide

Primary LanguagePythonMIT LicenseMIT

NOTE This package is now part of the main endaq repo, and can be found at https://github.com/MideTechnology/endaq-python/tree/development/endaq/ide This repo is Archived

endaq-ide

endaq.ide contains high-level utility functions to aid in importing and inspecting enDAQ IDE recording files. Key functions/features include:

  • get_channel_table(): Get summary information about the contents of a file.
  • get_doc(): Open an IDE, either locally or from a URL.
  • to_pandas(): Convert IDE data to a pandas DataFrame, for use with other packages.

Note: This is a component of the endaq package; it is separate to allow users to install it independently, avoiding the core endaq-python dependencies. It is included in a full endaq install.

endaq.ide usage examples

Here are a few examples of endaq.ide in use. For more information, see the full documentation.

For brevity, the following examples assume everything has been imported from endaq.ide:

from endaq.ide import *

Opening IDE files: endaq.ide.get_doc()

endaq.ide includes a convenient shortcut for importing IDE data: get_doc(). It can load data from local files, or read data directly from a URL.

doc = get_doc("tests/test.ide")
doc1 = get_doc("https://info.endaq.com/hubfs/data/surgical-instrument.ide")

IDE files can be retrieved directly from Google Drive using a Drive 'sharable link' URL. The file must be set to allow access to "Anyone with the link."

doc2 = get_doc("https://drive.google.com/file/d/1t3JqbZGhuZbIK9agH24YZIdVE26-NOF5/view?usp=sharing")

Whether opening a local file or a URL, get_doc() can be used to import only a specific interval by way of its start and end parameters:

doc3 = get_doc("tests/test.ide", start="5s", end="10s")

Summarizing IDE files: endaq.ide.get_channel_table()

Once an IDE file has been loaded, endaq.ide.get_channel_table() will retrieve basic summary information about its contents. Some environments, such as Jupyter Notebook or Colab, will automatically display the channel table data. From inside the Python Console, use get_channel_table(doc).data to display the information, or to access the table's contents directly as a pandas DataFrame.

get_channel_table(doc)
  channel name type units start end duration samples rate
0 32.0 X (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
1 32.1 Y (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
2 32.2 Z (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
3 80.0 X (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz
4 80.1 Y (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz
5 80.2 Z (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz
6 36.0 Pressure/Temperature:00 Pressure Pa 00:00.0945 00:19.0175 00:18.0230 20 1.10 Hz
7 36.1 Pressure/Temperature:01 Temperature °C 00:00.0945 00:19.0175 00:18.0230 20 1.10 Hz
8 70.0 X Quaternion q 00:01.0132 00:18.0954 00:17.0821 1755 98.47 Hz
9 70.1 Y Quaternion q 00:01.0132 00:18.0954 00:17.0821 1755 98.47 Hz
10 70.2 Z Quaternion q 00:01.0132 00:18.0954 00:17.0821 1755 98.47 Hz
11 70.3 W Quaternion q 00:01.0132 00:18.0954 00:17.0821 1755 98.47 Hz
12 59.0 Control Pad Pressure Pressure Pa 00:00.0979 00:18.0910 00:17.0931 180 10.04 Hz
13 59.1 Control Pad Temperature Temperature °C 00:00.0979 00:18.0910 00:17.0931 180 10.04 Hz
14 76.0 Lux Light Ill 00:00.0000 00:18.0737 00:18.0737 71 3.79 Hz
15 76.1 UV Light Index 00:00.0000 00:18.0737 00:18.0737 71 3.79 Hz

The results can be filtered by measurement type:

get_channel_table(doc, ACCELERATION)
  channel name type units start end duration samples rate
0 32.0 X (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
1 32.1 Y (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
2 32.2 Z (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
3 80.0 X (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz
4 80.1 Y (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz
5 80.2 Z (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz

Measurement types can be combined to retrieve more than one:

get_channel_table(doc, ACCELERATION+TEMPERATURE)
  channel name type units start end duration samples rate
0 32.0 X (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
1 32.1 Y (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
2 32.2 Z (16g) Acceleration g 00:00.0952 00:19.0012 00:18.0059 7113 393.86 Hz
3 80.0 X (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz
4 80.1 Y (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz
5 80.2 Z (8g) Acceleration g 00:00.0948 00:19.0013 00:18.0064 9070 502.09 Hz
6 36.1 Pressure/Temperature:01 Temperature °C 00:00.0945 00:19.0175 00:18.0230 20 1.10 Hz
7 59.1 Control Pad Temperature Temperature °C 00:00.0979 00:18.0910 00:17.0931 180 10.04 Hz

Information about a specific interval can be retrieved by using the start and/or end arguments. Note that due to different sampling rates, the start and end times for slower channels may not precisely match the specified start or end.

get_channel_table(doc, ACCELERATION+TEMPERATURE, start="0:05", end="0:10")
  channel name type units start end duration samples rate
0 32.0 X (16g) Acceleration g 00:05.0000 00:10.0001 00:05.0000 1969 393.75 Hz
1 32.1 Y (16g) Acceleration g 00:05.0000 00:10.0001 00:05.0000 1969 393.75 Hz
2 32.2 Z (16g) Acceleration g 00:05.0000 00:10.0001 00:05.0000 1969 393.75 Hz
3 80.0 X (8g) Acceleration g 00:05.0000 00:10.0001 00:05.0000 2510 501.98 Hz
4 80.1 Y (8g) Acceleration g 00:05.0000 00:10.0001 00:05.0000 2510 501.98 Hz
5 80.2 Z (8g) Acceleration g 00:05.0000 00:10.0001 00:05.0000 2510 501.98 Hz
6 36.1 Pressure/Temperature:01 Temperature °C 00:04.0954 00:10.0966 00:06.0011 6 1.00 Hz
7 59.1 Control Pad Temperature Temperature °C 00:05.0086 00:10.0095 00:05.0008 50 9.98 Hz

Extracting intervals: endaq.ide.extract_time()

A portion of an IDE file can be saved to another, new IDE. The source can be a local filename or an opened IDE (from a file or URL).

extract_time("tests/test.ide", "doc_extracted.ide", start="0:05", end="0:10")
extract_time(doc1, "doc1_extracted.ide", start="0:05", end="0:10")

Additional sample IDE recording files

Here are a number of example IDE files, which may be used with endaq.ide:

file_urls = ['https://info.endaq.com/hubfs/data/surgical-instrument.ide', 
             'https://info.endaq.com/hubfs/data/97c3990f-Drive-Home_70-1616632444.ide', 
             'https://info.endaq.com/hubfs/data/High-Drop.ide',
             'https://info.endaq.com/hubfs/data/HiTest-Shock.ide', 
             'https://info.endaq.com/hubfs/data/Drive-Home_01.ide', 
             'https://info.endaq.com/hubfs/data/Tower-of-Terror.ide',
             'https://info.endaq.com/hubfs/data/Punching-Bag.ide', 
             'https://info.endaq.com/hubfs/data/Gun-Stock.ide',
             'https://info.endaq.com/hubfs/data/Seat-Base_21.ide',
             'https://info.endaq.com/hubfs/data/Seat-Top_09.ide', 
             'https://info.endaq.com/hubfs/data/Bolted.ide',
             'https://info.endaq.com/hubfs/data/Motorcycle-Car-Crash.ide', 
             'https://info.endaq.com/hubfs/data/train-passing.ide', 
             'https://info.endaq.com/hubfs/data/baseball.ide',
             'https://info.endaq.com/hubfs/data/Clean-Room-VC.ide',
             'https://info.endaq.com/hubfs/data/enDAQ_Cropped.ide',
             'https://info.endaq.com/hubfs/data/Drive-Home_07.ide',
             'https://info.endaq.com/hubfs/data/ford_f150.ide',
             'https://info.endaq.com/hubfs/data/Drive-Home.ide',
             'https://info.endaq.com/hubfs/data/Mining-Data.ide',
             'https://info.endaq.com/hubfs/data/Mide-Airport-Drive-Lexus-Hybrid-Dash-W8.ide'] 

These can be directly read from endaq.com using endaq.ide.get_doc(), as previously described.