Opensim for use with XSENS

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Ioanna Deroukaki
Posts: 2
Joined: Thu Nov 23, 2023 6:55 am

Opensim for use with XSENS

Post by Ioanna Deroukaki » Tue Jan 23, 2024 5:14 am

I am writing on behalf of an ergonomics group in Cardiff university, working on a project involving analysis of ACL strain, using data from an XSENS suit (with no force plates).

At the moment we are trying to scale the generic model. We have been using a .trc file that we created using a c3d toolkit, that convert c3d data to .trc. The c3d file was derived from XSENS analyse, where the participant stayed still in a T-pose for 5 seconds.
We have also tried to convert the c3d file to an xml file to get the marker set, which we have done using a btk toolkit in matlab to read the c3d file and extract the marker set, and the xml_writeOSIM.m file to write the xml file. When we load those files for scaling, it seems to be working, however when we try the inverse kinematics step, it comes up with a no marker error.

Below is our matlab code to convert the .c3d file to a .xml.
Subject1.xml
XML file used for scaling
(11.3 KiB) Downloaded 14 times
% Add BTK to MATLAB path
addpath('C:\Users\User\Downloads\BTKCore-master\Build\Bin\Debug');

% Specify the path to your C3D file
c3dFilePath = 'C:\Users\User\Downloads\LangXi-2\Subject1.c3d'

% Read the C3D file using BTK
acq = btkReadAcquisition(c3dFilePath);
% Extract marker data from the acquisition
markers = btkGetMarkers(acq);

% Convert marker data into a structure format expected by OpenSim
OpenSimMarkers = struct();
OpenSimMarkers.OpenSimDocument.Version = '40000';
OpenSimMarkers.OpenSimDocument.MarkerSet.objects = struct();

markerNames = fieldnames(markers);
for i = 1:length(markerNames)
markerName = markerNames{i};
markerData = markers.(markerName);
OpenSimMarkers.OpenSimDocument.MarkerSet.objects.(markerName) = struct();
OpenSimMarkers.OpenSimDocument.MarkerSet.objects.(markerName).Marker = struct();
OpenSimMarkers.OpenSimDocument.MarkerSet.objects.(markerName).Marker.location = markerData(1, :);
end

% Specify the path for the output XML file
xmlOutputPath = 'C:\Users\User\Downloads\Subject1\Subject1.xml';


% Save the OpenSim marker structure as an XML file
xml_writeOSIM(xmlOutputPath, OpenSimMarkers);

% Display completion message
disp('C3D file has been converted to XML format.');

Tags:

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

Re: Opensim for use with XSENS

Post by Ayman Habib » Tue Jan 23, 2024 12:36 pm

Hello,

Can you step back a second and explain why you're trying to convert timeseries data (as represented by c3d file) into an XML file that contains fixed marker locations? What is your planned workflow?

Typically the markers live on different segments/frames of the model while the c3d data is all in ground frame. The attached xml file has no body specification for any of the markers.

Hope this helps,
-Ayman

POST REPLY