aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2022-05-20 15:41:13 +0200
committerThéo de la Hogue2022-05-20 15:41:13 +0200
commitdad3191ce9173f8a1d2b1be60bc6e3542f80e648 (patch)
treed9269cd0fc93fd217e15bfd5cce138f60f658751
parent5b5db9309c0952108a571d6b63180cb85b562e8f (diff)
downloadargaze-dad3191ce9173f8a1d2b1be60bc6e3542f80e648.zip
argaze-dad3191ce9173f8a1d2b1be60bc6e3542f80e648.tar.gz
argaze-dad3191ce9173f8a1d2b1be60bc6e3542f80e648.tar.bz2
argaze-dad3191ce9173f8a1d2b1be60bc6e3542f80e648.tar.xz
Adding down sampling features.
-rw-r--r--src/argaze/DataStructures.py10
-rw-r--r--src/argaze/utils/export_tobii_segment_plots.py18
2 files changed, 19 insertions, 9 deletions
diff --git a/src/argaze/DataStructures.py b/src/argaze/DataStructures.py
index f66ad78..637a007 100644
--- a/src/argaze/DataStructures.py
+++ b/src/argaze/DataStructures.py
@@ -109,11 +109,19 @@ class TimeStampedBuffer(collections.OrderedDict):
except:
raise RuntimeError(f'Can\' write {filepath}')
- def plot(self, names=[], colors=[], split={}):
+ def plot(self, names=[], colors=[], split={}, samples=None):
df = self.as_dataframe(split=split)
legend_patches = []
+ # decimate data
+ if samples != None:
+
+ if samples < len(df):
+
+ step = int(len(df) / samples) + 1
+ df = df.iloc[::step, :]
+
for name, color in zip(names, colors):
markerline, stemlines, baseline = mpyplot.stem(df.index, df[name])
diff --git a/src/argaze/utils/export_tobii_segment_plots.py b/src/argaze/utils/export_tobii_segment_plots.py
index 359748e..d28bafb 100644
--- a/src/argaze/utils/export_tobii_segment_plots.py
+++ b/src/argaze/utils/export_tobii_segment_plots.py
@@ -58,13 +58,15 @@ def main():
print(f'\t{name}: {len(tobii_segment_data[name])} data')
# Edit figure
- figure = mpyplot.figure(figsize=(4 * tobii_segment_video.get_duration() / 1e6, 35))
+ figure_width = min( 4 * tobii_segment_video.get_duration() / 1e6, 56) # maximal width to display: 56 inches at 144 dpi < 2^16 pixels
+ data_sample = 8064 # 56 inches * 144 dpi = 8064 data can be displayed at max
+ figure = mpyplot.figure(figsize=(figure_width, 35), dpi=144)
# Plot pupil diameter data
subplot = figure.add_subplot(711)
subplot.set_title('Pupil diameter', loc='left')
subplot.set_ylim(0, 10)
- patches = tobii_segment_data['PupilDiameter'].plot(names=['value'], colors=['#FFD800'])
+ patches = tobii_segment_data['PupilDiameter'].plot(names=['value'], colors=['#FFD800'], samples=data_sample)
subplot.legend(handles=patches, loc='upper left')
# Annotate events
@@ -80,38 +82,38 @@ def main():
subplot = figure.add_subplot(712)
subplot.set_title('Pupil center', loc='left')
subplot.set_ylim(-40, -20)
- patches = tobii_segment_data['PupilCenter'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']})
+ patches = tobii_segment_data['PupilCenter'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']}, samples=data_sample)
subplot.legend(handles=patches, loc='upper left')
# Plot gaze position data
subplot = figure.add_subplot(713)
subplot.set_title('Gaze position', loc='left')
subplot.set_ylim(0., 1.)
- patches = tobii_segment_data['GazePosition'].plot(names=['x','y'], colors=['#276FB6','#9427B6'], split={'value':['x','y']})
+ patches = tobii_segment_data['GazePosition'].plot(names=['x','y'], colors=['#276FB6','#9427B6'], split={'value':['x','y']}, samples=data_sample)
subplot.legend(handles=patches, loc='upper left')
# Plot gaze direction data
subplot = figure.add_subplot(714)
subplot.set_title('Gaze direction', loc='left')
- patches = tobii_segment_data['GazeDirection'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']})
+ patches = tobii_segment_data['GazeDirection'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']}, samples=data_sample)
subplot.legend(handles=patches, loc='upper left')
# Plot gaze direction data
subplot = figure.add_subplot(715)
subplot.set_title('Gaze position 3D', loc='left')
- patches = tobii_segment_data['GazePosition3D'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']})
+ patches = tobii_segment_data['GazePosition3D'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']}, samples=data_sample)
subplot.legend(handles=patches, loc='upper left')
# Plot accelerometer data
subplot = figure.add_subplot(716)
subplot.set_title('Accelerometer', loc='left')
- patches = tobii_segment_data['Accelerometer'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']})
+ patches = tobii_segment_data['Accelerometer'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']}, samples=data_sample)
subplot.legend(handles=patches, loc='upper left')
# Plot accelerometer data
subplot = figure.add_subplot(717)
subplot.set_title('Gyroscope', loc='left')
- patches = tobii_segment_data['Gyroscope'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']})
+ patches = tobii_segment_data['Gyroscope'].plot(names=['x','y','z'], colors=['#276FB6','#9427B6','#888888'], split={'value':['x','y','z']}, samples=data_sample)
subplot.legend(handles=patches, loc='upper left')
# Export figure