Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Jesse Heckman
pbtoolbox
Commits
dac14a84
Commit
dac14a84
authored
Feb 21, 2019
by
Jesse Heckman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new moving sound update and draft plots
parent
9860ff9c
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
348 additions
and
121 deletions
+348
-121
setups/vestibular chair/vPrime/tdt/rcx/StateMachineV1.11.rcx
setups/vestibular chair/vPrime/tdt/rcx/StateMachineV1.11.rcx
+0
-0
subtools/draft/@pb_draft/dplot.m
subtools/draft/@pb_draft/dplot.m
+0
-0
subtools/draft/@pb_draft/draft.m
subtools/draft/@pb_draft/draft.m
+8
-4
subtools/draft/@pb_draft/fit_ellipse.m
subtools/draft/@pb_draft/fit_ellipse.m
+46
-0
subtools/draft/@pb_draft/pb_draft.m
subtools/draft/@pb_draft/pb_draft.m
+1
-1
subtools/draft/@pb_draft/plot_bubble.m
subtools/draft/@pb_draft/plot_bubble.m
+19
-31
subtools/draft/@pb_draft/plot_rawdata.m
subtools/draft/@pb_draft/plot_rawdata.m
+28
-12
subtools/draft/@pb_draft/private/parse_va.m
subtools/draft/@pb_draft/private/parse_va.m
+2
-0
subtools/draft/@pb_draft/set_grid.m
subtools/draft/@pb_draft/set_grid.m
+19
-0
subtools/draft/@pb_draft/set_title.m
subtools/draft/@pb_draft/set_title.m
+3
-3
subtools/draft/example_draft.m
subtools/draft/example_draft.m
+8
-6
utilities/.DS_Store
utilities/.DS_Store
+0
-0
utilities/statistics/pa_ellipseplot.m
utilities/statistics/pa_ellipseplot.m
+52
-0
utilities/statistics/pb_ellipse.m
utilities/statistics/pb_ellipse.m
+46
-0
utilities/statistics/pb_ellipseplot.m
utilities/statistics/pb_ellipseplot.m
+51
-0
utilities/statistics/pb_ellipsoid.m
utilities/statistics/pb_ellipsoid.m
+37
-35
utilities/statistics/pb_regplot.m
utilities/statistics/pb_regplot.m
+28
-29
No files found.
setups/vestibular chair/vPrime/tdt/rcx/StateMachineV1.11.rcx
0 → 100644
View file @
dac14a84
File added
subtools/draft/@pb_draft/dplot.m
deleted
100644 → 0
View file @
9860ff9c
subtools/draft/@pb_draft/draft.m
View file @
dac14a84
...
...
@@ -49,21 +49,25 @@ function draft(obj)
axis
(
obj
(
iAx
)
.
pva
.
axis
);
hold
on
;
% Set colors
nCol
=
1
;
if
~
obj
(
iObj
)
.
pva
.
continious
nCol
=
length
(
unique
(
obj
(
iObj
)
.
pva
.
color
));
end
%
Plot data
%
FIX COLOR REPEAT ONLY FOR COLOR SPLITTING DATA
colors
=
pb_selectcolor
(
nCol
,
obj
(
iAx
)
.
pva
.
def
);
uD
=
unique
(
obj
(
iAx
)
.
pva
.
color
);
for
iCol
=
1
:
nCol
d
=
obj
(
iAx
)
.
pva
;
d
.
ind
=
d
.
color
==
uD
(
iCol
);
d
.
color
=
colors
(
iCol
,:);
for
iDP
=
1
:
length
(
obj
(
iObj
)
.
dplot
)
obj
(
iObj
)
.
dplot
{
iDP
}(
obj
,
d
);
end
end
% Plot all graphs
for
iDP
=
1
:
length
(
obj
(
iObj
)
.
dplot
)
d
=
obj
(
iAx
)
.
pva
;
obj
(
iObj
)
.
dplot
{
iDP
}(
obj
,
d
);
end
% Set labels
...
...
subtools/draft/@pb_draft/fit_ellipse.m
0 → 100644
View file @
dac14a84
function
fit_ellipse
(
obj
,
varargin
)
% PB_DRAFT>FIT_ELLIPSE
%
% OBJ.PLOT_VLINE(varargin) will add plot handle for draft function to object.
%
% See also PB_DRAFT
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
v
=
varargin
;
p
.
type
=
pb_keyval
(
'type'
,
v
,
'dot'
);
p
.
alpha
=
pb_keyval
(
'alpha'
,
v
,
1
);
%% crashes if you change the alpha to below 1?
p
.
marker
=
pb_keyval
(
'marker'
,
v
,
'o'
);
p
.
markersz
=
pb_keyval
(
'markersz'
,
v
,
3
);
p
.
linestyle
=
pb_keyval
(
'linestyle'
,
v
,
'-'
);
p
.
linewidth
=
pb_keyval
(
'linestyle'
,
v
,
2
);
p
.
fcol
=
pb_keyval
(
'facecolor'
,
v
,
'fill'
);
p
.
col
=
pb_keyval
(
'color'
,
v
,
'k'
);
p
.
ncol
=
pb_keyval
(
'ncol'
,
v
,
unique
(
obj
.
pva
.
color
));
for
iCol
=
1
:
length
(
p
.
ncol
)
obj
.
dplot
=
vertcat
(
obj
.
dplot
,{
@
(
dobj
,
data
)
ellipsefit
(
dobj
,
data
,
p
,
p
.
ncol
(
iCol
))});
end
obj
.
results
.
ellipse_handle
=
{};
end
function
h
=
ellipsefit
(
~
,
data
,
p
,
colorindex
)
% makes a vertical
sel
=
data
.
color
==
colorindex
;
x
=
data
.
x
(
sel
);
y
=
data
.
y
(
sel
);
color
=
pb_selectcolor
(
length
(
p
.
ncol
),
data
.
def
);
[
Mu
,
SD
,
Phi
,
~
,
~
]
=
pb_ellipse
(
x
,
y
);
h
=
pb_ellipseplot
(
Mu
,
SD
,
Phi
,
'Color'
,
color
(
colorindex
,:));
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2019) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
subtools/draft/@pb_draft/pb_draft.m
View file @
dac14a84
...
...
@@ -56,7 +56,7 @@ classdef pb_draft < matlab.mixin.Copyable
plot_hline
(
obj
,
varargin
);
% plot horizontal lines
plot_vline
(
obj
,
varargin
);
% plot vertical lines
plot_dline
(
obj
,
varargin
);
% plot diagonal lines
plot_bubble
(
obj
,
varargin
);
plot_bubble
(
obj
,
varargin
);
% plot bubblr histoplot
stat_regres
(
obj
,
varargin
);
% transform regression
stat_probit
(
obj
,
varargin
);
% transform probit
...
...
subtools/draft/@pb_draft/plot_bubble.m
View file @
dac14a84
...
...
@@ -13,17 +13,18 @@ function plot_bubble(obj,varargin)
p
.
YW
=
pb_keyval
(
'Ywidth'
,
v
);
p
.
BS
=
pb_keyval
(
'binsize'
,
v
);
p
.
def
=
pb_keyval
(
'def'
,
v
,
5
);
p
.
marker
=
pb_keyval
(
'marker'
,
v
,
'o'
);
obj
.
dplot
=
vertcat
(
obj
.
dplot
,{
@
(
dobj
,
data
)
bubble_plot
(
dobj
,
data
,
p
)});
obj
.
results
.
bubbleplot_handle
=
{};
end
function
h
=
bubble_plot
(
~
,
data
,
p
)
% Bubbleplot
%
%
Bubbleplot
% Select binsizes
if
isempty
(
p
.
XW
);
[
~
,
~
,
p
.
XW
,
~
]
=
pb_binsize
(
data
.
x
);
end
if
isempty
(
p
.
YW
);
[
~
,
~
,
p
.
YW
,
~
]
=
pb_binsize
(
data
.
y
);
end
if
isempty
(
p
.
XW
);
[
~
,
~
,
p
.
XW
,
~
]
=
pb_binsize
(
data
.
x
);
p
.
XW
=
p
.
XW
*
3
;
end
if
isempty
(
p
.
YW
);
[
~
,
~
,
p
.
YW
,
~
]
=
pb_binsize
(
data
.
y
);
p
.
YW
=
p
.
YW
*
3
;
end
if
~
isempty
(
p
.
BS
);
p
.
XW
=
p
.
BS
;
p
.
YW
=
p
.
BS
;
end
% Hist
...
...
@@ -37,7 +38,7 @@ function h = bubble_plot(~,data,p)
TOT
=
NaN
(
size
(
UX
));
for
ii
=
1
:
length
(
uX
)
sel
=
X
==
uX
(
ii
);
sel
=
X
==
uX
(
ii
);
r
=
Y
(
sel
);
N
=
hist
(
r
,
x
);
if
isscalar
(
x
)
...
...
@@ -46,42 +47,29 @@ function h = bubble_plot(~,data,p)
TOT
(:,
ii
)
=
N
;
end
%
%
Normalize
TOT
=
log10
(
TOT
+
1
);
m
xTOT
=
nanmax
(
nanmax
(
TOT
));
m
nTOT
=
nanmin
(
nanmin
(
TOT
));
TOT
=
(
TOT
-
mnTOT
)
.
/(
mxTOT
-
mnTOT
);
% Normalize
TOT
=
log10
(
TOT
+
1
);
m
axima
(
1
)
=
nanmax
(
nanmax
(
TOT
));
m
axima
(
2
)
=
nanmin
(
nanmin
(
TOT
));
TOT
=
(
TOT
-
maxima
(
2
))
.
/(
maxima
(
1
)
-
maxima
(
2
)
);
%
%
Plot
M
=
TOT
(:);
x
=
UX
(:);
y
=
UY
(:);
% Plot
M
=
TOT
(:);
x
=
UX
(:);
y
=
UY
(:);
sel
=
M
>
0
;
M
=
M
(
sel
);
x
=
x
(
sel
);
y
=
y
(
sel
);
sel
=
M
>
0
;
M
=
M
(
sel
);
x
=
x
(
sel
);
y
=
y
(
sel
);
SZ
=
ceil
(
100
*
M
);
[
~
,
~
,
idx
]
=
unique
(
M
);
col
=
statcolor
(
max
(
idx
),[],[],[],
'def'
,
p
.
def
);
C
=
col
(
idx
,:);
h
=
plot
(
x
,
...
y
,
...
'Marker'
,
p
.
marker
,
...
'LineStyle'
,
p
.
ls
,
...
'Color'
,
C
);
'MarkerFaceColor'
,
C
...
'MarkerSize'
,
p
.
markersz
);
h
=
scatter
(
x
,
y
,
SZ
,
C
,
'filled'
);
end
'Color'
,
data
.
color
,
...
switchpar
,
...
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
...
...
subtools/draft/@pb_draft/plot_rawdata.m
View file @
dac14a84
...
...
@@ -8,32 +8,48 @@ function plot_rawdata(obj,varargin)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
v
=
varargin
;
p
.
type
=
pb_keyval
(
'type'
,
v
,
'
line
'
);
p
.
type
=
pb_keyval
(
'type'
,
v
,
'
dot
'
);
p
.
alpha
=
pb_keyval
(
'alpha'
,
v
,
1
);
%% crashes if you change the alpha to below 1?
p
.
marker
=
pb_keyval
(
'marker'
,
v
,
'o'
);
p
.
markersz
=
pb_keyval
(
'markersz'
,
v
,
3
);
p
.
ls
=
pb_keyval
(
'linestyle'
,
v
,
'none'
);
p
.
linestyle
=
pb_keyval
(
'linestyle'
,
v
,
'-'
);
p
.
linewidth
=
pb_keyval
(
'linestyle'
,
v
,
2
);
p
.
fcol
=
pb_keyval
(
'facecolor'
,
v
,
'fill'
);
p
.
col
=
pb_keyval
(
'color'
,
v
,
'k'
);
obj
.
dplot
=
vertcat
(
obj
.
dplot
,{
@
(
dobj
,
data
)
rawdata
(
dobj
,
data
,
p
)});
p
.
ncol
=
pb_keyval
(
'ncol'
,
v
,
unique
(
obj
.
pva
.
color
));
for
iCol
=
1
:
length
(
p
.
ncol
)
obj
.
dplot
=
vertcat
(
obj
.
dplot
,{
@
(
dobj
,
data
)
rawdata
(
dobj
,
data
,
p
,
p
.
ncol
(
iCol
))});
end
obj
.
results
.
rawdata_handle
=
{};
end
function
h
=
rawdata
(
~
,
data
,
p
)
function
h
=
rawdata
(
~
,
data
,
p
,
colorindex
)
% Plots rawdata
%% MAKE SELECTION FOR COLOR!
sel
=
data
.
color
==
colorindex
;
x
=
data
.
x
(
sel
);
y
=
data
.
y
(
sel
);
color
=
pb_selectcolor
(
length
(
p
.
ncol
),
data
.
def
);
switch
p
.
type
case
'dot'
sz
=
p
.
sz
;
h
=
scatter
(
data
.
x
,
data
.
y
,
ceil
(
p
.
markersz
/
2.5
),
data
.
color
,
'filled'
,
'MarkerFaceAlpha'
,
p
.
alpha
);
%% crashes if you change the alpha to below 1?
case
'line'
if
strcmp
(
p
.
fcol
,
'fill'
);
switchpar
=
data
.
color
;
else
;
switchpar
=
'none'
;
end
h
=
plot
(
data
.
x
(
data
.
ind
),
...
data
.
y
(
data
.
ind
),
...
h
=
plot
(
x
,
...
y
,
...
'Color'
,
data
.
color
,
...
'Marker'
,
p
.
marker
,
...
'LineStyle'
,
p
.
ls
,
...
'LineStyle'
,
p
.
linestyle
,
...
'LineWidth'
,
p
.
linewidth
);
case
'dot'
if
strcmp
(
p
.
fcol
,
'fill'
);
switchpar
=
color
(
colorindex
,:);
else
;
switchpar
=
'none'
;
end
h
=
plot
(
x
,
...
y
,
...
'Color'
,
color
(
colorindex
,:),
...
'Marker'
,
p
.
marker
,
...
'LineStyle'
,
'none'
,
...
'MarkerFaceColor'
,
switchpar
,
...
'MarkerSize'
,
p
.
markersz
);
otherwise
...
...
subtools/draft/@pb_draft/private/parse_va.m
View file @
dac14a84
...
...
@@ -21,6 +21,8 @@ function parse_va(obj,varargin)
pva
.
axis
=
pb_keyval
(
'axis'
,
v
,
'square'
);
pva
.
subtitle
=
pb_keyval
(
'subtitle'
,
v
);
pva
.
colscheme
=
pb_selectcolor
(
length
(
unique
(
pva
.
color
)),
pva
.
def
);
obj
.
labels
.
xlab
=
pb_keyval
(
'xlab'
,
v
,
''
);
obj
.
labels
.
ylab
=
pb_keyval
(
'ylab'
,
v
,
''
);
...
...
subtools/draft/@pb_draft/set_grid.m
0 → 100644
View file @
dac14a84
function
set_grid
(
obj
,
varargin
)
% PB_DRAFT>SET_GRID
%
% SET_TITLE(obj,title,varargin) ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
subtools/draft/@pb_draft/set_title.m
View file @
dac14a84
function
set_title
(
obj
,
title
,
varargin
)
%
WRITETITLE()
%
PB_DRAFT>SET_GRID
%
%
WRITE
TITLE(
) ...
%
SET_
TITLE(
obj,title,varargin) sets title for pb_draft object
%
% See also
...
% See also
PB_DRAFT
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
...
...
subtools/draft/example_draft.m
View file @
dac14a84
...
...
@@ -3,22 +3,24 @@ pb_clean;
load
(
'exD_saccade'
);
cfn
=
pb_newfig
(
0
,
'size'
,[
0
0
17
17
],
'resize'
,
'off'
);
colormap
copper
;
%%
% construct
for
i
=
1
:
2
for
j
=
1
:
2
d
(
j
,
i
)
=
pb_draft
(
'x'
,
Saccades
.
GazeLatency
*
1000
,
'y'
,
Saccades
.
HeadLatency
*
1000
,
'color'
,
Saccades
.
Modality
,
'subtitle'
,[
's00'
num2str
(
i
)]);
d
(
j
,
i
)
=
pb_draft
(
'x'
,
Saccades
.
GazeLatency
*
1000
,
'y'
,
Saccades
.
HeadLatency
*
1000
,
'color'
,
Saccades
.
Modality
,
'subtitle'
,[
's00'
num2str
(
j
)]);
d
(
j
,
i
)
.
set_labels
(
'x'
,
'Gaze Latency (ms)'
,
'y'
,
'Head Latency (ms)'
);
if
~
iseven
(
j
)
d
(
j
,
i
)
.
plot_rawdata
(
'marker'
,
'o'
,
'facecolor'
,
'none'
)
;
d
(
j
,
i
)
.
plot_rawdata
;
else
d
(
j
,
i
)
.
plot_bubble
(
'binsize'
,
50
);
d
(
j
,
i
)
.
plot_bubble
;
d
(
j
,
i
)
.
fit_ellipse
;
end
d
(
j
,
i
)
.
plot_dline
%d(j,i).fit_ellipse;
d
(
j
,
i
)
.
plot_dline
;
d
(
j
,
i
)
.
plot_vline
(
'type'
,
'mode'
);
d
(
j
,
i
)
.
plot_hline
(
'type'
,
'mode'
);
end
end
...
...
utilities/.DS_Store
View file @
dac14a84
No preview for this file type
utilities/statistics/pa_ellipseplot.m
0 → 100644
View file @
dac14a84
function
h
=
pb_ellipseplot
(
Mu
,
SD
,
Phi
,
varargin
)
% PB_ELLIPSEPLOT
%
% PB_ELLIPSEPLOT(Mu,SD,Phi,varargin)
%
% See also PB_ELLIPSEP, PB_DRAFT
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
v
=
varargin
;
col
=
pb_keyval
(
'color'
,
v
,
'k'
);
alpha
=
pb_keyval
(
'alpha'
,
v
,
.
33
);
ls
=
pb_keyval
(
'linestyle'
,
v
,
'--'
);
SD
=
pb_keyval
(
'sd'
,
v
,
SD
*
2
);
disp
=
pb_keyval
(
'disp'
,
v
,
true
);
regcol
=
pb_keyval
(
'regcol'
,
v
,
col
);
hs
=
ishold
(
gca
);
hold
on
;
Xo
=
Mu
(
1
);
Yo
=
Mu
(
2
);
L
=
SD
(
1
);
S
=
SD
(
2
);
DTR
=
pi
/
180
;
Phi
=
Phi
*
DTR
;
% Ellipse
wt
=
(
0
:
.
1
:
360
)
.*
DTR
;
X
=
Xo
+
L
*
cos
(
Phi
)
*
cos
(
wt
)
-
S
*
sin
(
Phi
)
*
sin
(
wt
);
Y
=
Yo
+
L
*
sin
(
Phi
)
*
cos
(
wt
)
+
S
*
cos
(
Phi
)
*
sin
(
wt
);
% Graphics
h
=
patch
(
X
,
Y
,
col
);
set
(
h
(
1
),
...
'EdgeColor'
,
col
,
...
'LineWidth'
,
1
,
...
'LineStyle'
,
ls
,
...
'FaceAlpha'
,
alpha
);
if
disp
h
(
2
)
=
pb_regplot
(
X
,
Y
,
'data'
,
false
,
'color'
,
col
);
end
if
~
hs
;
hold
on
;
end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
utilities/statistics/pb_ellipse.m
0 → 100644
View file @
dac14a84
function
[
MU
,
SD
,
A
,
x
,
y
]
=
pb_ellipse
(
x
,
y
,
varargin
)
% PB_ELLIPSE
%
% PB_ELLIPSE(x,y,varargin)
%
% See also PB_ELLIPSEPLOT, PB_DRAFT
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
v
=
varargin
;
out
=
pb_keyval
(
'outlier'
,
v
,[]);
% Eigen-values for covariance-matrix
[
Veig
,
Deig
]
=
eig
(
cov
(
x
,
y
));
% Veig gives main axes
A
=
bf_rad2deg
(
atan2
(
Veig
(
2
),
Veig
(
1
)));
% angle
% Delete response >3SD
if
~
isempty
(
out
)
SD
=
sqrt
(
diag
(
Deig
));
% diagonal Deig = variance in the 2 main axes
xmu
=
mean
(
x
);
ymu
=
mean
(
y
);
[
Xr
,
Yr
]
=
rotate2d
(
x
,
y
,
-
A
);
seld
=
abs
(
Xr
-
mean
(
Xr
))
<
out
*
SD
(
2
)
&
abs
(
Yr
-
mean
(
Yr
))
<
out
*
SD
(
1
);
x
=
x
(
seld
);
y
=
y
(
seld
);
% Eigen-values for covariance-matrix
[
Veig
,
Deig
]
=
eig
(
cov
(
x
,
y
));
% Veig gives main axes
A
=
bf_rad2deg
(
atan2
(
Veig
(
2
),
Veig
(
1
)));
% angle
end
% diagonal Deig = variance in the 2 main axes
SD
=
sqrt
(
diag
(
Deig
));
xmu
=
mean
(
x
);
ymu
=
mean
(
y
);
MU
=
[
xmu
ymu
];
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
utilities/statistics/pb_ellipseplot.m
0 → 100644
View file @
dac14a84
function
h
=
pb_ellipseplot
(
Mu
,
SD
,
Phi
,
varargin
)
% PB_ELLIPSEPLOT
%
% PB_ELLIPSEPLOT(Mu,SD,Phi,varargin)
%
% See also PB_ELLIPSEP, PB_DRAFT
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
v
=
varargin
;
col
=
pb_keyval
(
'color'
,
v
,
'k'
);
alpha
=
pb_keyval
(
'alpha'
,
v
,
.
33
);
ls
=
pb_keyval
(
'linestyle'
,
v
,
'--'
);
SD
=
pb_keyval
(
'sd'
,
v
,
SD
*
2
);
disp
=
pb_keyval
(
'disp'
,
v
,
false
);
regcol
=
pb_keyval
(
'regcol'
,
v
,
col
);
hs
=
ishold
(
gca
);
hold
on
;
Xo
=
Mu
(
1
);
Yo
=
Mu
(
2
);
L
=
SD
(
1
);
S
=
SD
(
2
);
DTR
=
pi
/
180
;
Phi
=
Phi
*
DTR
;
% Ellipse
wt
=
(
0
:
.
1
:
360
)
.*
DTR
;
X
=
Xo
+
L
*
cos
(
Phi
)
*
cos
(
wt
)
-
S
*
sin
(
Phi
)
*
sin
(
wt
);
Y
=
Yo
+
L
*
sin
(
Phi
)
*
cos
(
wt
)
+
S
*
cos
(
Phi
)
*
sin
(
wt
);
% Graphics
h
=
patch
(
X
,
Y
,
col
);
set
(
h
(
1
),
...
'EdgeColor'
,
col
,
...
'LineWidth'
,
1
,
...
'LineStyle'
,
ls
,
...
'FaceAlpha'
,
alpha
);
if
disp
;
h
(
2
)
=
pb_regplot
(
X
,
Y
,
'data'
,
false
,
'color'
,
col
);
end
%% REGRESSION DOES NOT MATCH ANGLE OF ELLIPSE
if
~
hs
;
hold
on
;
end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
utilities/statistics/pb_ellipsoid.m
View file @
dac14a84
function
pb_ellipsoid
(
)
function
[
MU
,
SD
,
A
,
x
,
y
]
=
ellipse
(
x
,
y
,
varargin
)
% PB_ELLIPSOID()
%
% PB_ELLIPSOID() ...
...
...
@@ -7,40 +7,42 @@ function pb_ellipsoid()
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
%% Initialization
out
=
keyval
(
'outlier'
,
varargin
);
splot
=
pb_keyval
(
'show'
,
varargin
,
true
);
if
isempty
(
out
)
out
=
[];
% (Hz)
end
%% Eigen-values for covariance-matrix
[
Veig
,
Deig
]
=
eig
(
cov
(
x
,
y
));
% Veig gives main axes
A
=
bf_rad2deg
(
atan2
(
Veig
(
2
),
Veig
(
1
)));
% angle
%% Delete response >3SD
if
~
isempty
(
out
)
SD
=
sqrt
(
diag
(
Deig
));
% diagonal Deig = variance in the 2 main axes
xmu
=
mean
(
x
);
ymu
=
mean
(
y
);
[
Xr
,
Yr
]
=
rotate2d
(
x
,
y
,
-
A
);
seld
=
abs
(
Xr
-
mean
(
Xr
))
<
out
*
SD
(
2
)
&
abs
(
Yr
-
mean
(
Yr
))
<
out
*
SD
(
1
);
x
=
x
(
seld
);
y
=
y
(
seld
);
%% Eigen-values for covariance-matrix
[
Veig
,
Deig
]
=
eig
(
cov
(
x
,
y
));
% Veig gives main axes
A
=
bf_rad2deg
(
atan2
(
Veig
(
2
),
Veig
(
1
)));
% angle
end
%% diagonal Deig = variance in the 2 main axes
SD
=
sqrt
(
diag
(
Deig
));
xmu
=
mean
(
x
);
ymu
=
mean
(
y
);
MU
=
[
xmu
ymu
];
%% Initialization
out
=
keyval
(
'outlier'
,
varargin
);
if
isempty
(
out
)
out
=
[];
% (Hz)
end
%% Eigen-values for covariance-matrix
[
Veig
,
Deig
]
=
eig
(
cov
(
x
,
y
));
% Veig gives main axes
A
=
bf_rad2deg
(
atan2
(
Veig
(
2
),
Veig
(
1
)));
% angle
%% Delete response >3SD
if
~
isempty
(
out
)
SD
=
sqrt
(
diag
(
Deig
));
% diagonal Deig = variance in the 2 main axes
xmu
=
mean
(
x
);
ymu
=
mean
(
y
);
[
Xr
,
Yr
]
=
rotate2d
(
x
,
y
,
-
A
);
seld
=
abs
(
Xr
-
mean
(
Xr
))
<
out
*
SD
(
2
)
&
abs
(
Yr
-
mean
(
Yr
))
<
out
*
SD
(
1
);
x
=
x
(
seld
);
y
=
y
(
seld
);
%% Eigen-values for covariance-matrix
[
Veig
,
Deig
]
=
eig
(
cov
(
x
,
y
));
% Veig gives main axes
A
=
bf_rad2deg
(
atan2
(
Veig
(
2
),
Veig
(
1
)));
% angle
end
%% diagonal Deig = variance in the 2 main axes
SD
=
sqrt
(
diag
(
Deig
));
xmu
=
mean
(
x
);
ymu
=
mean
(
y
);
MU
=
[
xmu
ymu
];
end
...
...
utilities/statistics/pb_regplot.m
View file @
dac14a84
function
[
h
,
b
,
r
]
=
pb_regplot
(
X
,
Y
)
function
[
h
,
b
,
r
]
=
pb_regplot
(
X
,
Y
,
varargin
)
% PB_REGPLOT()
%
% plots data, and linear regression.
...
...
@@ -7,39 +7,38 @@ function [h,b,r] = pb_regplot(X,Y)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
%% Initialization
X
=
X
(:)
'
;
Y
=
Y
(:)
'
;
mrkr
=
'o'
;
%% Initialization
%% Regression
b
=
regstats
(
Y
,
X
,
'linear'
,
'beta'
);
b
=
b
.
beta
;
gain
=
b
(
2
);
bias
=
b
(
1
);
r
=
corrcoef
(
X
,
Y
);
r
=
r
(
2
);
v
=
varargin
;
marker
=
pb_keyval
(
'marker'
,
v
,
'o'
);
data
=
pb_keyval
(
'data'
,
v
,
true
);
text
=
pb_keyval
(
'text'
,
v
,
false
);
color
=
pb_keyval
(
'color'
,
v
,
'k'
);
linestyle
=
pb_keyval
(
'linestyle'
,
v
,
'--'
);
linewidth
=
pb_keyval
(
'linewidth'
,
v
,
2
);
X
=
X
(:)
'
;
Y
=
Y
(:)
'
;
hs
=
ishold
(
gca
);
hold
on
;
%% Regression