data extraction with time points from a sensor device

I am using a body worn sensor to measure balance in patients, the sensor starts to measure from the time it is turned on. I am measuring a series of tests of 30 seconds intervals with breaks in between for the patients and i am using an android app to record the exact time (time of the day)the respective test has been measured. My question is how can i synchronize and extract the data only from those 30 seconds test measurements with the time i recorded in my android app. please help..

Respuestas (2)

dpb
dpb el 15 de Jul. de 2014
I'd guess w/o knowing precisely how the app works the easiest would simply be to read all the data and turn into Matlab datenum s. Then select from a start/end time also in datenum format with ordinary math operations.
A "syntactic sugar" function I use a lot for such selections is
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
that allows one to write at top level
x=data(iswithin(dn,dn1,dn2),:);
to return the desired data where dn is a vector of datenum and data is the array of data values of the same length.

1 comentario

hello dpb,
Thank you for your reply. I can understand your script but i am not sure whether it works.
x=data(iswithin(dn,dn1,dn2),:); in this case dn has a limit and so on.
that what i am confused. please give me a answer if you have

Iniciar sesión para comentar.

Star Strider
Star Strider el 15 de Jul. de 2014
How are the time data in the sensor stored? If it starts from zero each time it is turned on and you know the exact time of day it was turned on, then I would add the sensor times to the initial time of day to get the sensor times in terms of time of day.
If the sensor has its own time of day clock, you need to calibrate it at the outset with your android app times. You can make the necessary corrections later.

5 comentarios

Hi Star Strider,
the time in the sensor is stored as milliseconds and the time in the app is stored as the actual day time [H Mm Ss]. right now i have to synchronize the two timings and take the desired data out. Actually, i measure 12 balance assessments, so it is like 12 data points of 30 seconds has to be extracted. after that i have to start analyzing the data to find the center of pressure variables.
Hi Surendar,
The problem is that I still do not know if the sensor starts from zero every time you turn it on or if it has its own internal time-of-day clock?
The easiest way to synchronize them is to use the app to record the time of day the sensor is turned on, noting the time on the sensor’s internal clock at the same time. After that, synchronizing them involves shifting the sensor clock data by a constant (the difference between the sensor and app times when the sensor is turned on). It is easy to do this in MATLAB.
I am assuming here that your data are output in some sort of spreadsheet format, with time in the first column and the other variables in other columns. You can use xlsread to import the data, being certain that the time data are reported in 24-hour format with millisecond precision. I would keep all the times from the app and the instrument as MATLAB date numbers. After that, if you have your app data in MATLAB as well, use the find function to locate the start and end of each segment. Since the individual segments you identify will likely not be precisely equal, I would store the data from each in a cell array for each subject. You can re-convert them to matrix arrays when you need to.
Surendar Devan
Surendar Devan el 31 de Jul. de 2014
Editada: Star Strider el 31 de Jul. de 2014
...;...;...;9 33 50;...
1;-1;ROM_Open_1;9 36 21;9 36 52
2;-1;ROM_Open_2;9 37 15;9 37 46
3;-1;ROM_Open_3;9 38 12;9 38 43
4;-1;ROM_Closed_1;9 39 18;9 39 49
5;-1;ROM_Closed_2;9 40 40;9 41 11
6;-1;ROM_Closed_3;9 42 7;9 42 39
7;-1;SL_Left_1;9 43 31;9 43 44
8;-1;SL_Right_1;9 44 4;9 44 26
9;-1;SL_Left_2;9 44 41;9 44 58
10;-1;SL_Right_2;9 45 13;9 45 35
11;-1;Foam_Surface_1;9 46 45;9 47 16
12;-1;Foam_Surface_2;9 47 52;9 48 24
...;...;...;9 49 6;...
this is how the time from the app look like, it does not start from zero everytime. as you can see those are the 12 data points i must extract. the time in the sensor is recorded in milliseconds for the respective day time. thank you so much for your reply.
dpb
dpb el 31 de Jul. de 2014
Explain what it is we're looking at and what you want/need and this real clock time from somewhere else...
Remember we only know what is on the screen; we don't have the app or the device or have any real klew of what you're even trying to accomplish. That's all patently clear to you, but not to any of us here...we "know nuthink!" as per Stg Schultz.
You will have to save the app data in a text file, or manually create strings from them as I did here. In any event, you can use textscan to recover the data:
x = {'1;-1;ROM_Open_1;9 36 21;9 36 52'
'2;-1;ROM_Open_2;9 37 15;9 37 46'
'3;-1;ROM_Open_3;9 38 12;9 38 43'
'4;-1;ROM_Closed_1;9 39 18;9 39 49'
'5;-1;ROM_Closed_2;9 40 40;9 41 11'
'6;-1;ROM_Closed_3;9 42 7;9 42 39'
'7;-1;SL_Left_1;9 43 31;9 43 44'
'8;-1;SL_Right_1;9 44 4;9 44 26'
'9;-1;SL_Left_2;9 44 41;9 44 58'
'10;-1;SL_Right_2;9 45 13;9 45 35'
'11;-1;Foam_Surface_1;9 46 45;9 47 16'
'12;-1;Foam_Surface_2;9 47 52;9 48 24'};
for k1 = 1:size(x,1)
d{k1} = textscan(x{k1}, '%d %d %s %d %d %d %d %d %d', 'delimiter',';');
tc(k1,:) = d{k1}(4:9);
end
td = cell2mat(tm);
The tc array is a cell array of the start and end times, td is the double array of those same data.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB Mobile en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 15 de Jul. de 2014

Comentada:

el 31 de Jul. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by