-
Notifications
You must be signed in to change notification settings - Fork 2
/
setLocalDataPath.m
54 lines (46 loc) · 1.61 KB
/
setLocalDataPath.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
function localDataPath = setLocalDataPath(varargin)
% function LocalDataPath = setLocalDataPath(varargin)
% Return the path to the root directory and add paths in this repo
%
% input:
% personalDataPath: optional, set to 1 if adding personalDataPath
%
% when adding personalDataPath, the following function should be in the
% root of this repo:
%
% function localDataPath = personalDataPath()
% 'localDataPath = [/my/path/to/data];
%
% function localDataPath = personalDataPath(1)
% % to load path from personalDataPath
%
% personalDataPath is ignored in .gitignore
%
% dhermes, 2020, Multimodal Neuroimaging Lab
if isempty(varargin)
rootPath = which('setLocalDataPath');
RepoPath = fileparts(rootPath);
% add path to functions
addpath(genpath(RepoPath));
% add localDataPath default
localDataPath = fullfile(RepoPath,'data');
elseif ~isempty(varargin)
% add path to data
if varargin{1}==1 && exist('personalDataPath','file')
localDataPath = personalDataPath();
elseif varargin{1}==1 && ~exist('personalDataPath','file')
sprintf(['add personalDataPath function to add your localDataPath:\n'...
'\n'...
'function localDataPath = personalDataPath()\n'...
'localDataPath.input = [/my/path/to/data];\n'...
'localDataPath.output = [/my/path/to/output];\n'...
'\n'...
'this function is ignored in .gitignore'])
return
end
% add path to functions
rootPath = which('setLocalDataPath');
RepoPath = fileparts(rootPath);
addpath(genpath(RepoPath));
end
return