
% This program generates actogram from temperature data and marks the onset
% as well as peak marker from the results file generated by
% wma_tempOnset.m and wma_tempPeak.m
clear all;
close all;
clc;

load SampleTemp.txt;
H=SampleTemp;

Mavt=35;
x2=(H-Mavt);
time2=[0:length(x2)-1]*(15/60)*(1/24);
th=30;
as2=find(time2<=th);
x1=x2(as2);

x=x1;
load Peak_SampleTemp.txt; % Peak marker obtained from wma_tempPeak.m
peaktimes1=Peak_SampleTemp'*24;
peaktimes=peaktimes1(1:th);

load Onset_SampleTemp.txt; % Onset marker obtained from wma_tempOnset.m
onset1=Onset_SampleTemp'*24;
onset=onset1(1:th);



NstepsPerHr=4;  % assumes 15 min sampling rate
Tcycle=24;
Nsteps=length(x);
t=(0:Nsteps-1)'/NstepsPerHr;
range=1:Nsteps;
MRAlength=length(range);
PhaseMarkerSize=4; 

Actogram2x(x(range),[],NstepsPerHr,t(range(end))-t(range(1)),'new',Tcycle);

 %plot(mod(onset(1:end),Tcycle),ceil(onset(1:end)/Tcycle)-0.3,'mo','MarkerFaceColor','m','MarkerSize',PhaseMarkerSize);
  plot(mod(onset(1:end),Tcycle)+24,ceil(onset(1:end)/Tcycle)-1.3,'mo','MarkerFaceColor','m','MarkerSize',PhaseMarkerSize);

 
%plot(mod(peaktimes(1:end),Tcycle),ceil(peaktimes(1:end)/Tcycle)-0.3,'gd','MarkerFaceColor','g','MarkerSize',PhaseMarkerSize)
plot(mod(peaktimes(1:end),Tcycle)+24,ceil(peaktimes(1:end)/Tcycle)-1.3,'gd','MarkerFaceColor','g','MarkerSize',PhaseMarkerSize)

