-
Notifications
You must be signed in to change notification settings - Fork 61
/
analysis.html
1286 lines (1194 loc) · 58 KB
/
analysis.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Preprocessing FEX data — Py-Feat</title>
<link rel="stylesheet" href="../_static/css/index.f658d18f9b420779cfdf24aa0a7e2d77.css">
<link rel="stylesheet"
href="../_static/vendor/fontawesome/5.13.0/css/all.min.css">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
<link rel="stylesheet"
href="../_static/vendor/open-sans_all/1.44.1/index.css">
<link rel="stylesheet"
href="../_static/vendor/lato_latin-ext/1.44.1/index.css">
<link rel="stylesheet" href="../_static/sphinx-book-theme.37f24b989f4638ff9c27c22dc7559d4f.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/togglebutton.css" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="../_static/mystnb.css" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx-thebe.css" />
<link rel="stylesheet" type="text/css" href="../_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
<link rel="stylesheet" type="text/css" href="../_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />
<link rel="preload" as="script" href="../_static/js/index.d3f166471bb80abb5163.js">
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<script src="../_static/togglebutton.js"></script>
<script src="../_static/clipboard.min.js"></script>
<script src="../_static/copybutton.js"></script>
<script >var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
<script src="../_static/sphinx-book-theme.7d483ff0a819d6edff12ce0b1ead3928.js"></script>
<script async="async" src="https://unpkg.com/thebelab@latest/lib/index.js"></script>
<script >
const thebe_selector = ".thebe"
const thebe_selector_input = "pre"
const thebe_selector_output = ".output"
</script>
<script async="async" src="../_static/sphinx-thebe.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Plotting examples" href="plotting.html" />
<link rel="prev" title="Detecting FEX from images" href="detector.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="en" />
</head>
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
<div class="container-xl">
<div class="row">
<div class="col-12 col-md-3 bd-sidebar site-navigation show" id="site-navigation">
<div class="navbar-brand-box">
<a class="navbar-brand text-wrap" href="../index.html">
<img src="../_static/pyfeat_logo_small.png" class="logo" alt="logo">
<h1 class="site-logo" id="site-title">Py-Feat</h1>
</a>
</div><form class="bd-search d-flex align-items-center" action="../search.html" method="get">
<i class="icon fas fa-search"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search this book..." aria-label="Search this book..." autocomplete="off" >
</form>
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="intro.html">
Py-Feat: Python Facial Expression Analysis Toolbox
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
Installation
</span>
</p>
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="installation.html">
Installation example
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
Tutorials
</span>
</p>
<ul class="current nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="detector.html">
Detecting FEX from images
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="detector.html#detecting-fex-from-videos">
Detecting FEX from videos
</a>
</li>
<li class="toctree-l1 current active">
<a class="current reference internal" href="#">
Preprocessing FEX data
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="#analyzing-fex-data">
Analyzing FEX data
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="plotting.html">
Plotting examples
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="loadingOtherFiles.html">
Loading data from other detectors
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="trainAUvisModel.html">
Training AU visualization model
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="modelContribution.html">
Contributing new detectors
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
API
</span>
</p>
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="../api/index.html">
API Reference
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../api/index.html#module-feat.detector">
feat.detector module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../api/index.html#module-feat.data">
feat.data module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../api/index.html#module-feat.plotting">
feat.plotting module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../api/index.html#module-feat.utils">
feat.utils module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../api/index.html#module-feat.version">
feat.version module
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../api/index.html#module-feat">
Module contents
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
Contributing
</span>
</p>
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="contribute.html">
Contribute
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/cosanlab/py-feat">
GitHub Repository
<i class="fas fa-external-link-alt">
</i>
</a>
</li>
</ul>
</nav> <!-- To handle the deprecated key -->
<div class="navbar_extra_footer">
Powered by <a href="https://jupyterbook.org">Jupyter Book</a>
</div>
</div>
<main class="col py-md-3 pl-md-4 bd-content overflow-auto" role="main">
<div class="topbar container-xl fixed-top">
<div class="topbar-contents row">
<div class="col-12 col-md-3 bd-topbar-whitespace site-navigation show"></div>
<div class="col pl-md-4 topbar-main">
<button id="navbar-toggler" class="navbar-toggler ml-0" type="button" data-toggle="collapse"
data-toggle="tooltip" data-placement="bottom" data-target=".site-navigation" aria-controls="navbar-menu"
aria-expanded="true" aria-label="Toggle navigation" aria-controls="site-navigation"
title="Toggle navigation" data-toggle="tooltip" data-placement="left">
<i class="fas fa-bars"></i>
<i class="fas fa-arrow-left"></i>
<i class="fas fa-arrow-up"></i>
</button>
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn" aria-label="Download this page"><i
class="fas fa-download"></i></button>
<div class="dropdown-buttons">
<!-- ipynb file if we had a myst markdown file -->
<!-- Download raw file -->
<a class="dropdown-buttons" href="../_sources/content/analysis.ipynb"><button type="button"
class="btn btn-secondary topbarbtn" title="Download source file" data-toggle="tooltip"
data-placement="left">.ipynb</button></a>
<!-- Download PDF via print -->
<button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="Print to PDF"
onClick="window.print()" data-toggle="tooltip" data-placement="left">.pdf</button>
</div>
</div>
<!-- Source interaction buttons -->
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn"
aria-label="Connect with source repository"><i class="fab fa-github"></i></button>
<div class="dropdown-buttons sourcebuttons">
<a class="repository-button"
href="https://github.com/cosanlab/py-feat"><button type="button" class="btn btn-secondary topbarbtn"
data-toggle="tooltip" data-placement="left" title="Source repository"><i
class="fab fa-github"></i>repository</button></a>
<a class="issues-button"
href="https://github.com/cosanlab/py-feat/issues/new?title=Issue%20on%20page%20%2Fcontent/analysis.html&body=Your%20issue%20content%20here."><button
type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip" data-placement="left"
title="Open an issue"><i class="fas fa-lightbulb"></i>open issue</button></a>
</div>
</div>
<!-- Full screen (wrap in <a> to have style consistency -->
<a class="full-screen-button"><button type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip"
data-placement="bottom" onclick="toggleFullScreen()" aria-label="Fullscreen mode"
title="Fullscreen mode"><i
class="fas fa-expand"></i></button></a>
<!-- Launch buttons -->
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn"
aria-label="Launch interactive content"><i class="fas fa-rocket"></i></button>
<div class="dropdown-buttons">
<a class="binder-button" href="https://mybinder.org/v2/gh/cosanlab/py-feat/master?urlpath=tree/notebooks/content/analysis.ipynb"><button type="button"
class="btn btn-secondary topbarbtn" title="Launch Binder" data-toggle="tooltip"
data-placement="left"><img class="binder-button-logo"
src="../_static/images/logo_binder.svg"
alt="Interact on binder">Binder</button></a>
<a class="jupyterhub-button" href="https://jhub.dartmouth.edu//hub/user-redirect/git-pull?repo=https://github.com/cosanlab/py-feat&urlpath=tree/py-feat/notebooks/content/analysis.ipynb&branch=master"><button type="button"
class="btn btn-secondary topbarbtn" title="Launch JupyterHub" data-toggle="tooltip"
data-placement="left"><img class="jupyterhub-button-logo"
src="../_static/images/logo_jupyterhub.svg"
alt="Interact on JupyterHub">JupyterHub</button></a>
<a class="colab-button" href="https://colab.research.google.com/github/cosanlab/py-feat/blob/master/notebooks/content/analysis.ipynb"><button type="button" class="btn btn-secondary topbarbtn"
title="Launch Colab" data-toggle="tooltip" data-placement="left"><img class="colab-button-logo"
src="../_static/images/logo_colab.png"
alt="Interact on Colab">Colab</button></a>
</div>
</div>
</div>
<!-- Table of contents -->
<div class="d-none d-md-block col-md-2 bd-toc show">
<div class="tocsection onthispage pt-5 pb-3">
<i class="fas fa-list"></i> Contents
</div>
<nav id="bd-toc-nav">
<ul class="nav section-nav flex-column">
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#">
Preprocessing FEX data
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#how-to-preprocess-and-analyze-facial-expression-data-with-feat">
How to preprocess and analyze facial expression data with Feat.
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#extract-features">
Extract features
</a>
</li>
</ul>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#analyzing-fex-data">
Analyzing FEX data
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#simple-t-test">
Simple t-test
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#two-sample-independent-t-test">
Two sample independent t-test
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#prediction">
Prediction
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#regression">
Regression
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#intersubject-or-intervideo-correlations">
Intersubject (or intervideo) correlations
</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div id="main-content" class="row">
<div class="col-12 col-md-9 pl-md-3 pr-md-0">
<div>
<div class="section" id="preprocessing-fex-data">
<h1>Preprocessing FEX data<a class="headerlink" href="#preprocessing-fex-data" title="Permalink to this headline">¶</a></h1>
<div class="section" id="how-to-preprocess-and-analyze-facial-expression-data-with-feat">
<h2>How to preprocess and analyze facial expression data with Feat.<a class="headerlink" href="#how-to-preprocess-and-analyze-facial-expression-data-with-feat" title="Permalink to this headline">¶</a></h2>
<p><em>Written by Jin Hyun Cheong</em></p>
<p>Here we will be using a sample dataset by David Watson on <a class="reference external" href="https://journals.plos.org/ploscompbiol/article/peerReview?id=10.1371/journal.pcbi.1008335">“A Data-Driven Characterisation Of Natural Facial Expressions When Giving Good And Bad News”</a> by Watson & Johnston 2020. The full dataset is available on <a class="reference external" href="https://osf.io/6tbwj/">OSF</a>.</p>
<p>Let’s start by installing Py-FEAT if you have not already done so or using this on Google Colab</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="o">!</span>pip install -q py-feat
</pre></div>
</div>
</div>
</div>
<p>First, we download the necessary files & videos.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">subprocess</span>
<span class="n">files_to_download</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"4c5mb"</span><span class="p">,</span> <span class="s2">"n6rt3"</span><span class="p">,</span> <span class="s2">"3gh8v"</span><span class="p">,</span> <span class="s2">"twqxs"</span><span class="p">,</span> <span class="s2">"nc7d9"</span><span class="p">,</span> <span class="s2">"nrwcm"</span><span class="p">,</span> <span class="s2">"2rk9c"</span><span class="p">,</span> <span class="s2">"mxkzq"</span><span class="p">,</span> <span class="s2">"c2na7"</span><span class="p">,</span> <span class="s2">"wj7zy"</span><span class="p">,</span> <span class="s2">"mxywn"</span><span class="p">,</span>
<span class="s2">"6bn3g"</span><span class="p">,</span> <span class="s2">"jkwsp"</span><span class="p">,</span> <span class="s2">"54gtv"</span><span class="p">,</span> <span class="s2">"c3hpm"</span><span class="p">,</span> <span class="s2">"utdqj"</span><span class="p">,</span> <span class="s2">"hpw4a"</span><span class="p">,</span> <span class="s2">"94swe"</span><span class="p">,</span> <span class="s2">"qte5y"</span><span class="p">,</span> <span class="s2">"aykvu"</span><span class="p">,</span> <span class="s2">"3d5ry"</span><span class="p">]</span>
<span class="k">for</span> <span class="n">fid</span> <span class="ow">in</span> <span class="n">files_to_download</span><span class="p">:</span>
<span class="n">subprocess</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="sa">f</span><span class="s2">"wget --content-disposition https://osf.io/</span><span class="si">{</span><span class="n">fid</span><span class="si">}</span><span class="s2">/download"</span><span class="o">.</span><span class="n">split</span><span class="p">())</span>
</pre></div>
</div>
</div>
</div>
<p>Check that videos have been downloaded and the attributes file, `clip_attrs.csv) explaining</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span><span class="o">,</span> <span class="nn">glob</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="kn">import</span> <span class="nn">seaborn</span> <span class="k">as</span> <span class="nn">sns</span>
<span class="n">sns</span><span class="o">.</span><span class="n">set_context</span><span class="p">(</span><span class="s2">"talk"</span><span class="p">)</span>
<span class="n">clip_attrs</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="s2">"clip_attrs.csv"</span><span class="p">)</span>
<span class="n">videos</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sort</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">"*.mp4"</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="n">videos</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>['001.mp4' '002.mp4' '003.mp4' '004.mp4' '005.mp4' '006.mp4' '007.mp4'
'008.mp4' '009.mp4' '010.mp4' '011.mp4' '012.mp4' '013.mp4' '014.mp4'
'015.mp4' '016.mp4' '017.mp4' '018.mp4' '019.mp4' '020.mp4']
</pre></div>
</div>
</div>
</div>
<p>Process each video using our detector.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">feat</span> <span class="kn">import</span> <span class="n">Detector</span>
<span class="n">detector</span> <span class="o">=</span> <span class="n">Detector</span><span class="p">(</span><span class="n">au_model</span> <span class="o">=</span> <span class="s2">"rf"</span><span class="p">,</span> <span class="n">emotion_model</span> <span class="o">=</span> <span class="s2">"resmasknet"</span><span class="p">)</span>
<span class="k">for</span> <span class="n">video</span> <span class="ow">in</span> <span class="n">videos</span><span class="p">:</span>
<span class="n">detector</span><span class="o">.</span><span class="n">detect_video</span><span class="p">(</span><span class="n">video</span><span class="p">,</span> <span class="n">outputFname</span> <span class="o">=</span> <span class="n">video</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">".mp4"</span><span class="p">,</span> <span class="s2">".csv"</span><span class="p">))</span>
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">feat.utils</span> <span class="kn">import</span> <span class="n">read_feat</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="k">for</span> <span class="n">ix</span> <span class="p">,</span><span class="n">video</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">videos</span><span class="p">):</span>
<span class="n">outputF</span> <span class="o">=</span> <span class="n">video</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">".mp4"</span><span class="p">,</span> <span class="s2">".csv"</span><span class="p">)</span>
<span class="k">if</span> <span class="n">ix</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">fex</span> <span class="o">=</span> <span class="n">read_feat</span><span class="p">(</span><span class="n">outputF</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">fex</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">([</span><span class="n">fex</span><span class="p">,</span> <span class="n">read_feat</span><span class="p">(</span><span class="n">outputF</span><span class="p">)])</span>
<span class="n">fex</span> <span class="o">=</span> <span class="n">fex</span><span class="o">.</span><span class="n">dropna</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Load in conditions</span>
<span class="n">clip_attrs</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="s2">"clip_attrs.csv"</span><span class="p">)</span>
<span class="n">clip_attrs</span> <span class="o">=</span> <span class="n">clip_attrs</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span><span class="nb">input</span> <span class="o">=</span> <span class="n">clip_attrs</span><span class="o">.</span><span class="n">clipN</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">zfill</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">+</span><span class="s2">".mp4"</span><span class="p">),</span>
<span class="n">condition</span> <span class="o">=</span> <span class="n">clip_attrs</span><span class="p">[</span><span class="s1">'class'</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">({</span><span class="s2">"gn"</span><span class="p">:</span><span class="s2">"goodNews"</span><span class="p">,</span> <span class="s2">"ists"</span><span class="p">:</span><span class="s2">"badNews"</span><span class="p">}))</span>
<span class="n">input_class_map</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">clip_attrs</span><span class="o">.</span><span class="n">input</span><span class="p">,</span> <span class="n">clip_attrs</span><span class="p">[</span><span class="s1">'condition'</span><span class="p">]))</span>
<span class="n">clip_attrs</span><span class="o">.</span><span class="n">head</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>clipN</th>
<th>class</th>
<th>phraseN</th>
<th>phrase_txt</th>
<th>input</th>
<th>condition</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>1</td>
<td>gn</td>
<td>1</td>
<td>your loan has been approved</td>
<td>001.mp4</td>
<td>goodNews</td>
</tr>
<tr>
<th>1</th>
<td>2</td>
<td>gn</td>
<td>2</td>
<td>you've got the job</td>
<td>002.mp4</td>
<td>goodNews</td>
</tr>
<tr>
<th>2</th>
<td>3</td>
<td>gn</td>
<td>3</td>
<td>the vendor has accepted your offer</td>
<td>003.mp4</td>
<td>goodNews</td>
</tr>
<tr>
<th>3</th>
<td>4</td>
<td>gn</td>
<td>4</td>
<td>your tests have come back clear</td>
<td>004.mp4</td>
<td>goodNews</td>
</tr>
<tr>
<th>4</th>
<td>5</td>
<td>gn</td>
<td>5</td>
<td>your application has been accepted</td>
<td>005.mp4</td>
<td>goodNews</td>
</tr>
</tbody>
</table>
</div></div></div>
</div>
</div>
<div class="section" id="extract-features">
<h2>Extract features<a class="headerlink" href="#extract-features" title="Permalink to this headline">¶</a></h2>
<p>You can set the <code class="docutils literal notranslate"><span class="pre">sessions</span></code> attribute to provide a grouping of your experimental setup. This could be the name of each video if you want to extract features per video or it could be conditions to extract features per condition.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Extract conditions between the two condtiiosn (gn: good news, ists: bad news)</span>
<span class="n">conditions</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">clip_attrs</span><span class="o">.</span><span class="n">input</span><span class="p">,</span> <span class="n">clip_attrs</span><span class="p">[</span><span class="s1">'condition'</span><span class="p">]))</span>
<span class="n">fex</span><span class="o">.</span><span class="n">sessions</span> <span class="o">=</span> <span class="n">fex</span><span class="o">.</span><span class="n">input</span><span class="p">()</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">conditions</span><span class="p">)</span>
<span class="n">average_au_intensity_per_video</span> <span class="o">=</span> <span class="n">fex</span><span class="o">.</span><span class="n">extract_mean</span><span class="p">()</span>
<span class="n">display</span><span class="p">(</span><span class="n">average_au_intensity_per_video</span><span class="o">.</span><span class="n">head</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>mean_AU01</th>
<th>mean_AU02</th>
<th>mean_AU04</th>
<th>mean_AU05</th>
<th>mean_AU06</th>
<th>mean_AU07</th>
<th>mean_AU09</th>
<th>mean_AU10</th>
<th>mean_AU11</th>
<th>mean_AU12</th>
<th>...</th>
<th>mean_y_61</th>
<th>mean_y_62</th>
<th>mean_y_63</th>
<th>mean_y_64</th>
<th>mean_y_65</th>
<th>mean_y_66</th>
<th>mean_y_67</th>
<th>mean_y_7</th>
<th>mean_y_8</th>
<th>mean_y_9</th>
</tr>
</thead>
<tbody>
<tr>
<th>badNews</th>
<td>0.370603</td>
<td>0.347909</td>
<td>0.274446</td>
<td>0.470608</td>
<td>0.144680</td>
<td>0.350956</td>
<td>0.057206</td>
<td>0.367228</td>
<td>0.414330</td>
<td>0.245751</td>
<td>...</td>
<td>714.571030</td>
<td>715.994335</td>
<td>711.230906</td>
<td>703.585629</td>
<td>715.312303</td>
<td>720.341735</td>
<td>718.979703</td>
<td>823.783636</td>
<td>827.212203</td>
<td>813.770216</td>
</tr>
<tr>
<th>goodNews</th>
<td>0.437070</td>
<td>0.399585</td>
<td>0.209061</td>
<td>0.219561</td>
<td>0.641241</td>
<td>0.642395</td>
<td>0.161864</td>
<td>0.775689</td>
<td>0.412116</td>
<td>0.814605</td>
<td>...</td>
<td>684.355943</td>
<td>686.797688</td>
<td>683.110011</td>
<td>676.147267</td>
<td>693.425396</td>
<td>697.551264</td>
<td>695.402943</td>
<td>810.933791</td>
<td>817.027471</td>
<td>806.257672</td>
</tr>
</tbody>
</table>
<p>2 rows × 169 columns</p>
</div></div></div>
</div>
<p>Or simply extract features per video</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Extract features per video</span>
<span class="n">fex</span><span class="o">.</span><span class="n">sessions</span> <span class="o">=</span> <span class="n">fex</span><span class="o">.</span><span class="n">input</span><span class="p">()</span>
<span class="n">average_au_intensity_per_video</span> <span class="o">=</span> <span class="n">fex</span><span class="o">.</span><span class="n">extract_mean</span><span class="p">()</span>
<span class="n">display</span><span class="p">(</span><span class="n">average_au_intensity_per_video</span><span class="o">.</span><span class="n">head</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>mean_AU01</th>
<th>mean_AU02</th>
<th>mean_AU04</th>
<th>mean_AU05</th>
<th>mean_AU06</th>
<th>mean_AU07</th>
<th>mean_AU09</th>
<th>mean_AU10</th>
<th>mean_AU11</th>
<th>mean_AU12</th>
<th>...</th>
<th>mean_y_61</th>
<th>mean_y_62</th>
<th>mean_y_63</th>
<th>mean_y_64</th>
<th>mean_y_65</th>
<th>mean_y_66</th>
<th>mean_y_67</th>
<th>mean_y_7</th>
<th>mean_y_8</th>
<th>mean_y_9</th>
</tr>
</thead>
<tbody>
<tr>
<th>001.mp4</th>
<td>0.367902</td>
<td>0.304953</td>
<td>0.217278</td>
<td>0.247205</td>
<td>0.529641</td>
<td>0.546710</td>
<td>0.127434</td>
<td>0.689482</td>
<td>0.405150</td>
<td>0.757060</td>
<td>...</td>
<td>694.305659</td>
<td>696.236139</td>
<td>692.150659</td>
<td>682.592831</td>
<td>696.408174</td>
<td>700.882806</td>
<td>699.187324</td>
<td>814.856982</td>
<td>819.742603</td>
<td>808.427911</td>
</tr>
<tr>
<th>002.mp4</th>
<td>0.384290</td>
<td>0.372414</td>
<td>0.218073</td>
<td>0.238233</td>
<td>0.466245</td>
<td>0.568260</td>
<td>0.139705</td>
<td>0.645774</td>
<td>0.406103</td>
<td>0.665162</td>
<td>...</td>
<td>686.464658</td>
<td>688.592334</td>
<td>685.344299</td>
<td>677.572549</td>
<td>688.540245</td>
<td>692.234408</td>
<td>690.349490</td>
<td>806.882534</td>
<td>812.669819</td>
<td>802.669351</td>
</tr>
<tr>
<th>003.mp4</th>
<td>0.475926</td>
<td>0.435061</td>
<td>0.193346</td>
<td>0.235034</td>
<td>0.628517</td>
<td>0.614398</td>
<td>0.130048</td>
<td>0.758156</td>
<td>0.406965</td>
<td>0.822223</td>
<td>...</td>
<td>678.527397</td>
<td>681.056783</td>
<td>677.828855</td>
<td>672.959971</td>
<td>688.190226</td>
<td>691.792301</td>
<td>689.539840</td>
<td>803.369594</td>
<td>810.371285</td>
<td>800.508759</td>
</tr>
<tr>
<th>004.mp4</th>
<td>0.465396</td>
<td>0.431265</td>
<td>0.215378</td>
<td>0.136780</td>
<td>0.719656</td>
<td>0.712953</td>
<td>0.195271</td>
<td>0.852897</td>
<td>0.413281</td>
<td>0.888342</td>
<td>...</td>
<td>682.179613</td>
<td>684.565805</td>
<td>680.513723</td>
<td>674.068777</td>
<td>694.367983</td>
<td>698.833575</td>
<td>696.740101</td>
<td>811.564575</td>
<td>817.511093</td>
<td>806.248735</td>
</tr>
<tr>
<th>005.mp4</th>
<td>0.358873</td>
<td>0.346983</td>
<td>0.196898</td>
<td>0.132950</td>
<td>0.729992</td>
<td>0.724506</td>
<td>0.230352</td>
<td>0.844839</td>
<td>0.421897</td>
<td>0.883427</td>
<td>...</td>
<td>701.603967</td>
<td>703.849507</td>
<td>699.122215</td>
<td>687.917109</td>
<td>711.293560</td>
<td>716.390717</td>
<td>714.357210</td>
<td>827.466633</td>
<td>833.453529</td>
<td>821.740933</td>
</tr>
</tbody>
</table>
<p>5 rows × 169 columns</p>
</div></div></div>
</div>
</div>
</div>
<div class="section" id="analyzing-fex-data">
<h1>Analyzing FEX data<a class="headerlink" href="#analyzing-fex-data" title="Permalink to this headline">¶</a></h1>
<div class="section" id="simple-t-test">
<h2>Simple t-test<a class="headerlink" href="#simple-t-test" title="Permalink to this headline">¶</a></h2>
<p>You can use a simple t-test to test if the average activation of a certain AU is significantly higher than .5 (chance). The results suggests that AU10 (upper lip raiser), 12 (lip corner puller), and 14 (dimpler) is significantly activitated when providing good news.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">average_au_intensity_per_video</span><span class="o">.</span><span class="n">sessions</span> <span class="o">=</span> <span class="n">average_au_intensity_per_video</span><span class="o">.</span><span class="n">index</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">input_class_map</span><span class="p">)</span>
<span class="n">t</span><span class="p">,</span> <span class="n">p</span> <span class="o">=</span> <span class="n">average_au_intensity_per_video</span><span class="p">[</span><span class="n">average_au_intensity_per_video</span><span class="o">.</span><span class="n">sessions</span><span class="o">==</span><span class="s2">"goodNews"</span><span class="p">]</span><span class="o">.</span><span class="n">aus</span><span class="p">()</span><span class="o">.</span><span class="n">ttest_1samp</span><span class="p">(</span><span class="o">.</span><span class="mi">5</span><span class="p">)</span>
<span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">({</span><span class="s2">"t"</span><span class="p">:</span> <span class="n">t</span><span class="p">,</span> <span class="s2">"p"</span><span class="p">:</span> <span class="n">p</span><span class="p">},</span> <span class="n">index</span><span class="o">=</span> <span class="n">average_au_intensity_per_video</span><span class="o">.</span><span class="n">au_columns</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>t</th>
<th>p</th>
</tr>
</thead>
<tbody>
<tr>
<th>mean_AU01</th>
<td>-2.927201</td>
<td>1.683346e-02</td>
</tr>
<tr>
<th>mean_AU02</th>
<td>-5.838201</td>
<td>2.473720e-04</td>
</tr>
<tr>
<th>mean_AU04</th>
<td>-49.805912</td>
<td>2.660164e-12</td>
</tr>
<tr>
<th>mean_AU05</th>
<td>-11.942339</td>
<td>8.022300e-07</td>
</tr>
<tr>
<th>mean_AU06</th>
<td>3.905366</td>
<td>3.589972e-03</td>
</tr>
<tr>
<th>mean_AU07</th>
<td>5.487334</td>
<td>3.864728e-04</td>
</tr>
<tr>
<th>mean_AU09</th>
<td>-22.647961</td>
<td>3.024835e-09</td>
</tr>
<tr>
<th>mean_AU10</th>
<td>10.361594</td>
<td>2.660301e-06</td>
</tr>
<tr>
<th>mean_AU11</th>
<td>-42.691265</td>
<td>1.059418e-11</td>
</tr>
<tr>
<th>mean_AU12</th>
<td>11.949046</td>
<td>7.984040e-07</td>
</tr>
<tr>
<th>mean_AU14</th>
<td>23.155621</td>
<td>2.485336e-09</td>
</tr>
<tr>
<th>mean_AU15</th>
<td>-12.587565</td>
<td>5.119202e-07</td>
</tr>
<tr>
<th>mean_AU17</th>
<td>-0.460219</td>
<td>6.562759e-01</td>
</tr>
<tr>
<th>mean_AU20</th>
<td>-45.470892</td>
<td>6.019391e-12</td>
</tr>
<tr>
<th>mean_AU23</th>
<td>-0.300423</td>
<td>7.706780e-01</td>
</tr>
<tr>
<th>mean_AU24</th>
<td>-4.533345</td>
<td>1.419377e-03</td>
</tr>
<tr>
<th>mean_AU25</th>
<td>3.119502</td>
<td>1.232852e-02</td>
</tr>
<tr>
<th>mean_AU26</th>
<td>-5.015769</td>
<td>7.232461e-04</td>
</tr>
<tr>
<th>mean_AU28</th>
<td>-7.169935</td>
<td>5.251451e-05</td>
</tr>
<tr>
<th>mean_AU43</th>
<td>-78.139016</td>
<td>4.660607e-14</td>
</tr>
</tbody>
</table>
</div></div></div>
</div>
</div>
<div class="section" id="two-sample-independent-t-test">
<h2>Two sample independent t-test<a class="headerlink" href="#two-sample-independent-t-test" title="Permalink to this headline">¶</a></h2>
<p>You can also perform an independent two sample ttest between two sessions which in this case is goodNews vs badNews.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">columns2compare</span> <span class="o">=</span> <span class="s2">"mean_AU12"</span>
<span class="n">sessions</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"goodNews"</span><span class="p">,</span> <span class="s2">"badNews"</span><span class="p">)</span>
<span class="n">t</span><span class="p">,</span> <span class="n">p</span> <span class="o">=</span> <span class="n">average_au_intensity_per_video</span><span class="o">.</span><span class="n">ttest_ind</span><span class="p">(</span><span class="n">col</span> <span class="o">=</span> <span class="n">columns2compare</span><span class="p">,</span> <span class="n">sessions</span><span class="o">=</span><span class="n">sessions</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"T-test between </span><span class="si">{</span><span class="n">sessions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> vs </span><span class="si">{</span><span class="n">sessions</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">: t=</span><span class="si">{</span><span class="n">t</span><span class="si">:</span><span class="s2">.2g</span><span class="si">}</span><span class="s2">, p=</span><span class="si">{</span><span class="n">p</span><span class="si">:</span><span class="s2">.3g</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
<span class="n">sns</span><span class="o">.</span><span class="n">barplot</span><span class="p">(</span><span class="n">x</span> <span class="o">=</span> <span class="n">average_au_intensity_per_video</span><span class="o">.</span><span class="n">sessions</span><span class="p">,</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">columns2compare</span><span class="p">,</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">average_au_intensity_per_video</span><span class="p">);</span>
</pre></div>
</div>