demo-emotion-regression/code/annotations2regr
2016-04-19 08:18:39 +02:00

45 lines
1.6 KiB
Text

import numpy as np
run_onset = np.array((0.0, 894., 1760., 2620., 3580., 4488., 5350., 6418., 7086.))
run_vols = np.array((451, 441, 438, 488, 462, 439, 542, 338))
target_length = run_vols.sum() - 8 * 7
def split4runs(label, data):
if not len(data) == target_length:
n = np.zeros(target_length, dtype=data.dtype)
n[:len(data)] = data
data = n
for i, vols in enumerate(run_vols):
if i == 0:
start = 0
else:
start = run_vols[:i].sum() - (8 * i)
if i == 7:
end = None
else:
end = start + run_vols[i]
np.savetxt('design/emo_%s_run-%i.txt' % (label, i + 1),
data[start: end],
fmt='%.3f')
annot = np.recfromcsv(
'src/annotations/emotions/audio-visual/timeseries/ioats_2s_av_allchar.csv')
for f in ('arousal', 'valence', 'direction', 'audio', 'context', 'face',
'gesture', 'verbal'):
if f in ('arousal', 'valence', 'direction'):
split4runs('%s_pos' % f, np.clip(annot[f], 0, 1))
split4runs('%s_neg' % f, -1 * np.clip(annot[f], -1, 0))
else:
split4runs(f, annot[f])
import pandas
dialog = pandas.read_csv('src/annotations/speech/english_dialog.csv')
onset = dialog['start'].as_matrix()
duration = dialog['end'].as_matrix() - onset
for i, ronset in enumerate(run_onset[:-1]):
selector = np.logical_and(onset >= ronset, onset < run_onset[i + 1])
np.savetxt('design/speech_run-%i.txt' % (i + 1),
np.array((onset[selector] - ronset,
duration[selector],
[1] * selector.sum())).T,
fmt='%.3f')