Commit 1424b8fb authored by Jesse Heckman's avatar Jesse Heckman

Update vPRIME Draft

parent 333d9975
a1 = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21];
a2 = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 21];
a3 = [0 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
a4 = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21];
a5 = [0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 9];
a6 = [0 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2];
a7 = [0 0 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9];
a8 = [0 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2];
A = [a1;a2;a3;a4;a5;a6;a7;a8];
%Connects to RZ6 #1 via Optical Gigabit
RP=actxcontrol('RPco.x',[5 5 26 26]);
if RP.ConnectRZ6('GB',1)
e='connected'
else
e='Unable to connect'
end
RP.LoadCOF('U:\##BIOFYSICA\#P075 Moving sound\SetTagV_Matrix_test2.rcx');
RP.Run;
if RP.WriteTagVEX('STM_Data', 0, 'F32', A)
e='WriteTagVEX OK'
else
e='WriteTagVEX error'
end
Matrix = RP.ReadTagVEX('STM_Data',0,22,'F32','F64',8)
......@@ -33,18 +33,18 @@ function draft(obj)
%% Set Compare Axis
% Check and set comparing axis
ax = gobjects(0);
objsz = size(obj);
nCmp = length(unique(obj(1).pva.axcomp.feature));
if min(objsz) > 1; nCmp = 1; end
cmpsz = [1 1];
[~,cmpInd] = max(cmpsz);
cmpsz(cmpInd) = nCmp;
cmpsz = fliplr(cmpsz);
obj(1).h_ax_plot.sz = cmpsz .* size(obj);
% ax = gobjects(0);
% objsz = size(obj);
%
% nCmp = length(unique(obj(1).pva.axcomp.feature));
% if min(objsz) > 1; nCmp = 1; end
%
% cmpsz = [1 1];
% [~,cmpInd] = max(cmpsz);
% cmpsz(cmpInd) = nCmp;
% cmpsz = fliplr(cmpsz);
%
% obj(1).h_ax_plot.sz = cmpsz .* size(obj);
%% Create Plots
% Draft each subplot
......@@ -57,7 +57,7 @@ function draft(obj)
% Make Axes
Ax = pb_invidx(objsz.*cmpsz,cObj); % reverse get axes index
Ax2Obj = pb_invidx(objsz,iObj); % reverse get object index
ax(Ax) = subplot(objsz(1)*cmpsz(1),objsz(2)*cmpsz(2),cObj); % make axis
%ax(Ax) = subplot(objsz(1)*cmpsz(1),objsz(2)*cmpsz(2),cObj); % make axis
if obj(iObj).pva.subtitle; title(obj(Ax2Obj).pva.subtitle); end
axis(obj(Ax2Obj).pva.axis);
......
......@@ -28,7 +28,8 @@ function make_axes(obj,varargin)
%% Build Playground
% Set graphing axes
h = gobjects(ngraph,1);
h = gobjects(ngraph,1);
pos = axis_pos(obj,graphsz,playground);
% h = pb_fobj(gcf,'Tag','legend');
% scale = [h.Position(1) 1];
......@@ -40,10 +41,11 @@ function make_axes(obj,varargin)
%% DONE TILL HERE!!! REST NEEDS FIXING!
% ASSIGN AXES TO POSITION RELATIVE TO PLAYGROUND AND INDEX
pos = [0.1+(iAx/20) 0.3 0.3 0.3];
%pos = [0.1+(iAx/20) 0.3 0.3 0.3];
cAx = pb_invidx(graphsz,iAx); % align axes and objects
h(cAx) = axes('Parent',obj(1).parent,'OuterPosition',pos);
h(cAx) = axes('Parent',obj(1).parent,'Position',pos(iAx,:));
axis square
% Set Grids
......@@ -64,20 +66,54 @@ function make_axes(obj,varargin)
end
% Set labels
if ~obj(1).labels.supx; xlabel(obj(Ax2Obj).labels.xlab); end
if ~obj(1).labels.supy; ylabel(obj(Ax2Obj).labels.ylab); end
% if ~obj(1).labels.supx; xlabel(obj(Ax2Obj).labels.xlab); end
% if ~obj(1).labels.supy; ylabel(obj(Ax2Obj).labels.ylab); end
%% SHOULD I GO FOR THIS? MAYBE THIS COMPLICATES STUFF
% Make scientific notations on the axes.
h(cAx).YAxis.Exponent = length(num2str(max(abs(round(h(cAx).YLim)))))-1;
h(cAx).XAxis.Exponent = length(num2str(max(abs(round(h(cAx).XLim)))))-1;
end
end
diff = abs(obj(1).h_ax_labels.Position(2) - h(end).OuterPosition(2));
%% Checkout
% Store and update primary obj data
obj(1).h_ax_labels.Position(2) = obj(1).h_ax_labels.Position(2)+diff;
obj(1).h_ax_labels.Position(4) = obj(1).h_ax_labels.Position(4)-(2*diff);
obj(1).h_ax_plot.handles = h;
obj(1).h_ax_plot.sz = graphsz;
end
function pos = axis_pos(obj,sz,area)
% Defines the positions of all graphic axes in a given graphic area
% Get sizes
rep = prod(sz);
pos = zeros(rep,4);
asz = obj(1).parent.Position;
obj(1).h_ax_plot.handles = h;
obj(1).h_ax_plot.sz = graphsz;
% Find smallest ratio
ra = (area(3)*asz(3)) / (area(4)*asz(4));
rs = sz(2)/sz(1);
width = area(4)/sz(1); % get y length
if ra/rs < 1; width = area(3)/sz(2); end % change to x length
width = width*.9;
for iAx = 1:rep
% Get idx position
[c,r] = pb_mod(iAx,sz(2));
if c == 0; c = sz(2); end
N = [r+1,c];
% Get normalized position
x = area(1)/2 + (N(2)-1)*width;
y = (sz(1)*width*1.1)/2 + 0.5 - N(1)*width;
pos(iAx,:) = [x y width width];
end
end
......
......@@ -43,7 +43,7 @@ function make_suplabel(obj,varargin)
% Store and update primary obj data
obj(1).h_ax_labels = h;
obj(1).h_ax_plot.playground = h.Position;
obj(1).h_ax_plot.playground = [h.Position(1)*0.8 h.Position(2) h.OuterPosition(3:4)];
end
......
......@@ -4,7 +4,7 @@
pb_clean; % Empty
load('exD_saccade'); % load example data
cfn = 0; % Initialize current figure number
run = 1; % Set # of blocks to run
run = 9; % Set # of blocks to run
%% Block 1:
% Make figure 1: Plot data
......@@ -20,7 +20,7 @@ run = 1; % Set # of blocks to run
% d.plot_hline('type','mode');
%
% % Layout
% d.set_axcomp(Saccades.Subject);
% %d.set_axcomp(Saccades.Subject);
% d.set_title('Saccade Latencies');
% d.set_labels('x','Gaze Latency (ms)','y','Head Latency (ms)');
% d.set_grid;
......
%% Initialize
% Prepare example_draft: clean and initialize.
pb_clean; % Empty
load('exD_saccade'); % load example data
cfn = 0; % Initialize current figure number
%% Block 1:
% Make figure 1: Plot data
% Build draft-objs
d(1) = pb_draft('x',Saccades.GazeLatency,'y',Saccades.HeadLatency,'color',Saccades.Modality);
d(2) = pb_draft('x',Saccades.GazeLatency,'y',Saccades.HeadLatency,'color',Saccades.Modality);
d(3) = pb_draft('x',Saccades.GazeLatency,'y',Saccades.HeadLatency,'color',Saccades.Modality);
% Figure Layout
d.set_title('Saccade Latencies');
d.set_grid;
d.set_legend('Entries',{'Audio','Visual','Audiovisual'});
% Build
d.draft;
function h = pb_figure(n,varargin)
% PB_FIGURE()
%
% PB_FIGURE() ...
%
% See also ...
% PBToolbox (2019): JJH: j.heckman@donders.ru.nl
if nargin == 0
g = groot;
n = 1;
if ~isempty(g.Children); n = g.Children(end).Number+1; end
end
MP = get(0, 'MonitorPositions');
FigH = figure(n);
if size(MP, 1) == 1 % Single monitor
set(figH,varargin{:})
else % Multiple monitors
% Catch creation of figure with disabled visibility:
indexVisible = find(strncmpi(varargin(1:2:end), 'Vis', 3));
if ~isempty(indexVisible)
paramVisible = varargin(indexVisible(end) + 1);
else
paramVisible = get(0, 'DefaultFigureVisible');
end
%
Shift = MP(1, 1:2);
set(FigH,varargin{:}, 'Visible', 'off');
set(FigH, 'Units', 'pixels');
pos = get(FigH, 'Position');
set(FigH, 'Position', [pos(1:2) + Shift, pos(3:4)],'Visible', paramVisible);
end
if nargout ~= 0; h = FigH; end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2019) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment