-
Notifications
You must be signed in to change notification settings - Fork 11
/
loadPLDAPS_template.m
98 lines (79 loc) · 2.74 KB
/
loadPLDAPS_template.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
function loadPLDAPS()
%loadPLDAPS load the pldaps folders from into the matlab path
% Set unified location for Matlab toolboxes
toolRoot = fullfile('~','MLtoolbox');
%% Setup the path
% remove other/conflicting copies from path
scrubPath({'PLDAPS','VPixx','Psychtoolbox'});
% PLDAPS stuff (with additional excludes)
addToPathWithoutGit( fullfile(toolRoot, 'Psychtoolbox')); %, {'Octave','R2007a','EyelinkDemos'});
addToPathWithoutGit( fullfile(toolRoot, 'PLDAPS'), '/PLDAPS/doc');
% Place OS-dependent copy of datapixx.mex AHEAD of PTB version (shadowing it)
if ismac
osStr = 'macosx64';
elseif isunix
osStr = 'linux64';
else
osStr = 'win64';
end
vpixxTrunk = fullfile(toolRoot,'VPixx_Software_Tools','DatapixxToolbox_trunk');
addToPathWithoutGit( fullfile(vpixxTrunk, 'mexdev','build','matlab',osStr) );
% cd(toolRoot);
end %main function
% % % % % %
% % % % % %
%% Sub-function dependencies
% ** These are normal parts of PLDAPS **
% Sub-function copies are needed here so they can be used while setting up the path
% % % % % %
% % % % % %
%% scrubPath.m
function scrubPath(excludes)
a=path;
b=textscan(a,'%s','delimiter',':');
b=b{1};
keepers = true(size(b));
if ischar(excludes), excludes = {excludes}; end
for i = 1:numel(excludes)
keepers = keepers & cellfun(@isempty,strfind(b, excludes{i}));
end
b = setdiff(b, b(keepers));
if numel(b)>0
rmpath( b{:} )
end
fprintf('Removing path directories containing keywords:\n\t[%s\b]\n', sprintf('''%s''\t',excludes{:}));
end
%% addToPathWithoutGit.m
function addToPathWithoutGit(dir, excludes, withSubdirs)
% function addToPathWithoutGit(dir, excludes, withSubdirs)
%
% Add [dir] to Matlab path without including all the hidden versioning junk (.git, .svn)
% -- Optionally also exclude subdirs matching any entries in [excludes] string (or cell of strings)
% -- by default includes all subdirectories, set [withSubdirs] to false to only add the main [dir]
%
if nargin<3 || withSubdirs
a = genpath(dir);
withSubdirs = ' and subdirectories';
else
a = dir;
withSubdirs = [];
end
if isempty(a)
fprintf('%s not found...attempting to continue\n', dir);
else
b=textscan(a,'%s','delimiter',':');
b=b{1};
b(~cellfun(@isempty,strfind(b,'.git')))=[];
b(~cellfun(@isempty,strfind(b,'.svn')))=[];
if nargin>1
if ~iscell(excludes), excludes = {excludes}; end
for i = 1:numel(excludes)
if ~isempty(excludes{i})
b(~cellfun(@isempty,strfind(b, excludes{i})))=[];
end
end
end
addpath(b{:})
disp([dir, withSubdirs, ' added to the path']);
end
end