Convert .mat/csv file to c3d or trc
- Reuben Addison
- Posts: 7
- Joined: Mon Aug 20, 2018 11:18 am
Convert .mat/csv file to c3d or trc
How do you convert a .mat or csv file to c3d motion data. I want to import the data into OpenSim for processing. But if I am to get it into just c3d I can do the rest. The data was download from an open source repository.
Tags:
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: Convert .mat/csv file to c3d or trc
Hi,
I would suggest you use the BTK package.
http://biomechanical-toolkit.github.io/ ... ng/Matlab/
If you have a double which contains XYZ of whole markers, first convert it to a struct:
Then use BTK for creating a c3d file:
You can set the analog and force data to your file too.
But isn't it more convenient to generate OpenSim required files from your CSV or mat data without converting them to a c3d file?
You have all, just write them as an ASCII (trc or mot) or use OpenSim functions instead.
Hope this helps.
Regards
I would suggest you use the BTK package.
http://biomechanical-toolkit.github.io/ ... ng/Matlab/
If you have a double which contains XYZ of whole markers, first convert it to a struct:
Code: Select all
data = struct; % create an empty struct
for i = 1:Nmarkers % number of markers
data.(lables{i}) = markers(:,[3*i-2 3*i-1 3*i]); % lables is a cell contains the marker labels
end
Code: Select all
acq = btkNewAcquisition(Nmarkers, frames ); % number of markers and frames
btkSetFrequency(acq, Rmarkers); % sampling frequency
for i = 1:Nmarkers
btkSetPointLabel(acq, i, lables{i});
btkSetPoint(acq, i, data.(lables{i}));
end
btkWriteAcquisition(acq, 'NEW.c3d');
But isn't it more convenient to generate OpenSim required files from your CSV or mat data without converting them to a c3d file?
You have all, just write them as an ASCII (trc or mot) or use OpenSim functions instead.
Hope this helps.
Regards
- Reuben Addison
- Posts: 7
- Joined: Mon Aug 20, 2018 11:18 am
Re: Convert .mat/csv file to c3d or trc
Thank you. My Btk is crushing my Matlab so I will use the second alternative