% MDBS_PROC1
% ISSS MDBS Demonstration
% September 6, 2006, Boston, MA
% Collected with PS(C#) and Tmote gateway
%
% Emil Jovanov
% University of Alabama in Huntsville
% September 2006. 
%

% Directory path and session number definition
% note: change if necessary
dir_path='c:\Projects\C#\PS_2006\PS_PC\bin\Debug\Updates\';
sess_no=41;

% Raw data sampling frequency
Fs=25;

% display collection record stats
[NFiles,no_rec,PacCntr]=actis_file_stats(dir_path,sess_no)

% extract user's activity estimate
[AEE,St_aee,no_rec_aee,lost_rec_aee]=actis_read_AEE(dir_path,1,sess_no);

% extract Rpeak events
[RR,St_rr,no_rec_rr,lost_rec_rr]=actis_read_RR(dir_path,3,sess_no);

subplot(211)
bar(St_aee/60,AEE),title('Activity (AEE)')
subplot(212)
plot(St_rr./60,60*32768./RR),axis([min(St_rr)./60 max(St_rr./60) 40 140]),title('Heart rate')

% extract raw accelerometer data
[X,Xt]=actis_read('c:\Projects\C#\PS_2006\PS_PC\bin\Debug\Updates\',37,1,0,Fs);
[Y,Yt]=actis_read('c:\Projects\C#\PS_2006\PS_PC\bin\Debug\Updates\',37,1,1,Fs);
[Z,Zt]=actis_read('c:\Projects\C#\PS_2006\PS_PC\bin\Debug\Updates\',37,1,2,Fs);

% plot raw data
figure
plot(Xt./60,X,Yt./60,Y,Zt./60,Z)
axis([min([Xt Yt Zt]./60) max([Xt Yt Zt]./60) 4000 14000])
title('Raw accelerometer data')
