Skip to content

Commit

Permalink
Merge pull request #6 from Ergo-Tools/next-version
Browse files Browse the repository at this point in the history
Algorithms in version 1.49
  • Loading branch information
pasan-h authored Mar 5, 2023
2 parents 068db71 + 286a659 commit fe16b84
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 790 deletions.
22 changes: 11 additions & 11 deletions algorithms/calcBedLgc.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function runLsBL=calcBedLgc(aktFull,timeFull,lenAktFilt,lenLieFilt,VLongSitBt)
% CALCBEDLGC Calculate bedtime logic using by filtering the activities
%
% %% Inputs %%%%%%%%%%%%%%%%%
Expand All @@ -8,7 +9,11 @@
% VLongSitBt - very long sit bouts to consider for bedtime filtering (4*3600 default)
%
% %% Outputs%%%%%%%%%%%%%%%%%%%%
% bedLgc [double-n] - A logical vector given at 1s epoch representing bedtime status
% runLsBL {4 x1} - the run-length-encoded bedTime logic
% runLsBL{1}= [m x1] type of bedtime: 1-primary, 2-extra, 0-nobedtime
% runLsBL{2}= [m x1] run length (seconds)
% runLsBL{3}= [m x1] start index of each run
% runLsBL{4}= [m x1] end index of each run
%
% Copyright (c) 2021, Pasan Hettiarachchi .
% All rights reserved.
Expand Down Expand Up @@ -36,10 +41,6 @@
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.


function [bedLgc,bedFlags]=calcBedLgc(aktFull,timeFull,lenAktFilt,lenLieFilt,VLongSitBt)


MinLieBt=3600; % minimum lying bout to consider for bedtime expanding
MinSitBt=7200; % try to connect sit bouts longer than this to adjacent lying or very-long sit bouts

Expand Down Expand Up @@ -176,14 +177,13 @@
end


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


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

startDay=dateshift(timeFull(1),'start','day'); % if the day starts dayStartMx hours or later starting day is next day, otherwise start day is today
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
startDay=dateshift(timeFull(1),'start','day'); % the start day
endDay=dateshift(timeFull(end),'start','day'); % the last day

selDays=startDay:endDay;

Expand Down Expand Up @@ -245,7 +245,7 @@
end
end

bedFlags=[bedFlags,selScore,prod(selScore,2)];
runLsBL{1}(runLsBL{1}==1)=bedFlags;

% remove low scoring bedtimes from run-length-encoding
% runLsBL{1}(selBedtms(indDel))=0;
Expand Down
275 changes: 0 additions & 275 deletions algorithms/calcBedLgc_20230228.m

This file was deleted.

Loading

0 comments on commit fe16b84

Please sign in to comment.