Commit 21a29415 authored by Jesse Heckman's avatar Jesse Heckman
Browse files

update vEndExp

parent 49065ccf
function pb_vEndExp(cfg)
function pb_vEndExp
% PB_VENDEXP()
%
% PB_VENDEXP() ...
......
......@@ -108,7 +108,7 @@ function pb_vRunExp(handles)
% finalizes experiment, and resets handles.
% check out experiment
pb_vEndExp(handles.cfg);
pb_vEndExp;
pb_vStoreBlockDat(handles.cfg, Dat);
pb_vInitialize(handles, false);
toc(experimentTime)
......
......@@ -7,22 +7,28 @@ function pb_makelocal(varargin)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
user = pb_keyval('user',varargin,'JJH');
local = pb_keyval('destination',varargin,[pb_datapath filesep user]);
srv = pb_keyval('server',varargin,'mbaudit5');
srv = ['~/sharename/'];
user = pb_keyval('user',varargin,'JJH');
local = pb_keyval('destination',varargin,[pb_datapath filesep user]);
srv = pb_keyval('server',varargin,'mbaudit5');
d = dir(['~/sharename/']);
srv = d.folder;
if ~exist(srv,'dir')
disp('Server cannot be found. Please first mount server (pb_mountserver).');
return
end
cdir = pb_getdir('dir',srv,'title','Select Data..');
dest = [local filesep cdir(find(cdir==filesep, 1,'last')+1:end)];
cdir = pb_getdir('dir',srv,'title','Select Data..');
% Prevent copy of entire DATA dir
globaldir = strrep(cdir,[srv filesep],'');
wmsg = [newline 'Prohibited action: DATA dir cannot be made local.' newline];
if strcmp(globaldir,'DATA'); disp(wmsg); return; end
% Prevent overwrite in local dir
dest = [local filesep cdir(find(cdir==filesep, 1,'last')+1:end)];
if exist(dest); dest = [dest ' (1)']; end
cnt = 0;
while exist(dest)
cnt = cnt+1;
......
function pb_mountserver(varargin)
function [sn] = pb_mountserver(varargin)
% PB_MOUNTSERVER(varargin)
%
% PB_MOUNTSERVER(varargin) mounts server for pulling or storing data. TO
......@@ -9,11 +9,14 @@ function pb_mountserver(varargin)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
srv = pb_keyval('server',varargin,'mbaudit5');
prfx = '';
cin = ['mount -t smbfs //' getcredentials(srv) '@' srv '-srv.science.ru.nl/' srv '/ ~/sharename/'];
[s,cout] = system(cin);
if s > 0 && s ~= 64; disp(cout); end
if s == 64; system('umount ~/sharename/'); end
if s == 64; system('umount ~/sharename/'); prfx = 'un'; end
disp([newline srv ' is ' prfx 'mounted.' newline])
end
function auth = getcredentials(srv)
......
function cout = pb_open(folder, varargin)
% PB_OPEN()
%
% PB_OPEN() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
if nargin == 0
folder = '~/sharename';
end
if exist(folder,'dir')
system(['open ' folder])
end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function pb_shadedline(D,varargin)
% PB_SHADEDLINE()
% PB_SHADEDLINE(D, varargin)
%
% PB_SHADEDLINE() ...
% PB_SHADEDLINE(D, varargin) allows you to plot shaded lines. Both line and
% shade types can be inidicated in keyvals.
%
% See also ...
% See also PB_KEYVAL, PLOT
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
fig = pb_keyval('fig',varargin,gcf);
ax = pb_keyval('axis',varargin,gca);
col = pb_keyval('col',varargin);
alpha = pb_keyval('alpha',varargin,.3);
smooth = pb_keyval('smooth',varargin,1);
%% INITIALIZE
% initialize (default) parameters, and set figure handles
% Set vars
fig = pb_keyval('fig',varargin,gcf);
ax = pb_keyval('axis',varargin,gca);
col = pb_keyval('col',varargin,'r');
def = pb_keyval('def',varargin,2);
alpha = pb_keyval('alpha',varargin,.3);
line = pb_keyval('line',varargin,'mean');
shade = pb_keyval('shade',varargin,'std');
% Set figure handles
figure(fig);
axes(ax);
hs = ~ishold;
hold on;
F = 1 : size(D,2);
% Define Colors
Dsz = size(D);
if isempty(col)
col = pb_selectcolor(Dsz(2),'def',def); % YOU CAN ONLY PLOT 1 LINE AT THE TIME (= 1 COLOR)
end
%% PROCESS DATA
% Define line and shadetype, and prepare data
% Set linetype
switch line
case 'mean'
LineDat = nanmean(D)';
case 'fit'
LineDat = [];
otherwise
LineDat = nanmean(D)'; % case 'mean'
end
% Set shadetype
switch shade
case 'std'
ShadeDat = nanstd(D);
case 'sem'
ShadeDat = nanstd(D)/sqrt(Dsz(1));
case 'range'
ShadeDat = max(D);
otherwise
ShadeDat = nanstd(D); % case 'std'
end
F = 1 : Dsz(2);
if ne(size(F,1),1)
F=F';
end
fill([F fliplr(F)],[LineDat+ShadeDat fliplr(LineDat-ShadeDat)],col);
amean=smooth(nanmean(D),smth)';
astd=nanstd(D); % to get std shading
% astd=nanstd(amatrix)/sqrt(size(amatrix,1)); % to get sem shading
if exist('alpha','var')==0 || isempty(alpha)
fill([F fliplr(F)],[amean+astd fliplr(amean-astd)],acolor,'linestyle','none');
acolor='k';
else
fill([F fliplr(F)],[amean+astd fliplr(amean-astd)],acolor, 'FaceAlpha', alpha,'linestyle','none');
end
plot(F,amean,acolor,'linewidth',1.5); %% change color or linewidth to adjust mean line
plot(F,LineDat,col,'linewidth',1.5); % change color or linewidth to adjust mean line
if hs; hold off; end
end
......
function pb_tplot(target,varargin)
% PB_TPLOT()
%
% PB_TPLOT() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
if nargin == 0; return; end
ax = pb_keyval('axis', varargin, gca);
col = pb_keyval('color', varargin, 'r');
axes(ax);
targetsz = size(target,1);
for tIdx = 1:targetsz
y = target(tIdx,1);
y = [y y];
t1 = target(tIdx,2);
dur = target(tIdx,3);
t2 = t1+dur;
t = [t1 t2];
plot(t,y,'color',col,'tag','target plot','HandleVisibility','off')
end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function signal = pb_tukeywin(signal, varargin)
% PB_TUKEYWIN()
%
% PB_TUKEYWIN() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
% Keyval pairs
vel = pb_keyval('velocity',varargin,0.33);
% Orient signal
signalsz = size(signal);
if signalsz(2)>signalsz(1)
signal = signal';
end
tk = tukeywin(max(signalsz),vel);
signal = signal .* tk;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
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