aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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