Back to the main page.
Bug 2980 - possible speed increase: allow ft_plot_XXX functions to work with vpos being a vector (instead of only scalar)
Status |
NEW |
Reported |
2015-10-06 01:18:00 +0200 |
Modified |
2015-10-06 01:18:34 +0200 |
Product: |
FieldTrip |
Component: |
plotting |
Version: |
unspecified |
Hardware: |
All |
Operating System: |
All |
Importance: |
P5 enhancement |
Assigned to: |
|
URL: |
|
Tags: |
|
Depends on: |
|
Blocks: |
|
See also: |
|
Roemer van der Meij - 2015-10-06 01:18:34 +0200
This came up in bug# 2878. A large part of the time it takes ft_databrowser to draw a new trial is caused by repeatedly calling ft_plot_vector. This is causing a slow down, which can be traced back to calling plot.m multiple times. This can illustrated by the code down below.
By allowing ft_plot_vector to work with a vpos per row in its input (if its input is a matrix), speed increases can be achieved. This is probably around 2-fold (see below), which decreases at higher number of channels.
If this is done, this must be done consistently in all ft_plot functions that use local axis:
grep -l vpos *.m
ft_plot_box.m
ft_plot_lay.m
ft_plot_line.m
ft_plot_matrix.m
ft_plot_patch.m
ft_plot_text.m
ft_plot_topo.m
ft_plot_vector.m
ft_uilayout.m (prolly not this one)
The slow down can be illustrated by the below:
******************
time = 1:1000;
figure
hpos = rand(100,1);
vpos = rand(100,1);
width = 0.1 * ones(100,1);
height = 0.1 * ones(100,1);
% time plotting without vpos'ing
tic
for i=1:100
cla
dat = randn(100, 1000);
%ft_plot_vector(time, dat);
plot(time, dat);
drawnow
end
toc
% time plotting with vpos'ing
cla
tic
for i=1:100
cla
dat = randn(100, 1000);
for i=1:100
%ft_plot_vector(time, dat(i,:), 'hpos', hpos(i), 'vpos', vpos(i), 'width', width(i), 'height', height(i));
plot(time, dat(i,:));
end
drawnow
end
toc
******************
Using ft_plot_vector:
Elapsed time is 14.788130 seconds.
Elapsed time is 30.443646 seconds.
Using plot.m:
Elapsed time is 9.943976 seconds.
Elapsed time is 26.832142 seconds.