Skip to content

Commit

Permalink
ENH - added empty directory to detect incorrect path setup, give warn…
Browse files Browse the repository at this point in the history
…ing in ft_defaults
  • Loading branch information
robertoostenveld committed Jul 6, 2018
1 parent 88a049a commit 1716c92
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compat/incorrect/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This is a directory that should never be added to your MATLAB path.
It only serves to check whether your path is setup incorrectly.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path
12 changes: 12 additions & 0 deletions compat/matlablt2010b/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This directory contains some functions that allow FieldTrip to run
on older MATLAB versions. These functions emulate the functionality
that is present in the latest MATLAB version.

Each of these directories is called matlabltXXXXX, where "lt" stands
for "less than" and XXXXX is the MATLAB release. If you are using
MATLAB release N, then you should only add the directories N+1,
N+2, ... to your path. In general this will be done automatically
by the ft_defaults function.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path

11 changes: 11 additions & 0 deletions compat/matlablt2011b/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This directory contains some functions that allow FieldTrip to run
on older MATLAB versions. These functions emulate the functionality
that is present in the latest MATLAB version.

Each of these directories is called matlabltXXXXX, where "lt" stands
for "less than" and XXXXX is the MATLAB release. If you are using
MATLAB release N, then you should only add the directories N+1,
N+2, ... to your path. In general this will be done automatically
by the ft_defaults function.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path
11 changes: 11 additions & 0 deletions compat/matlablt2012a/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This directory contains some functions that allow FieldTrip to run
on older MATLAB versions. These functions emulate the functionality
that is present in the latest MATLAB version.

Each of these directories is called matlabltXXXXX, where "lt" stands
for "less than" and XXXXX is the MATLAB release. If you are using
MATLAB release N, then you should only add the directories N+1,
N+2, ... to your path. In general this will be done automatically
by the ft_defaults function.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path
11 changes: 11 additions & 0 deletions compat/matlablt2013b/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This directory contains some functions that allow FieldTrip to run
on older MATLAB versions. These functions emulate the functionality
that is present in the latest MATLAB version.

Each of these directories is called matlabltXXXXX, where "lt" stands
for "less than" and XXXXX is the MATLAB release. If you are using
MATLAB release N, then you should only add the directories N+1,
N+2, ... to your path. In general this will be done automatically
by the ft_defaults function.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path
11 changes: 11 additions & 0 deletions compat/matlablt2014b/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This directory contains some functions that allow FieldTrip to run
on older MATLAB versions. These functions emulate the functionality
that is present in the latest MATLAB version.

Each of these directories is called matlabltXXXXX, where "lt" stands
for "less than" and XXXXX is the MATLAB release. If you are using
MATLAB release N, then you should only add the directories N+1,
N+2, ... to your path. In general this will be done automatically
by the ft_defaults function.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path
11 changes: 11 additions & 0 deletions compat/matlablt2015a/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This directory contains some functions that allow FieldTrip to run
on older MATLAB versions. These functions emulate the functionality
that is present in the latest MATLAB version.

Each of these directories is called matlabltXXXXX, where "lt" stands
for "less than" and XXXXX is the MATLAB release. If you are using
MATLAB release N, then you should only add the directories N+1,
N+2, ... to your path. In general this will be done automatically
by the ft_defaults function.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path
11 changes: 11 additions & 0 deletions compat/matlablt2016b/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This directory contains some functions that allow FieldTrip to run
on older MATLAB versions. These functions emulate the functionality
that is present in the latest MATLAB version.

Each of these directories is called matlabltXXXXX, where "lt" stands
for "less than" and XXXXX is the MATLAB release. If you are using
MATLAB release N, then you should only add the directories N+1,
N+2, ... to your path. In general this will be done automatically
by the ft_defaults function.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path
11 changes: 11 additions & 0 deletions compat/matlablt2017b/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This directory contains some functions that allow FieldTrip to run
on older MATLAB versions. These functions emulate the functionality
that is present in the latest MATLAB version.

Each of these directories is called matlabltXXXXX, where "lt" stands
for "less than" and XXXXX is the MATLAB release. If you are using
MATLAB release N, then you should only add the directories N+1,
N+2, ... to your path. In general this will be done automatically
by the ft_defaults function.

See also http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path
20 changes: 20 additions & 0 deletions ft_defaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
if ~isfield(ft_default.toolbox, 'stats') , ft_default.toolbox.stats = 'compat'; end % matlab or compat
if ~isfield(ft_default.toolbox, 'signal'), ft_default.toolbox.signal = 'compat'; end % matlab or compat

% Some people mess up their path settings and then have
% stuff on the path that should not be there.
% The following will issue a warning
checkIncorrectPath();

% Check whether this ft_defaults function has already been executed. Note that we
% should not use ft_default itself directly, because the user might have set stuff
% in that struct already prior to ft_defaults being called for the first time.
Expand Down Expand Up @@ -316,3 +321,18 @@ function checkMultipleToolbox(toolbox, keyfile)
end
end % function checkMultipleToolbox

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUBFUNCTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function checkIncorrectPath

persistent v p
if isempty(v) || isempty(p)
[v, p] = ft_version;
end

incorrect = fullfile(p, 'compat', 'incorrect');
if contains(path, incorrect)
ft_warning('Your path is set up incorrectly.\nYou probably used addpath(genpath(''path_to_fieldtrip'')).\nThis can lead to unexpected behaviour.\nSee http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path');
end
end % function checkPath

0 comments on commit 1716c92

Please sign in to comment.