Skip to content

Instantly share code, notes, and snippets.

@jcheong0428
Last active November 25, 2021 16:10
Show Gist options
  • Save jcheong0428/0de74d5855ee5f3ef9b0f4cf63cd76d1 to your computer and use it in GitHub Desktop.
Save jcheong0428/0de74d5855ee5f3ef9b0f4cf63cd76d1 to your computer and use it in GitHub Desktop.
synchrony02.py
# Set window size to compute moving window synchrony.
r_window_size = 120
# Interpolate missing data.
df_interpolated = df.interpolate()
# Compute rolling window synchrony
rolling_r = df_interpolated['S1_Joy'].rolling(window=r_window_size, center=True).corr(df_interpolated['S2_Joy'])
f,ax=plt.subplots(2,1,figsize=(14,6),sharex=True)
df.rolling(window=30,center=True).median().plot(ax=ax[0])
ax[0].set(xlabel='Frame',ylabel='Smiling Evidence')
rolling_r.plot(ax=ax[1])
ax[1].set(xlabel='Frame',ylabel='Pearson r')
plt.suptitle("Smiling data and rolling window correlation")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment