Skip to content

Commit fe16b84

Browse files
authored
Merge pull request #6 from Ergo-Tools/next-version
Algorithms in version 1.49
2 parents 068db71 + 286a659 commit fe16b84

File tree

4 files changed

+60
-790
lines changed

4 files changed

+60
-790
lines changed

algorithms/calcBedLgc.m

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function runLsBL=calcBedLgc(aktFull,timeFull,lenAktFilt,lenLieFilt,VLongSitBt)
12
% CALCBEDLGC Calculate bedtime logic using by filtering the activities
23
%
34
% %% Inputs %%%%%%%%%%%%%%%%%
@@ -8,7 +9,11 @@
89
% VLongSitBt - very long sit bouts to consider for bedtime filtering (4*3600 default)
910
%
1011
% %% Outputs%%%%%%%%%%%%%%%%%%%%
11-
% bedLgc [double-n] - A logical vector given at 1s epoch representing bedtime status
12+
% runLsBL {4 x1} - the run-length-encoded bedTime logic
13+
% runLsBL{1}= [m x1] type of bedtime: 1-primary, 2-extra, 0-nobedtime
14+
% runLsBL{2}= [m x1] run length (seconds)
15+
% runLsBL{3}= [m x1] start index of each run
16+
% runLsBL{4}= [m x1] end index of each run
1217
%
1318
% Copyright (c) 2021, Pasan Hettiarachchi .
1419
% All rights reserved.
@@ -36,10 +41,6 @@
3641
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3742
% POSSIBILITY OF SUCH DAMAGE.
3843

39-
40-
function [bedLgc,bedFlags]=calcBedLgc(aktFull,timeFull,lenAktFilt,lenLieFilt,VLongSitBt)
41-
42-
4344
MinLieBt=3600; % minimum lying bout to consider for bedtime expanding
4445
MinSitBt=7200; % try to connect sit bouts longer than this to adjacent lying or very-long sit bouts
4546

@@ -176,14 +177,13 @@
176177
end
177178

178179

179-
%do a run-length-decoding and return the betime logical vector
180-
bedLgc=rle(runLsBL);
180+
181181

182182
%% scan through the full days to select primary bedtimes.
183-
runLsBL=rle(bedLgc); % re-do the run-length-encoding (because we changed the encoding above)
183+
runLsBL=rle(rle(runLsBL)); % re-do the run-length-encoding (because we changed the encoding above)
184184

185-
startDay=dateshift(timeFull(1),'start','day'); % if the day starts dayStartMx hours or later starting day is next day, otherwise start day is today
186-
endDay=dateshift(timeFull(end),'start','day'); % if the day ends dayEndMin or earlier last day is last-calander day, otherwise last-day is previous day
185+
startDay=dateshift(timeFull(1),'start','day'); % the start day
186+
endDay=dateshift(timeFull(end),'start','day'); % the last day
187187

188188
selDays=startDay:endDay;
189189

@@ -245,7 +245,7 @@
245245
end
246246
end
247247

248-
bedFlags=[bedFlags,selScore,prod(selScore,2)];
248+
runLsBL{1}(runLsBL{1}==1)=bedFlags;
249249

250250
% remove low scoring bedtimes from run-length-encoding
251251
% runLsBL{1}(selBedtms(indDel))=0;

algorithms/calcBedLgc_20230228.m

Lines changed: 0 additions & 275 deletions
This file was deleted.

0 commit comments

Comments
 (0)