Oxford-step-counter / DataSet

Data set used to tune the algorithm and validate it
6 stars 4 forks source link

Step counting is incorrect in optimisation/stats.js #2

Closed AntonIsraelsson closed 2 years ago

AntonIsraelsson commented 2 years ago

The program counts each state change and not the number of times a person sets down their foot.

Therefore it counts two steps when we only put the foot down once:

State behavior expected
...
10
00 steps++
01 steps++ steps ++
And doesn't recognize that a step has taken place when this happens: ... State behavior expected
...
10
01 steps++

Changing the for loop to the following seems to fix this problem.

for (let i = 0; i < lines.length; i++) {
  // 578088453544940,1,1
  let line = lines[i]
  let cols = line.split(',')
  if (cols.length > 1) {
    let time = parseInt(cols[0])
    let foot1 = parseInt(cols[1])
    let foot2 = parseInt(cols[2])
    if (i === 0) {
      start = time
      prevfoot1 = foot1
      prevfoot2 = foot2
    } else duration = time - start
    // If foot1 goes from 0 to 1:
    if (foot1 - prevfoot1 === 1) {
      steps++
    }
    // If foot2 goes from 0 to 1:
    if (foot2 - prevfoot2 === 1) {
      steps++
    }
    prevfoot1 = foot1
    prevfoot2 = foot2
  }
}
dariosalvi78 commented 2 years ago

so you mean that it counts one extra step for the whole test?

AntonIsraelsson commented 2 years ago

No, it seems to be off by a factor of around 2

dariosalvi78 commented 2 years ago

yes well, right and left step, of course.. To be honest, on longer distances with hundreds of steps it's not a big deal, but it would be good to fix anyhow. Maybe you want to send a pull request?

AntonIsraelsson commented 2 years ago

To be clear it's off by over a hundred steps for each dataset. A frequency of 4 steps per second is unreasonable for most kinds of walks.

Steps Original Steps New Duration (s) Steps/s, Original Steps/s, New
398 198 107 3.7 1.9
455 248 132 3.4 1.9
475 243 137 3.5 1.8
535 270 138 3.9 2.0
427 261 138 3.1 1.9
516 263 139 3.7 1.9
517 260 142 3.6 1.8
557 284 143 3.9 2.0
380 195 144 2.6 1.4
411 206 144 2.9 1.4
523 275 144 3.6 1.9
514 272 144 3.6 1.9
537 277 144 3.7 1.9
532 266 145 3.7 1.8
529 265 145 3.6 1.8
533 267 146 3.7 1.8
497 255 147 3.4 1.7
468 280 147 3.2 1.9
505 257 147 3.4 1.7
493 285 148 3.3 1.9
533 268 151 3.5 1.8
485 282 151 3.2 1.9
605 305 152 4.0 2.0
611 306 152 4.0 2.0
517 278 152 3.4 1.8
533 266 152 3.5 1.8
581 295 153 3.8 1.9
643 322 159 4.0 2.0
646 323 162 4.0 2.0
565 288 162 3.5 1.8
582 292 163 3.6 1.8
585 302 164 3.6 1.8
473 289 165 2.9 1.8
547 312 168 3.3 1.9
571 302 169 3.4 1.8
575 299 169 3.4 1.8
537 303 171 3.1 1.8
577 311 173 3.3 1.8
515 330 176 2.9 1.9
557 316 177 3.1 1.8
528 306 180 2.9 1.7
465 314 187 2.5 1.7
693 362 189 3.7 1.9
370 277 189 2.0 1.5
707 364 191 3.7 1.9
431 301 192 2.2 1.6
502 335 208 2.4 1.6
463 365 219 2.1 1.7
dariosalvi78 commented 2 years ago

I don't get it, what is off? the ground truth or the estimated steps from the algorithm?

AntonIsraelsson commented 2 years ago

The ground truth

dariosalvi78 commented 2 years ago

I am very surprised, we validated the GT device with lab measurements. This is how the steps are counted in the app. See from line 239. It looks like it's not double counting.

I think we used those steps as GT in the optimization process, not the ones computed in stats.js. Actually I cannot remember what stats.js was used for. It was some time ago!

AntonIsraelsson commented 2 years ago

It might just be an error with the stats.js file, as all other file-steps seem to be correct.

How was it validated?

dariosalvi78 commented 2 years ago

we validated the GT app by comparing the N of steps computed there with what was counted manually (2 separate people observed the test) over a short walk. I think the issue is only with the stats.js file, which I am not sure it was actually used for anything, so hopefully our results are not affected by it. In any case thanks for finding and correcting the issue!

If you need any help you can also write me an email at dario.salvi.work at gmail