4
$\begingroup$

I am giving my first steps in data analysis, gathering/cleaning.

To learn, I am trying to create a simple code that can detect heartbeats from color variations from the image coming from the camera on the iPhone.

This is what I have done so far:

  1. I have created a code that detects faces and cuts them from the image.
  2. then I get the average color from that face image.
  3. Because the values are grabbed at irregular time intervals, I interpolate the data. Now I have a series of values "taken" at regular intervals.

Plotting the data I have this:

enter image description here

I think I am seeing something that looks like heartbeats there.

To confirm that I am not seeing artifacts from the camera, I sample a rectangle from the background and I get the same color with very little random variation. The background color is stable and shows barely any variation.

  1. Now, I apply a Direct Cosine Transform to the data and get this:

enter image description here

The DCT has negative vales.

The two first items of the DCT are peaks, at t=0 and t=0.10482311 seconds.

I read a paper where the researcher says heartbeats occur between 0.4 and 4Hz. I suppose this has a relation why the first two DCT items are peaks...

What do I do now?

I have tried to apply a threshold to zero every term from the DCT below 150 and do an inverse DCT to reconstruct the signal and got this

enter image description here

I have reduced the threshold to 85 and got this

enter image description here

I am not sure if I see a heartbeat there. I mean, the peaks where the beats start.

This is the data at regular time intervals I have (256 samples):

17.0
14.151599
11.303198
8.454798
5.74406
7.5946655
12.173319
18.0
18.0
7.448537
18.0
16.36569
12.0000515
13.0
13.0
13.0
13.0
12.442261
9.134232
11.052017
12.0
7.605861
10.42025
11.911684
3.4419365
2.0
2.0
14.082303
16.227417
9.639368
7.0
3.4693644
5.0578203
7.0
14.859163
8.363442
7.876806
16.721855
16.367476
13.054573
17.416235
6.6276655
11.617707
12.0
6.3224463
11.111255
14.0
14.0
14.0
14.0
8.705125
17.478954
18.0
17.259813
14.371727
12.0
12.0
17.304781
18.0
18.0
2.6055841
9.789778
8.290463
6.3248563
2.3246787
12.944895
2.999961
8.443108
16.994041
7.714527
11.132567
2.2226758
5.6030903
12.528458
16.932209
16.087227
7.9563236
16.43404
8.239223
17.576452
12.102208
15.194642
1.0
1.0
1.0
1.0
1.0
1.0
1.7313459
17.479614
11.889918
11.0
11.0
14.0
14.0
13.802156
12.975004
6.840872
14.405505
7.928815
1.4836411
7.193712
15.371663
6.2666273
6.1682196
17.532732
16.0
15.034918
9.363262
1.0
4.654352
17.0
17.0
17.0
17.0
10.1624565
2.696946
13.607519
10.2923975
1.0
1.49984
9.996923
7.0500054
17.0
17.0
17.343903
13.191299
1.6610342
5.2127213
7.0
5.6532416
3.0295517
12.250117
12.687657
2.9297333
7.463814
9.5274105
13.640531
18.061134
16.376305
5.9621263
4.2103305
7.751727
7.023478
2.4116693
14.6888685
11.718729
4.0103664
12.0
8.606849
1.0
1.0
7.0
7.0
8.867684
12.0
12.0
9.598275
4.9731455
2.0
2.0
2.0
2.4965348
4.843401
5.4067893
3.655766
7.0
11.899609
11.855668
10.36767
16.59431
7.843425
1.9749169
8.829407
12.43066
11.205647
16.514818
17.0
13.328903
11.462145
12.0
12.0
12.0
12.502206
15.606055
18.0
18.0
13.699917
2.0
2.0
8.122738
12.0342
12.311193
9.434023
8.419968
8.64551
2.1631317
7.9250226
13.173435
3.0252013
1.0
1.0
1.0
1.0
1.0
3.7013192
6.0
6.0
6.3827076
7.0
6.570015
6.0
6.0
6.0
6.0
2.8011405
7.071625
15.575444
17.0
17.0
6.811758
1.0
4.5509486
5.3095756
10.288496
13.577595
2.493825
10.179988
12.0
6.3059773
7.9304085
14.911688
8.452748
2.8948724
10.117218
12.0
12.0
15.008322
16.0
7.473282
4.4403195
12.0
12.0
8.330021
6.0
6.0
6.0
11.515245
0.946867
0.83356774
0.95877224
0.05619842
15.221931
16.469358
5.231963
1.7867849

and these are the regular time intervals

0.0
0.03317536
0.06635072
0.09952608
0.13270144
0.1658768
0.19905217
0.23222753
0.26540288
0.29857823
0.33175358
0.36492893
0.39810428
0.43127963
0.46445498
0.49763033
0.5308057
0.56398106
0.5971564
0.63033175
0.6635071
0.69668245
0.7298578
0.76303315
0.7962085
0.82938385
0.8625592
0.89573455
0.9289099
0.96208525
0.9952606
1.028436
1.0616113
1.0947866
1.127962
1.1611373
1.1943127
1.227488
1.2606634
1.2938387
1.3270141
1.3601894
1.3933648
1.4265401
1.4597155
1.4928908
1.5260662
1.5592415
1.5924169
1.6255922
1.6587676
1.6919429
1.7251183
1.7582936
1.791469
1.8246443
1.8578197
1.890995
1.9241704
1.9573457
1.9905211
2.0236964
2.056872
2.0900474
2.1232228
2.1563983
2.1895738
2.2227492
2.2559247
2.2891002
2.3222756
2.355451
2.3886266
2.421802
2.4549775
2.488153
2.5213284
2.554504
2.5876794
2.6208549
2.6540303
2.6872058
2.7203813
2.7535567
2.7867322
2.8199077
2.8530831
2.8862586
2.919434
2.9526095
2.985785
3.0189605
3.052136
3.0853114
3.118487
3.1516623
3.1848378
3.2180133
3.2511888
3.2843642
3.3175397
3.3507152
3.3838906
3.417066
3.4502416
3.483417
3.5165925
3.549768
3.5829434
3.616119
3.6492944
3.6824698
3.7156453
3.7488208
3.7819963
3.8151717
3.8483472
3.8815227
3.9146981
3.9478736
3.981049
4.0142245
4.0474
4.0805755
4.113751
4.1469264
4.180102
4.2132773
4.246453
4.2796283
4.3128037
4.345979
4.3791547
4.41233
4.4455056
4.478681
4.5118566
4.545032
4.5782075
4.611383
4.6445584
4.677734
4.7109094
4.744085
4.7772603
4.810436
4.8436112
4.8767867
4.909962
4.9431376
4.976313
5.0094886
5.042664
5.0758395
5.109015
5.1421905
5.175366
5.2085414
5.241717
5.2748923
5.308068
5.3412433
5.3744187
5.407594
5.4407697
5.473945
5.5071206
5.540296
5.5734715
5.606647
5.6398225
5.672998
5.7061734
5.739349
5.7725244
5.8057
5.8388753
5.872051
5.905226
5.9384017
5.971577
6.0047526
6.037928
6.0711036
6.104279
6.1374545
6.17063
6.2038054
6.236981
6.2701564
6.303332
6.3365073
6.369683
6.4028583
6.4360337
6.469209
6.5023847
6.53556
6.5687356
6.601911
6.6350865
6.668262
6.7014375
6.734613
6.7677884
6.800964
6.8341393
6.867315
6.9004903
6.9336658
6.966841
7.0000167
7.033192
7.0663676
7.099543
7.1327186
7.165894
7.1990695
7.232245
7.2654204
7.298596
7.3317714
7.364947
7.3981223
7.431298
7.4644732
7.4976487
7.530824
7.5639997
7.597175
7.6303506
7.663526
7.6967015
7.729877
7.7630525
7.796228
7.8294034
7.862579
7.8957543
7.92893
7.9621053
7.9952807
8.028456
8.061631
8.094807
8.127982
8.161158
8.194333
8.227509
8.260684
8.2938595
8.327035
8.36021
8.393386
8.426561
8.459737
$\endgroup$
1

0

Browse other questions tagged or ask your own question.