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
|
function [bart_path, isWSL] = get_bart_path()
% BART get BART for Matlab.
% [bart_path, isWSL] = get_bart_path() will return the bart path as seen by Matlab,
% and optionally will return whether WSL was detected.
%
% Authors:
% 2022 Jon Tamir <jtamir.utexas.edu>
% Check bart toolbox path
bart_path = getenv('BART_TOOLBOX_PATH');
isWSL = false;
if isempty(bart_path)
if ~isempty(getenv('TOOLBOX_PATH'))
bart_path = getenv('TOOLBOX_PATH');
elseif exist('/usr/local/bin/bart', 'file')
bart_path = '/usr/local/bin';
elseif exist('/usr/bin/bart', 'file')
bart_path = '/usr/bin';
else
% Try to execute bart inside wsl, if it works, then it returns status 0
[bartstatus, ~] = system('wsl bart version -V');
if bartstatus==0
[~, bart_path] = system('wsl dirname $(which bart)');
bart_path = strip(bart_path);
isWSL = true;
end
end
end
end
|