-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathaddOptickaToPath.m
More file actions
63 lines (54 loc) · 2.19 KB
/
Copy pathaddOptickaToPath.m
File metadata and controls
63 lines (54 loc) · 2.19 KB
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
function addOptickaToPath(addPTB)
% adds opticka to path, ignoring unneeded folders. Also ensures other
% related code folders are present.
% in general we do not want to add PTB paths as this is done by
% SetupPsychToolbox, but for CI tasks it may be necessary to at least have
% PTB functions available even when not "fully" setup.
if ~exist('addPTB','var'); addPTB = false; end
tt = tic;
mpath = path;
mpath = strsplit(mpath, pathsep);
opath = fileparts(mfilename('fullpath'));
%remove any old paths
opathesc = regexptranslate('escape',opath);
oldPath = ~cellfun(@isempty,regexpi(mpath,opathesc));
if any(oldPath)
rmpath(mpath{oldPath});
end
% add new paths
opaths = genpath(opath);
opaths = strsplit(opaths,pathsep);
sep = regexptranslate('escape',filesep);
pathExceptions = ["/.git" "/.github" "/.vscode" ...
"/adio" "/arduino" "photodiode" "/+uix" ...
"/+zmq" "/+uiextras" "/tests" "/images" "/resources" ...
"/media" "/legacy" "/html" "/doc"];
qAdd = contains(opaths,pathExceptions); % true where exceptions match
addpath(opaths{~qAdd});
% Define the parent folder and the string array of optional project folder names
% If they exist in the same folder that opticka is stored, add them to
% path.
parentFolder = fileparts(opath); % Adjust this to your actual parent folder
folderNames = ["Palamedes", "CageLab-Code", "matlab-jzmq", "matmoteGO", "PTBSimia"];
if addPTB; folderNames = [folderNames "Psychtoolbox"]; end
% Loop through each folder name
for i = 1:length(folderNames)
% Construct the full path for each folder
folderPath = fullfile(parentFolder, folderNames(i));
% Check if the folder exists
if isfolder(folderPath)
if strcmp(folderNames(i), "Psychtoolbox")
ptbPaths = strsplit(genpath(folderPath),pathsep);
qAdd = contains(ptbPaths,pathExceptions); % true where exceptions match
addpath(ptbPaths{~qAdd});
fprintf('Additionally added to path with subfolders: %s\n', folderPath);
else
% Add the folder to the MATLAB path
addpath(folderPath);
fprintf('Additionally added to path: %s\n', folderPath);
end
end
end
% Save the changes to the path for future sessions
savepath;
fprintf('--->>> Added opticka to the MATLAB path in %.1f ms...\n',toc(tt)*1000);