You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Files which are part of ActiPASS documentation
2
+
3
+
### License
4
+
5
+
Unless otherwise specified in an individual source file, all source code in this repositery are release under **BSD 3-Clause license**. This means if a different license is included in a source file, that license supersedes the BSD 3-Clause license.
6
+
7
+
**BSD 3-Clause license**
8
+
9
+
Copyright (c) 2022, Pasan Hettiarachchi & Peter Johansson.
10
+
All rights reserved.
11
+
12
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
+
14
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15
+
16
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
17
+
18
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
19
+
20
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Unless otherwise specified in an individual source file, all source code in this repositery are release under **BSD 3-Clause license**. This means if a different license is included in a source file, that license supersedes **BSD 3-Clause license**.
4
+
5
+
**BSD 3-Clause License**
6
+
7
+
Copyright (c) 2023, Pasan Hettiarachchi and Peter Johansson
8
+
9
+
Redistribution and use in source and binary forms, with or without
10
+
modification, are permitted provided that the following conditions are met:
11
+
12
+
1. Redistributions of source code must retain the above copyright notice, this
13
+
list of conditions and the following disclaimer.
14
+
15
+
2. Redistributions in binary form must reproduce the above copyright notice,
16
+
this list of conditions and the following disclaimer in the documentation
17
+
and/or other materials provided with the distribution.
18
+
19
+
3. Neither the name of the copyright holder nor the names of its
20
+
contributors may be used to endorse or promote products derived from
21
+
this software without specific prior written permission.
22
+
23
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+
34
+
# Binary release license
35
+
36
+
Read the [License agreement to use for ActiPASS compiled binary releases](https://github.com/Ergo-Tools/ActiPASS/wiki/License-agreement#license-and-usage-agreement)
<figcaption>ActiPASS - a user friendly tool to process thigh-worn accelerometer data</figcaption>
20
+
</figure>
21
+
22
+
23
+
### About ActiPASS
24
+

25
+
26
+
27
+
ActiPASS is developed by: [Pasan Hettiarachchi](mailto:pasan.hettiarachchi@medsci.uu.se) and [Peter J. Johansson](mailto:peter.johansson@medsci.uu.se)
28
+
at Occupational and Environmental Medicine, Department of Medical Sciences, Uppsala University. [[Magnus Svartengren](mailto:magnus.svartengren@medsci.uu.se)]
29
+
30
+
ActiPASS is based on: Acti4 thigh accelerometer activity detection algorithm developed by Jørgen Skotte
31
+
at the National Research Centre for the Working Environment (NFA), Copenhagen, Denmark. [[Andreas Holtermann](mailto:aho@nfa.dk)]
32
+
33
+
The development of ActiPASS has partly been funded by [ProPASS Consortium](https://www.propassconsortium.org)
34
+
35
+
ActiPASS may not be used for any commercial purposes without written permission from the developers.
36
+
Please acknowledge the Developers and NFA as the source of the Software in any publications by referring to [relevant publications](https://github.com/Ergo-Tools/ActiPASS/wiki/ActiPASS-References) about Acti4 /ActiPASS.
37
+
38
+
ActiPASS is made possible by [these open source software](https://github.com/Ergo-Tools/ActiPASS/wiki/Open-source-software-used-by-ActiPASS) and developers [acknowledge](https://github.com/Ergo-Tools/ActiPASS/wiki/acknowledgements) all who contributed in various means.
## Various classifications algorithms used by ActiPASS software
2
+
3
+
### License
4
+
5
+
Unless otherwise specified in an individual source file, all source code in this repositery are release under **BSD 3-Clause license**. This means if a different license is included in a source file, that license supersedes the BSD 3-Clause license.
6
+
7
+
**BSD 3-Clause license**
8
+
9
+
Copyright (c) 2022, Pasan Hettiarachchi & Peter Johansson.
10
+
All rights reserved.
11
+
12
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
+
14
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15
+
16
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
17
+
18
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
19
+
20
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gapL=runLs{2}(indsGap); % lengths of the bouts within the gap
61
+
gapL(ismember(runLs{1}(indsGap),[1,2]))=0; % do not consider sit/lie in the gap (consider only upright)
62
+
gapLAll=sum(gapL); % the total upright time of the gap
63
+
gapLAct=sum(gapL.*ismember(runLs{1}(indsGap),[5,6,7,8,9])); % the total walking/stair/run/other,bicycling time
64
+
ifgapLAll<deltaT|| (gapLAll<5*deltaT&&gapLAct<deltaT) % if either the total gap length less than 1minute or gap length less than 5min & active time less than 1min
65
+
66
+
% after removing the short gap, if a sit bout is adjacent to a lie bout, mark both as lie
67
+
if runLs{1}(indsRunSitLie(itr))~=runLs{1}(indsRunSitLie(itr+1)) % after removing the short gap, if a sit bout is adjacent to a lie bout, mark both as lie
68
+
runLs{1}(indsRunSitLie(itr))=1;
69
+
runLs{1}(indsRunSitLie(itr+1))=1;
70
+
runLs{1}(indsGap)=1;
71
+
else
72
+
runLs{1}(indsGap)=runLs{1}(indsRunSitLie(itr)); %mark the gaps with same either sit or lie
73
+
end
74
+
end
75
+
76
+
end
77
+
78
+
%readjust run length encoding
79
+
if any(diff(runLs{1})==0)
80
+
runLs=rle(rle(runLs));
81
+
end
82
+
83
+
%Then expand Lie bouts and very large Sit bouts to adjacent large-sit or lie bouts by allowing a cumulative upright time of lenAktFilt
84
+
% we consider Lie bouts which are bigger than MinLieBt and Sitbouts which are bigger than VLongSitBt
%mark forward and backward bout-runs as 1 (ie.e. Lie). This is just a marker of Bedtime real Activities are not changed
143
+
runLs{1}(goBackI(1:numBts_BK))=1; % mark forward adjacent sit bouts as 1
144
+
runLs{1}(goFwdI(1:numBts_FD))=1; % mark backward adjacent sit bouts as 1
145
+
146
+
% also mark the current bout as 1 (Lie). This is because we consider long sit bouts for bedtime
147
+
runLs{1}(indsRunSitLie(itr))=1;
148
+
end
149
+
150
+
% recalculate bout-runs by re-running run-length-encoding (in other words run-length-decoding)
151
+
tmpAkt=rle(runLs);
152
+
153
+
% filtering out short upright bouts
154
+
% bedLgc=~bwareaopen(tmpAkt~=1,lenAktFilt);
155
+
runLsUR=rle(tmpAkt~=1); % run length encoding of upright bouts
156
+
runLsUR{1}(runLsUR{1}==1& runLsUR{2} <lenAktFilt)=0; % remove short upright bout from encoding (set to zero)
157
+
bedLgc=~rle(runLsUR); % inverse RLE the encoding and invert to find a logical vector of filtered sit/lie
158
+
159
+
% filter out one last time by and and considering a minimum of lenLieFilt and VLongSitBt for bedtime
160
+
runLsBL=rle(bedLgc);
161
+
162
+
for itr=1:length(runLsBL{1})
163
+
if runLsBL{1}(itr)==1
164
+
if aktFull(runLsBL{3}(itr))==1&& aktFull(runLsBL{4}(itr))==1% if this sit/lie bout starts and ends with lying
165
+
% do-not consider this lying bout because if it's too short
166
+
if runLsBL{2}(itr)<lenLieFilt
167
+
runLsBL{1}(itr)=0;
168
+
end
169
+
else% else if this sit/lie bout does not both starts and ends with lying
170
+
if runLsBL{2}(itr)<max(VLongSitBt,lenLieFilt)
171
+
runLsBL{1}(itr)=0; % do-not consider this lying bout because it's too short
172
+
end
173
+
end
174
+
175
+
end
176
+
end
177
+
178
+
179
+
%do a run-length-decoding and return the betime logical vector
180
+
bedLgc=rle(runLsBL);
181
+
182
+
%%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)
184
+
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
187
+
188
+
selDays=startDay:endDay;
189
+
190
+
% only consider bedtimes falling within the startDay:endDay
191
+
selBedtms=find(runLsBL{1}==1);
192
+
bdLengths=runLsBL{2}(selBedtms);
193
+
bedStarts=timeFull(runLsBL{3}(selBedtms));
194
+
bedEnds=timeFull(runLsBL{4}(selBedtms));
195
+
bedMidpts=bedStarts+(bedEnds-bedStarts)/2;
196
+
tod_MidPts=timeofday(bedMidpts); % the timeofday of the midpoints as a duration vector
197
+
numChcks=3; % the number of different scoring checks
198
+
199
+
% create a scoring matrix to iterate through days and try to flag bedtimes for selection
200
+
selScore=zeros(length(selBedtms),numChcks); % a column vector to hold priority-score of each bedtime
201
+
202
+
%score based on the length of the bedtime
203
+
selScore(:,1)=bdLengths/max(bdLengths);
204
+
205
+
% score based on whether midpoints of bedtimes falls within 22:00 - 08:00 or 08:00 to 22:00
0 commit comments