Sensorlog app CSV files

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Stuart McNeill
Posts: 5
Joined: Sun Jan 05, 2020 11:26 am

Sensorlog app CSV files

Post by Stuart McNeill » Sun Jan 05, 2020 12:39 pm

Hi all,

I am new to here and was wondering if anyone has tried using data from an iPhone via an app 'Sensorlog' (http://www.berndthomas.net) and could OpenSim use this data to look at the quaternions - rotational axis and rotational angle? The sensorlog app can output CSV files however OpenSim doesn't seem to use this file format. Has anyone ever used this data file format or found a work-around/ways to look at this data?

Many Thanks
Stuart McNeill

Tags:

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: Sensorlog app CSV files

Post by Ayman Habib » Tue Jan 07, 2020 11:55 am

Hi Stuart,

OpenSim 4.1 (now available in Beta on the downloads page) has examples of parsing csv files of sensor data exported by APDM. I don't know if the quantities exported and the labels match those in Sensorlog csv files. If not then you can either write your own parser based on our code or write a converter from Sensorlog to APDM file formats.

Hope this helps,
-Ayman

User avatar
Stuart McNeill
Posts: 5
Joined: Sun Jan 05, 2020 11:26 am

Re: Sensorlog app CSV files

Post by Stuart McNeill » Mon Jan 13, 2020 2:13 pm

Thanks Ayman,

I have downloaded Opensim 4.1 and c3d2OpenSim to try to access the CSV file but require markers which the sensorlog data doesn't capture, the IMU is the apple iphone, this is the type of data the app can collect:, loggingTime(txt) loggingSample(N) accelerometerTimestamp_sinceReboot(s) accelerometerAccelerationX(G) accelerometerAccelerationY(G) accelerometerAccelerationZ(G) motionTimestamp_sinceReboot(s) motionYaw(rad) motionRoll(rad) motionPitch(rad) motionRotationRateX(rad/s) motionRotationRateY(rad/s) motionRotationRateZ(rad/s) motionUserAccelerationX(G) motionUserAccelerationY(G) motionUserAccelerationZ(G) motionAttitudeReferenceFrame(txt) motionQuaternionX(R) motionQuaternionY(R) motionQuaternionZ(R) motionQuaternionW(R) motionGravityX(G) motionGravityY(G) motionGravityZ(G).
I was wondering if this data would be useful in OpenSim for analysing a segment?
Thanks for your help.

Many Thanks
Stuart

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: Sensorlog app CSV files

Post by Ayman Habib » Mon Jan 13, 2020 4:44 pm

Hi Stuart,

There's no need to use c3d2OpenSim, just check the example code parsing CSV files from APDM here
https://simtk-confluence.stanford.edu/d ... h+IMU+Data
and check the corresponding data files here
https://github.com/opensim-org/opensim- ... UData/APDM
and you'll realize that we parse/use the same data you reported, the headers maybe different so you can either modify the parser code or modify the file contents/headers to match APDM format.
We use the Quaternions directly from the file to compute orientations.

Hope this helps,
-Ayman

User avatar
Stuart McNeill
Posts: 5
Joined: Sun Jan 05, 2020 11:26 am

Re: Sensorlog app CSV files

Post by Stuart McNeill » Fri Jan 17, 2020 2:05 pm

Thanks Ayman

I've managed to get CSV APDM format 7 from GitHub, I'm not sure about the header information but is there any reason behind numbers 5718 Lumber/5778 Right Ankle/5811 Left Ankle/6570 Left foot/6575 Chest/6833 Right Foot?
Is there a specific number system for segment parts? if so do you have a list of these codes plus all the segment/body part they represent?

Does it matter if the IMU sensor data doesn't have a Barometer or Magnetometer?

Many Thanks
Stuart

User avatar
Stuart McNeill
Posts: 5
Joined: Sun Jan 05, 2020 11:26 am

Re: Sensorlog app CSV files

Post by Stuart McNeill » Wed Jan 29, 2020 2:00 pm

Okay I have modified the CSV file headers to match the APDM format.
Screenshot 2020-01-28 at 19.50.29.png
Screenshot 2020-01-28 at 19.50.29.png (75.22 KiB) Viewed 488 times
The sensorlog app in the iPhone app exports csv and json file formats.
Can I use this raw data even though I haven't ran sensor fusion, time syncing, and data interpolation on the data?
Then is the next step is to create a txt file from this data for each sensor like the Xsens like: (https://github.com/opensim-org/opensim- ... B421E6.txt)
If so, could you tell me what each column header stands for and where to put the data, I have a sneaky suspicion Acc_ means the value for the accelerometer ;) ;
PacketCounter SampleTimeFine Year Month Day Second UTC_Nano UTC_Year UTC_Month UTC_Day UTC_Hour UTC_Minute UTC_Second UTC_Valid Acc_X Acc_Y Acc_Z Mat[1][1] Mat[2][1] Mat[3][1] Mat[1][2] Mat[2][2] Mat[3][2] Mat[1][3] Mat[2][3] Mat[3][3]

I have also created the myIMUMappings xml file attached, that would be the two sensors that I have data for.
If someone could give me a few pointers, I would be very grateful.
Attachments
myIMUMappings.xml
(10.82 KiB) Downloaded 12 times

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: Sensorlog app CSV files

Post by Ayman Habib » Thu Jan 30, 2020 11:56 am

Hi Stuart,

The numbers in the APDM header file are not fixed and are not used downstream so you can leave blank or put any number, the names are used downstream to associate IMUs from the data file to bodies in an OpenSim model. The association is done through an XML file so the names actually are arbitrary as long as they are unique.

We assume the fusion was done by the user or manufacturer before bringing the data over for processing, this was done because it depends on the capabilities of the IMUs and hardware, but we plan to address sensor fusion in the future. I think APDM does the synchronization using the packet number so you could find something similar but the internals of the synchronization algorithm are typically proprietary so we can't be sure.

The Acc is accelerometer, and the Mat[] is a rotation matrix for the corresponding sensor.

Hope this helps, and thanks for trying this out.
-Ayman

User avatar
Stuart McNeill
Posts: 5
Joined: Sun Jan 05, 2020 11:26 am

Re: Sensorlog app CSV files

Post by Stuart McNeill » Thu Jan 30, 2020 1:56 pm

Thanks Ayman for getting back to me.

Sorry for asking all these questions, I am a newbie here and I can somewhat understand the xml code but I am finding it difficult with the process/steps that I need to follow from the web page,
https://simtk-confluence.stanford.edu:8 ... h+IMU+Data

its just me being new here, do I need to use or follow the Matlab/Terminal scripting?

The txt files in your IMUData examples folder, I know are from the Xsens sensor device, however I'm using an iPhone with CSV data, is this data the same data from the csv file that I have modified the headers to APDM format? that I now also need to re-format/copy to a txt file with Acc value, how do I find the rotation matrix from the apple sensor, is this the quaternion s, x, y, z values?

Sorry and Many Thanks
Stuart

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: Sensorlog app CSV files

Post by Ayman Habib » Fri Jan 31, 2020 4:58 pm

No worries Stuart,

The functionality is rather new so if there's anything we can do to ease users into it please let us know.

You could either use the API in Matlab or Python to create tables or files or use XML files and modify the contents of your data files to match the format that the code uses, your choice and it also depends on what setting you're more comfortable with.

The documentation for the file formats from manufacturers is also rather sparse, one specifies rotations as Quaternions that are read in as is, while the other provides rotation matrices (3x3) and we convert them internally to Quaternions for use by our algorithms.

Hope this helps,

Ayman

User avatar
Divyansh Gupta
Posts: 9
Joined: Fri Aug 09, 2019 4:31 am

Re: Sensorlog app CSV files

Post by Divyansh Gupta » Sat Feb 01, 2020 12:34 am

Hi, I am working on something similar using MPU9250. Can you please give some insights on whether there is a need for Barometer data while using APDM format or can we skip it?

POST REPLY