Commit 58ca2365 authored by Jesse Heckman's avatar Jesse Heckman

update vPrime + draft

parent 37ec3c7d
......@@ -24,7 +24,7 @@ function pb_vSetSound(snd,cfg,RZ6str)
cfg.RZ6_1.SetTagVal('eventSND',snd.onevent+1);
cfg.RZ6_1.SetTagVal('delaySND',snd.ondelay);
cfg.RZ6_1.SetTagVal('soundDur',snd.duration); %
cfg.RZ6_1.SetTagVal('soundDur',snd.duration);
cfg.RZ6_1.SetTagVal('AttenuationA',atten); % Note: sounds are set for 2 channels, but only 1 sound is played (see MUX below)
cfg.RZ6_1.SetTagVal('AttenuationB',atten);
......
......@@ -52,7 +52,6 @@ function [stim, cfg] = pb_vSetupTrial(stim,cfg)
end
end
end
stim(find(selled,1)).ledhandle = ledcontroller_pi('dcn-led06','dcn-led07');
stim(find(selled,1)).ledhandle.write(s);
end
......@@ -71,8 +70,12 @@ function [stim, cfg] = pb_vSetupTrial(stim,cfg)
%% WAIT
ev = stim.offevent;
de = stim.offdelay;
ev = 0;
de = 2500;
if isfield(stim,'offevent'); ev = stim.offevent; end
if isfield(stim,'offdelay'); de = stim.offdelay; end
mxevent = max(ev);
sel = ismember(ev,mxevent);
mxdelay = max([de(sel) ceil(1000*cfg.nsamples./cfg.RZ6Fs) ]);
......
......@@ -67,6 +67,7 @@ function [block,cfg] = pb_vReadExp(cfg)
block(bn).trial(tn).stim(sn).ondelay = par(6);
block(bn).trial(tn).stim(sn).offdelay = par(5)+par(7);
block(bn).trial(tn).stim(sn).duration = par(7);
block(bn).trial(tn).stim(sn).offevent = par(5);
case {'LED','LED1','LED2'}
% Updates count and writes stimulus
......
......@@ -98,13 +98,9 @@ function draft(obj)
%% Adjust Axis Handles
% Set super labels
% TO DO:
% 1. Scale and move axis to make graph nice, pleasing and non-overlapping
obj.make_axes(ax);
obj.make_legend;
obj.make_axes(ax);
obj.make_suplabel;
end
......
......@@ -9,44 +9,43 @@ function make_axes(obj,ax,varargin)
linkaxes(ax,'xy');
positions = zeros(length(ax),4);
nAx = length(ax);
% Get legend data
h = pb_fobj(gcf,'Tag','legend');
scale = [h.Position(1) 1];
sz = obj(1).h_ax_plot.sz;
szfl = fliplr(sz);
opObj = ax(1).OuterPosition(3:4)*scale(1);
nAx = length(ax);
for iAx = 1:nAx
sz = obj(1).h_ax_plot.sz;
cAx = pb_invidx(sz,iAx); % align axes and objects
ax(cAx);
% Scale for legend
if obj(1).h_ax_legend.bool
scale = [0.8 1];
szfl = fliplr(sz);
[xN,yN] = pb_mod(iAx,sz(2)); if xN == 0; xN = sz(2); end
N = [xN,yN+1];
ax(cAx).OuterPosition(3:4) = ax(cAx).OuterPosition(3:4)*scale(1);
spacing = [];
for iDir = 1:2
width = ax(cAx).OuterPosition(2+iDir);
width = ax(cAx).OuterPosition(2+iDir);
spacing(iDir) = (scale(iDir)-(width*szfl(iDir)))/(szfl(iDir)+1);
if iDir == 1; ax(cAx).OuterPosition(1) = (N(1)-1)*width + N(1)*spacing(iDir); end
if iDir == 2
if spacing(2)>spacing(1)*1.5
spacing(2) = spacing(1)*1.5;
end
margin = (1-(sz(1)*width + (sz(1)-1)*spacing(2)))/2;
margin = (1-(sz(1)*width + (sz(1)-1)*spacing(2)))/2*1.1;
ax(cAx).OuterPosition(2) = 1-margin-(N(2)*width) - (N(2)-1)*spacing(iDir);
end
end
ax(cAx).OuterPosition(3:4) = opObj;
end
% Set Limits
if obj(1).pva.setAxes
xlim(obj(1).pva.limits.x);
ylim(obj(1).pva.limits.y);
xlim(ax(cAx),obj(1).pva.limits.x);
ylim(ax(cAx),obj(1).pva.limits.y);
end
% Set Grids
......@@ -71,6 +70,9 @@ function make_axes(obj,ax,varargin)
% Set Label Positions
% TODO: THIS MUST BE DONE WAY BETTER!!
% NOTE THAT AXES ARE NOT SAME SIZE? (SEE MOST RIGHT FIGURES), ALSO
% POSITION IS NOT ALIGNED!
obj(1).labels.ypos = min(positions(:,2));
obj(1).labels.xpos = min(positions(:,1));
obj(1).labels.pos = [min(positions(:,1))/1.33 min(positions(:,2))/1.33 max(positions(:,1)+positions(:,3)) max(positions(:,2)+positions(:,4))];
......
......@@ -9,37 +9,24 @@ function make_legend(obj,varargin)
lgnd = obj(1).h_ax_legend;
if lgnd.bool
h = axes('Units','Normal','Position',[.8 .3 .15 .4],'Visible','off','tag','legend');
h = axes('Units','Normal','Position',[.85 .3 .15 .4],'tag','legend','Visible','off');
hold on;
t = text(0,0.5,'LEGEND1','Visible','on');
p = plot(0,0.5,'o','Visible','on');
xlim = [0 1];
ylim = [0 1];
%[n,m] = readlegend(lgnd.features.entries,lgnd.features.fontsize);
end
end
function [n,m] = readlegend(entries,fontsize)
% returns the size of the legend
if isempty(entries)
n = 0; m = 0;
return
ncol = length(unique(obj(1).pva.color));
col = pb_selectcolor(ncol,obj(1).pva.def);
move = 0;
for iCol = 1:ncol
pos = 0.575 - (iCol-1)*.075;
t(iCol) = text(0.1,pos,lgnd.features.entries{iCol},'Visible','on','FontSize',lgnd.features.fontsize);
p(iCol) = plot(0,pos,'Marker','o','Visible','on','Color',col(iCol,:),'MarkerFaceColor',col(iCol,:));
xlim([0 1]);
ylim([0 1]);
if move<t(iCol).Extent(3); move = t(iCol).Extent(3); end
end
move = (.95-move)*0.15;
h.Position(1) = h.Position(1)+move;
end
n = length(entries);
n = (n+1)*0.04;
z = axes();
set(z,units,'centimeters');
end
......
......@@ -4,31 +4,33 @@
pb_clean; % Empty
load('exD_saccade'); % load example data
cfn = 0; % Initialize current figure number
run = 1; % Set # of blocks to run
run = 2; % Set # of blocks to run
%% Block 1:
% Make figure 1: Plot data
% if run>cfn
% % Make figure & draft-obj
% cfn = pb_newfig(cfn,'size',[0 0 17 17],'resize','off');
% d = pb_draft('x',Saccades.GazeLatency,'y',Saccades.HeadLatency,'color',Saccades.Modality);
%
% % Plots
% d.plot_rawdata
% d.plot_vline('type','mode');
% d.plot_hline('type','mode');
%
% % Layout
% d.set_title('Saccade Latencies');
% d.set_labels('x','Gaze Latency (ms)','y','Head Latency (ms)');
% d.set_grid;
% d.set_legend('Entries',{'Audio','Visual','Audiovisual'});
%
% % Build
% d.draft
% %d.print('disp',true);
% end
if run>cfn
% Make figure & draft-obj
cfn = pb_newfig(cfn,'size',[0 0 17 17],'resize','off');
d = pb_draft('x',Saccades.GazeLatency,'y',Saccades.HeadLatency,'color',Saccades.Modality);
% Plots
d.plot_rawdata
d.plot_vline('type','mode');
d.plot_hline('type','mode');
% Layout
d.set_axcomp(Saccades.Subject);
d.set_title('Saccade Latencies');
d.set_labels('x','Gaze Latency (ms)','y','Head Latency (ms)');
d.set_grid;
d.set_legend('Entries',{'Audio','Visual','Audiovisual'});
% Build
d.draft
d.print('disp',true);
end
%% Block 2:
......@@ -37,7 +39,7 @@ run = 1; % Set # of blocks to run
if run>cfn
tic
% Make figure
cfn = pb_newfig(cfn,'size',[0 0 17 12],'resize','off');
cfn = pb_newfig(cfn,'size',[0 0 17 11],'resize','off');
for iR = 1:2
% Build draft-objs
d(iR,1) = pb_draft('x',Saccades.GazeLatency,'y',Saccades.HeadLatency,'color',Saccades.Modality);
......
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