%% Script to plot all the Emotion related datastreams together
%
% Plot E3 GSR, E3 BVP, E3 HR, BH HR, BH RespRate
%
%

%% Enter user name as userid
%
userid = 'PD05';
%actionname = 'PD06';

%% Set all the file names for the specific userid
%
%
%

E3GSR = sprintf('%s_E3GSR',userid);
E3GSRv = evalin('base',E3GSR);
E3GSRTime = sprintf('%s_E3GSRTime',userid); 
E3GSRTimev = evalin('base',E3GSRTime);

E3BVP = sprintf('%s_E3BVP',userid);
E3BVPv = evalin('base',E3BVP);
E3BVPTime = sprintf('%s_E3BVPTime',userid); 
E3BVPTimev = evalin('base',E3BVPTime);

E3IBI_HR = sprintf('%s_E3IBI_HR',userid);
E3IBI_HRv = evalin('base',E3IBI_HR);
E3IBI_HRTime = sprintf('%s_E3IBITime',userid); 
E3IBI_HRTimev = evalin('base',E3IBI_HRTime);

BHHeartRate = sprintf('%s_BHHeartRate',userid);
BHHeartRatev = evalin('base',BHHeartRate);
BHHeartRateTime = sprintf('%s_BHHeartRateTime',userid); 
BHHeartRateTimev = evalin('base',BHHeartRateTime);

BHRespRate = sprintf('%s_BHRespRate',userid);
BHRespRatev = evalin('base',BHRespRate);
BHRespRateTime = sprintf('%s_BHRespRateTime',userid); 
BHRespRateTimev = evalin('base',BHRespRateTime);

%use the bioharness timing to set the size of figure

settim = sprintf('%s_BHAccXYZTime',userid);
settime = evalin('base',settim);

%axis(xlim,[startx endx]);

figure('Color','w')

subplot(5,1,1)
plot(E3GSRTimev,E3GSRv,'r')
hold on
title('E3 EDA (right hand)')
xlim(settime([1 end]))
datetick('x','HH:MM:SSPM','keepticks')


subplot(5,1,2)
plot(E3BVPTimev,E3BVPv,'r')
hold on
title('E3 BVP (right hand)')
xlim(settime([1 end]))
datetick('x','HH:MM:SSPM','keepticks')


subplot(5,1,3)
plot(E3IBI_HRTimev,E3IBI_HRv,'r')
hold on
title('E3 Heart Rate (right hand)')
xlim(settime([1 end]))
datetick('x','HH:MM:SSPM','keepticks')


subplot(5,1,4)
plot(BHHeartRateTimev,BHHeartRatev,'r')
hold on
title('Bioharness Heart Rate (chest)')
xlim(settime([1 end]))
datetick('x','HH:MM:SSPM','keepticks')


subplot(5,1,5)
plot(BHRespRateTimev,BHRespRatev,'r')
hold on
title('Bioharness Resp Rate (chest)')
xlim(settime([1 end]))
datetick('x','HH:MM:SSPM','keepticks')


% may have to run this loop outside of the script - for unknown reasons

for i = 1:5;
subplot(5,1,i)
xlim(settime([1 end]))
set(gca,'XTick',[settime(1):.025:settime(end)])

datetick('x','HH:MM:SSPM')
grid on
grid minor
end


ha = axes('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0 1],'Box','off','Visible','off','Units','normalized', 'clipping' , 'off');
titlename = sprintf('%s',userid);
text(0.5, 1,titlename,'HorizontalAlignment','center','VerticalAlignment', 'top')  

hold on
