1- function addRigboxPaths(savePaths )
1+ function addRigboxPaths(varargin )
22% ADDRIGBOXPATHS Adds the required paths for using Rigbox
3+ % addRigboxPaths([savePaths, interactive, strict]) or
4+ % addRigboxPaths('SavePaths', true, 'Interactive', true, 'Strict', true)
35%
4- % Part of the Rigging toolbox
6+ % Inputs (Optional):
7+ % savePaths (logical): If true, added paths are saved between sessions
8+ % interactive (logical): If true, user may be prompted for input
9+ % strict (logical): Assert toolbox & system requirments are all met
10+ %
11+ % Part of the Rigging toolbox
512%
613% 2014-01 CB
714% 2017-02 MW Updated to work with 2016b
815
9- % Flag for perminantly saving paths
10- if nargin < 1 ; savePaths = true ; end
16+ % %% Input validation %%%
17+ % Allow positional or Name-Value pairs
18+ p = inputParser ;
19+ p .addOptional(' savePaths' , true )
20+ p .addOptional(' interactive' , true )
21+ p .addOptional(' strict' , true )
22+ p .parse(varargin{: });
23+ p = p .Results ;
1124
1225% %% MATLAB version and toolbox validation %%%
13- % MATLAB must be running on Windows
14- assert(ispc , ' Rigbox currently only works on Windows 7 or later' )
15-
16- % Microsoft Visual C++ Redistributable for Visual Studio 2015 must be
17- % installed, check for runtime dll file in system32 folder
18- sys32 = dir(' C:\Windows\System32' );
19- assert(any(strcmpi(' VCRuntime140.dll' ,{sys32 .name })), ' Rigbox:setup:libraryRequired' ,...
20- [' Requires Microsoft Visual C++ Redistributable for Visual Studio 2015. ' ,...
21- ' Click <a href="matlab:web(''%s'' ,'' -browser'' )">here</a> to install.' ],...
22- ' https://www.microsoft.com/en-us/download/details.aspx?id=48145' )
23-
24- % Check MATLAB 2017b is running
25- assert(~verLessThan(' matlab' , ' 9.3' ), ' Requires MATLAB 2017b or later' )
26-
27- % Check essential toolboxes are installed (common to both master and
28- % stimulus computers)
29- toolboxes = ver ;
30- requiredMissing = setdiff(...
31- {' Data Acquisition Toolbox' , ...
32- ' Signal Processing Toolbox' , ...
33- ' Instrument Control Toolbox' , ...
34- ' Statistics and Machine Learning Toolbox' },...
35- {toolboxes .Name });
36-
37- assert(isempty(requiredMissing ),' Rigbox:setup:toolboxRequired' ,...
38- ' Please install the following toolboxes before proceeding: \n%s ' ,...
39- strjoin(requiredMissing , ' \n ' ))
40-
41- % Check that GUI Layout Toolbox is installed (required for the master
42- % computer only)
43- isInstalled = strcmp(' GUI Layout Toolbox' , {toolboxes .Name });
44- if ~any(isInstalled ) || ...
45- str2double(strrep(toolboxes(isInstalled ).Version,' .' , ' ' )) < 230
46- warning(' Rigbox:setup:toolboxRequired' ,...
47- [' MC requires GUI Layout Toolbox v2.3 or higher to be installed. ' ...
26+ if p .strict
27+ % MATLAB must be running on Windows
28+ assert(ispc , ' Rigbox currently only works on Windows 7 or later' )
29+
30+ % Microsoft Visual C++ Redistributable for Visual Studio 2015 must be
31+ % installed, check for runtime dll file in system32 folder
32+ sys32 = dir(' C:\Windows\System32' );
33+ assert(any(strcmpi(' VCRuntime140.dll' ,{sys32 .name })), ' Rigbox:setup:libraryRequired' ,...
34+ [' Requires Microsoft Visual C++ Redistributable for Visual Studio 2015. ' ,...
4835 ' Click <a href="matlab:web(''%s'' ,'' -browser'' )">here</a> to install.' ],...
49- ' https://uk.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox' )
50- end
51-
52- % Check that the Psychophisics Toolbox is installed (required for the
53- % stimulus computer only)
54- isInstalled = strcmp(' Psychtoolbox' , {toolboxes .Name });
55- if ~any(isInstalled ) || str2double(toolboxes(isInstalled ).Version(1 )) < 3
56- warning(' Rigbox:setup:toolboxRequired' ,...
57- [' The stimulus computer requires Psychtoolbox v3.0 or higher to be installed. ' ...
58- ' Click <a href="matlab:web(''%s'' ,'' -browser'' )">here</a> to install.' ],...
59- ' https://github.com/Psychtoolbox-3/Psychtoolbox-3/releases' )
60- end
61-
62- % Check that the NI DAQ support package is installed (required for the
63- % stimulus computer only)
64- info = matlabshared .supportpkg .getInstalled ;
65- if isempty(info ) || ~any(contains({info .Name }, ' NI-DAQmx' ))
66- warning(' Rigbox:setup:toolboxRequired' ,...
67- [' The stimulus computer requires the National Instruments support package to be installed. ' ...
68- ' Click <a href="matlab:web(''%s'' ,'' -browser'' )">here</a> to install.' ],...
69- ' https://www.mathworks.com/hardware-support/nidaqmx.html' )
36+ ' https://www.microsoft.com/en-us/download/details.aspx?id=48145' )
37+
38+ % Check MATLAB 2017b is running
39+ assert(~verLessThan(' matlab' , ' 9.3' ), ' Requires MATLAB 2017b or later' )
40+
41+ % Check essential toolboxes are installed (common to both master and
42+ % stimulus computers)
43+ toolboxes = ver ;
44+ requiredMissing = setdiff(...
45+ {' Data Acquisition Toolbox' , ...
46+ ' Signal Processing Toolbox' , ...
47+ ' Instrument Control Toolbox' , ...
48+ ' Statistics and Machine Learning Toolbox' },...
49+ {toolboxes .Name });
50+
51+ assert(isempty(requiredMissing ),' Rigbox:setup:toolboxRequired' ,...
52+ ' Please install the following toolboxes before proceeding: \n%s ' ,...
53+ strjoin(requiredMissing , ' \n ' ))
54+
55+ % Check that GUI Layout Toolbox is installed (required for the master
56+ % computer only)
57+ isInstalled = strcmp(' GUI Layout Toolbox' , {toolboxes .Name });
58+ if ~any(isInstalled ) || ...
59+ str2double(strrep(toolboxes(isInstalled ).Version,' .' , ' ' )) < 230
60+ warning(' Rigbox:setup:toolboxRequired' ,...
61+ [' MC requires GUI Layout Toolbox v2.3 or higher to be installed. ' ...
62+ ' Click <a href="matlab:web(''%s'' ,'' -browser'' )">here</a> to install.' ],...
63+ ' https://uk.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox' )
64+ end
65+
66+ % Check that the Psychophisics Toolbox is installed (required for the
67+ % stimulus computer only)
68+ isInstalled = strcmp(' Psychtoolbox' , {toolboxes .Name });
69+ if ~any(isInstalled ) || str2double(toolboxes(isInstalled ).Version(1 )) < 3
70+ warning(' Rigbox:setup:toolboxRequired' ,...
71+ [' The stimulus computer requires Psychtoolbox v3.0 or higher to be installed. ' ...
72+ ' Click <a href="matlab:web(''%s'' ,'' -browser'' )">here</a> to install.' ],...
73+ ' https://github.com/Psychtoolbox-3/Psychtoolbox-3/releases' )
74+ end
75+
76+ % Check that the NI DAQ support package is installed (required for the
77+ % stimulus computer only)
78+ info = matlabshared .supportpkg .getInstalled ;
79+ if isempty(info ) || ~any(contains({info .Name }, ' NI-DAQmx' ))
80+ warning(' Rigbox:setup:toolboxRequired' ,...
81+ [' The stimulus computer requires the National Instruments support package to be installed. ' ...
82+ ' Click <a href="matlab:web(''%s'' ,'' -browser'' )">here</a> to install.' ],...
83+ ' https://www.mathworks.com/hardware-support/nidaqmx.html' )
84+ end
7085end
7186
7287% %% Paths for adding
@@ -133,7 +148,7 @@ function addRigboxPaths(savePaths)
133148end
134149
135150% %% Validate that paths saved correctly %%%
136- if savePaths
151+ if p . savePaths
137152 assert(savepath == 0 , ' Failed to save changes to MATLAB path' );
138153 if ~cbtoolsInJavaPath
139154 fseek(fid , 0 , ' eof' );
@@ -152,11 +167,13 @@ function addRigboxPaths(savePaths)
152167fileExists = any(strcmp(' msvcr120.dll' ,{sys32 .name }));
153168copied = false ;
154169if isWindowsAdmin % If user has admin privileges, attempt to copy dll file
155- if fileExists % If there's already a dll file there prompt use to make backup
170+ if fileExists && p . interactive % If there's already a dll file there prompt use to make backup
156171 prompt = sprintf([' For signals to work propery, it is nessisary to copy ' ,...
157- ' the file \n <strong>' , strrep(fileName , ' \' , ' \\ ' ), ' </strong> to ' ,...
158- ' <strong>C:\\ Windows\\ System32</strong>.\n ' ,...
172+ ' the file \n <strong>' , strrep(fileName , ' \' , ' \\\\ ' ), ' </strong> to ' ,...
173+ ' <strong>C:\\\\ Windows\\ \\ System32</strong>.\n ' ,...
159174 ' You may want to make a backup of your existing dll file before continuing.\n\n ' ,...
175+ ' Alternatively this file is installed with ' ,...
176+ ' Visual C++ Redistributable Packages for Visual Studio 2013\n\n ' ,...
160177 ' Do you want to proceed? Y/N [Y]: ' ]);
161178 str = input(prompt ,' s' ); if isempty(str ); str = ' y' ; end
162179 if strcmpi(str , ' n' ); return ; end % Return without copying
0 commit comments