problem with btkSetAnglesValues

56 views
Skip to first unread message

debora

unread,
Oct 24, 2012, 5:31:57 AM10/24/12
to btk-...@googlegroups.com
I am trying to create a new c3d file with BTK in Matlab and I have a problem with btkSetAnglesValues.
my code is:
 
acq=btkNewAcquisition(20,2200)
btkSetFrequency(acq,200)
btkWriteAcquisition(acq,'PrimaProva.c3d')
[2200,3]=size(angle)
btkSetAnglesValues(acq,angle)

I get the following error message:
Error using btkSetAnglesValues
The second input doesn't have the same size than the number of
extracted points' components.


Does any of you have an idea what I am doing wrong?
Thank you for your answers in advance
Debora

Arnaud BARRE

unread,
Oct 24, 2012, 6:37:04 AM10/24/12
to btk-...@googlegroups.com
Hi Debora,

The function btkSetAnglesValues works as following:
 - From the given acquisition
   1. Extract angles
   2. Compare their dimensions with the dimensions of the given data
   3. Set angles' values with given data.

In your case, you have an error in the step 2. Indeed the step 1 return an empty set of angles as you create a new acquisition with by default only markers.

So your code should be modified like this:

acq=btkNewAcquisition(20,2200)
btkSetFrequency(acq,200)
for i = 1:20
  btkSetPointType(acq, i, 'Angle'); % The new type of the point
 
btkSetPoint(acq, i, data(i,:,1:3)) % the variable data is 20x2200x3
end
btkWriteAcquisition(acq,'PrimaProva.c3d')

It is also important to write the acquisition at the end, otherwise all modifications done after in the acquisition won't be saved.

Finally, you can also use the function
btkAppendPoint. The code will be slightly different:

acq=btkNewAcquisition(0,2200) % No points
btkSetFrequency(acq,200)
for i = 1:20
  btkAppendPoint(acq, 'Angle', ['Angle',num2str(i)], data(i,:,:));

  % Other example where labels is a cell of strings

  % btkAppendPoint(acq, 'Angle', labels{i}, data(i,:,:));
end
btkWriteAcquisition(acq,'PrimaProva.c3d')


Arnaud


--
 
 

debora

unread,
Oct 24, 2012, 8:06:33 AM10/24/12
to btk-...@googlegroups.com
thanks,
but it produce another error with the first code
 error:
Undefined function 'data' for input arguments of type 'double'.

Arnaud BARRE

unread,
Oct 24, 2012, 8:10:01 AM10/24/12
to btk-...@googlegroups.com
It was just an example to illustrate the function.

You should have a variable in Matlab which contains your angles' values. Replace data by this variable.

Arnaud

--
 
 

Debora La Bella

unread,
Oct 24, 2012, 8:56:08 AM10/24/12
to btk-...@googlegroups.com
if I have this volues: angles.R_ShoulderH1 <2200x3 double>
the code give me this error:
Index exceeds matrix dimensions
why?
the index wich range must have?

2012/10/24 debora <deboral...@gmail.com>
--
 
 

Arnaud BARRE

unread,
Oct 24, 2012, 9:03:17 AM10/24/12
to btk-...@googlegroups.com
In your example, you initialize your acquisition with 20 points, but your variable 'angles.R_ShoulderH1' contains only one angles.
Have you 20 angles in the structure 'angles' ?

The error here is more related to Matlab, than BTK. Maybe if you give more informations on the source of your data (does it come from another acquisition open with BTK? etc.), it will be possible to better help you.

Arnaud

--
 
 

Debora La Bella

unread,
Oct 24, 2012, 9:15:32 AM10/24/12
to btk-...@googlegroups.com
no I have 10 angles in the structure,  but I need to insert a single corner , this is a matrix of size[2200,3],
how do I put this matrix in my c3d file?

2012/10/24 Arnaud BARRE <arnaud...@gmail.com>
--
 
 

Arnaud BARRE

unread,
Oct 24, 2012, 9:20:47 AM10/24/12
to btk-...@googlegroups.com
This script should work with your data


acq=btkNewAcquisition(0,2200) % No points
btkSetFrequency(acq,200)
btkAppendPoint(acq, 'Angle', 'R_ShoulderH1', angles.R_ShoulderH1);
btkWriteAcquisition(acq,'PrimaProva.c3d')



--
 
 

Debora La Bella

unread,
Oct 24, 2012, 9:40:47 AM10/24/12
to btk-...@googlegroups.com
thanks

2012/10/24 Arnaud BARRE <arnaud...@gmail.com>
--
 
 

Reply all
Reply to author
Forward
0 new messages