Skip to content

jaysonjeg/FacialDynamicsHMM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FacialDynamicsHMM

This repository contains the Matlab-based pipeline to analyse facial affect dynamics with time-frequency representations and hidden Markov model. The code will run this pipeline on the openly available DISFA dataset, and reproduce the healthy control results in the paper "Quantifying dynamic facial expressions under naturalistic conditions".

To reproduce the results, run the following in order:

  1. DISFA_Step1_vid2csv.m. Calls OpenFace to generate facial AU time series from DISFA dataset.
  2. DISFA_Step2_csv2cubes.m. Puts facial AU time series into nice Matlab arrays
  3. DISFA_Step3_cubes2cwt2hmm.m. Runs the pipeline, starting from Matlab arrays containing AU time series. Generates Figures 1 and 2.

If you don't want to reproduce the results on DISFA but rather want to apply it on your own data, first run OpenFace on your data to produce action unit time series. Then make sure your data is in a matlab array called 'cube' which is ntimepoints x nAUs x nSubjects. Using our function get_cwt.m, type in Matlab: abs(get_cwt(cube,YourWebcamFrameRate,true)) to get wavelet transform representation of your data. Then do lines 265-271 in DISFA_Step3_cubes2cwt2hmm to get it into HMM-ready format. Then, you can either continue with the rest of the script, or follow the HMM-MAR usage notes yourself to implement the HMM.

Subfolder 'for_melancholia' has scripts to run it on our melancholia data. This subfolder is for internal users who have access to the data

System: I used a Windows 10 operating system, 64-bit, 6 cores, with 64GB RAM. I used Matlab R2021a.

Software dependencies:

The HMM-MAR code was modified slightly. These are the changes.

  • In initGamma_random.m, changed line 17 to rng(1), (for reproducibility)
  • In hmmmar_init.m, lines 109-113, deleted last parameter options.priorOFFvsON (to prevent an error)
  • In padGamma.m, line 27, deleted ‘offset=sum(d)’ and ‘Tshifted=T-offset’. Add ‘Tshifted=T’. (to prevent error with padGamma).

My fork of HMM-MAR at https://github.com/jaysonjeg/HMM-MAR/tree/branch1, already has these changes

Citation: If you use the scripts, please cite the following: https://elifesciences.org/articles/79581

About

Pipeline to analyse facial affect dynamics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages