Commit 4314a6b3 authored by Jan-Gerrit Richter's avatar Jan-Gerrit Richter

removed sofa from toolbox

added ita_sofa_install this needs to be called
the function will download the latest sofa, add it to the path and call sofastart
parent 0fdbc751
function Obj = SOFAaddVariable(Obj,Name,Dim,Value)
%SOFAaddVariable
% Obj = SOFAaddVariable(Obj,Name,Dim,Value) adds a user-defined variable
% to the SOFA structure OBJ. NAME must be a string with the variable name
% ('API', 'PRIVATE', or 'GLOBAL' are not allowed). DIM is a string
% describing the dimensions of the variable according to SOFA specifications.
% The content of NAME is stored in VALUE which must be of the size DIM.
% The used-defined variable NAME will be stored as Obj.NAME and its
% dimension will be stored as Obj.API.Dimensions.NAME. Note that user-
% defined variables can be saved in SOFA file and thus remain in the
% object when loaded from a SOFA file.
%
% Obj = SOFAaddVariable(Obj,Name,'PRIVATE',Value) adds a private variable
% to OBJ. The private variable NAME will be stored as Obj.PRIVATE.NAME.
% Note that the private variables will be not stored in SOFA files and
% arbitrary dimensions are allowed.
%
% Note that adding variables to Data is not supported and should not be used
% as it might be confusing having user-defined variables in a Data structure.
% Consider adding a variable at the global level instead, which would be more
% clear for others.
% 9.8.2014: dimension is added if not previously found.
%
% SOFA API - function SOFAaddVariable
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or ñ as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
Dim=upper(Dim);
switch Dim
case 'PRIVATE'
Obj.PRIVATE.(Name)=Value;
otherwise
switch Name
case {'API','PRIVATE','GLOBAL'}
error('This variable name is reserved.');
otherwise
if strncmp(Name,'Data.',length('Data.'))
% add variable to Data
Name=Name(length('Data.')+1:end);
Obj.Data.(Name)=Value;
Obj.API.Dimensions.Data.(Name)=Dim;
else
% add variable to root
Obj.(Name)=Value;
Obj.API.Dimensions.(Name)=Dim;
end
dims=SOFAdefinitions('dimensions');
for ii=1:length(Dim)
if ~isfield(dims,Dim(ii))
error('Dimension not supported.');
end
end
end
end
function output = SOFAappendText(Obj,attribute,new)
%SOFAappendText
%
% output = SOFAappendText(input,new) appends the new text to the
% attribute using the correct SOFA separators. If the attribute is empty
% or non-existing, the output will be the new text only.
%
% SOFA API - function SOFAappendText
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
if ~isfield(Obj,attribute), Obj.(attribute)=''; end
if isempty(Obj.(attribute)),
output=new;
else
output=[Obj.(attribute) SOFAdefinitions('EOL') new];
end
\ No newline at end of file
function [flags,keyvals,varargout] = SOFAarghelper(posdepnames,definput,arglist,callfun)
%SOFAARGHELPER Parse arguments for SOFA
% Usage: [flags,varargout] = SOFAarghelper(posdepnames,definput,arglist,callfun);
%
% Input parameters:
% posdepnames : Names of the position dependant parameters.
% definput : Struct to define the allowed input
% arglist : Commandline of the calling function (varargin)
% callfun : Name of calling function (optional)
%
% Output parameters:
% flags : Struct with information about flags.
% keyvals : Struct with key / values.
% varargout : The position dependant pars. properly initialized
%
% [flags,keyvals]=SOFAARGHELPER(posdepnames,definput,arglist) assists in
% parsing input parameters for a function. Parameters come in
% four categories:
%
% Position dependant parameters. These must not be strings. These are
% the first parameters passed to a function, and they are really just a short way
% of specifying key/value pairs. See below.
%
% Flags. These are single string appearing after the position dependant
% parameters.
%
% Key/value pairs. The key is always a string followed by the value, which can be
% anything.
%
% Expansions. These appear as flags, that expand into a pre-defined list of parameters.
% This is a short-hand way of specifying standard sets of flags and key/value pairs.
%
% The parameters are parsed in order, so parameters appearing later in varargin will override
% previously set values.
%
% The following example for calling SOFAARGHELPER is taken from DGT:
%
% definput.keyvals.L=[];
% definput.flags.phase={'freqinv','timeinv'};
% [flags,kv]=SOFAarghelper({'L'},definput,varargin);
%
% The first line defines a key/value pair with the key 'L' having an initial value of `[]`
% (the empty matrix).
%
% The second line defines a group of flags by the name of phase. The
% group phase contains the flags `'freqinv'` and `'timeinv'`, which can
% both be specified on the command line by the user. The group-name
% phase is just for internal use, and does not appear to the user. The
% flag mentioned first in the list will be selected by default, and only
% one flag in a group can be selected at any time. A group can contain as
% many flags as desired.
%
% The third line is the actual call to SOFAARGHELPER which defines the
% output flags and `kv`. The input `{'L'}` indicates that the value of
% the parameter 'L' can also be given as the very first value in
% varargin.
%
% The output struct kv contains the key/value pairs, so the value associated to `'L'` is
% stored in kv.L.
%
% The output struct flags contains information about the flags choosen
% by the user. The value of flags.phase will be set to the selected flag
% in the group phase and additionally, the value of `flags.do_timeinv`
% will be 1 if 'timeinv' was selected and 0 otherwise, and similarly for
% 'freqinv'. This allows for easy checking of selected flags.
%
% Copyright (C) 2005-2012 Peter L. Soendergaard.
% Modified from the LTFAT 1.1.2 for SOFA by Piotr Majdak.
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
persistent SOFA_CONF;
if isempty(SOFA_CONF)
SOFA_CONF.fundefs = struct;
end;
if ischar(posdepnames)
% Special interface needed for ltfatsetdefaults and ltfatgetdefaults,
% activated when first argument is a string.
% First input argument, posdepnames, is a string, one of the options
% in the "switch" section below
% Second input argument, definput, is a function name to get or set
% Third input argument, arglist , is a cell-array with options to set.
switch(lower(posdepnames))
case 'get'
if isfield(SOFA_CONF.fundefs,definput)
flags=SOFA_CONF.fundefs.(definput);
else
flags={};
end;
case 'set'
SOFA_CONF.fundefs.(definput)=arglist;
case 'all'
flags=SOFA_CONF.fundefs;
case 'clearall'
SOFA_CONF.fundefs=struct;
end;
return
end;
if nargin<4
f=dbstack;
callfun=f(2).name;
end;
nposdep=numel(posdepnames);
% Resolve import specifications BEFORE adding our own specifications.
if isfield(definput,'import')
for imp = definput.import;
definput=feval(['arg_',imp{1}],definput);
end;
end;
if isfield(definput,'flags')
defflags=definput.flags;
else
defflags=struct;
end;
if isfield(definput,'keyvals')
defkeyvals=definput.keyvals;
else
defkeyvals=struct;
end;
if isfield(definput,'groups')
groups=definput.groups;
else
groups=struct;
end;
total_args = numel(arglist);
% Determine the position of the first optional argument.
% If no optional argument is given, return nposdep+1
first_str_pos = 1;
while first_str_pos<=total_args && ~ischar(arglist{first_str_pos})
first_str_pos = first_str_pos +1;
end;
% If more than nposdep arguments are given, the first additional one must
% be a string
if (first_str_pos>nposdep+1)
error('%s: Too many input arguments',upper(callfun));
end;
n_first_args=min(nposdep,first_str_pos-1);
keyvals=defkeyvals;
% Copy the given first arguments
for ii=1:n_first_args
keyvals.(posdepnames{ii})=arglist{ii};
end;
% Initialize the position independent parameters.
% and create reverse mapping of flag -> group
flagnames=fieldnames(defflags);
flags=struct;
% In order for flags to start with a number, it is necessary to add
% 'x_' before the flag when the flags are used a field names in
% flagreverse. Externally, flags are never used a field names in
% structs, so this is an internal problem in ltfatarghelper that is
% fixed this way.
flagsreverse=struct;
for ii=1:numel(flagnames)
name=flagnames{ii};
flaggroup=defflags.(name);
flags.(name)=flaggroup{1};
for jj=1:numel(flaggroup)
flagsreverse.(['x_', flaggroup{jj}])=name;
flags.(['do_',flaggroup{jj}])=0;
end;
flags.(['do_',flaggroup{1}])=1;
end;
%Get the rest of the arguments
restlist = arglist(first_str_pos:end);
%Check for default arguments
if isfield(SOFA_CONF.fundefs,callfun)
s=SOFA_CONF.fundefs.(callfun);
restlist=[s,restlist];
end;
% Check for import defaults
if isfield(definput,'importdefaults')
% Add the importdefaults before the user specified arguments.
restlist=[definput.importdefaults,restlist];
end;
while ~isempty(restlist)
argname=restlist{1};
restlist=restlist(2:end); % pop
found=0;
% Is this name a flag? If so, set it
if isfield(flagsreverse,['x_',argname])
% Unset all other flags in this group
flaggroup=defflags.(flagsreverse.(['x_',argname]));
for jj=1:numel(flaggroup)
flags.(['do_',flaggroup{jj}])=0;
end;
flags.(flagsreverse.(['x_',argname]))=argname;
flags.(['do_',argname])=1;
found=1;
end;
% Is this name the key of a key/value pair? If so, set the value.
if isfield(defkeyvals,argname)
keyvals.(argname)=restlist{1};
restlist=restlist(2:end);
found=1;
end;
% Is this name a group definition? If so, put the group in front of the parameters
if isfield(groups,argname)
s=groups.(argname);
restlist=[s,restlist];
found=1;
end;
% Is the name == 'argimport'
if strcmp('argimport',argname)
fieldnames_flags= fieldnames(restlist{1});
fieldnames_kvs = fieldnames(restlist{2});
for ii=1:numel(fieldnames_flags)
importname=fieldnames_flags{ii};
flags.(importname)=restlist{1}.(importname);
end;
for ii=1:numel(fieldnames_kvs)
importname=fieldnames_kvs{ii};
keyvals.(importname)=restlist{2}.(importname);
end;
restlist=restlist(3:end);
found=1;
end;
if found==0
if ischar(argname)
error('%s: Unknown parameter: %s',upper(callfun),argname);
else
error('%s: Parameter is not a string, it is of class %s',upper(callfun),class(argname));
end;
end;
%ii=ii+1;
end;
% Fill varargout
varargout=cell(1,nposdep);
for ii=1:nposdep
varargout(ii)={keyvals.(posdepnames{ii})};
end;
function ApparentPositionVector = SOFAcalculateAPV(Obj)
%SOFAcalculateAPV
% APV = SOFAcalculateAPV(Obj) calculates the apparent position vector
% (APV) which represents the position of the source relative to the
% listener's position and view. APV is in the format [azi ele radius]
% with units [deg deg m].
% Note that ListenerUp is not considered and the APV can be considered as
% the HRTF direction usually used in HRTF databases
% SOFA API - function SOFAcalculateAPV
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences;
% Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
% === Apparent azimuth ===
% Apparent azimuth is the relative direction of the sound source in the
% horizontal plane from the listener viewpoint
%
% Get head orientation of the listener and source position in spherical
% coordinates
HeadOrientation = SOFAconvertCoordinates( ...
Obj.ListenerView,Obj.ListenerView_Type,'spherical');
SourcePosition = SOFAconvertCoordinates( ...
Obj.SourcePosition,Obj.SourcePosition_Type,'spherical');
% Calculate the relative azimuth angle between them
APVazimuth = correctAzimuth(bsxfun( ...
@minus,SourcePosition(:,1),HeadOrientation(:,1)));
% === Apparent elevation ===
% Apparent elevation is the relative direction of the sound source in the median
% plane from the listener viewpoint
APVelevation = correctElevation(bsxfun( ...
@minus,SourcePosition(:,2),HeadOrientation(:,2)));
% === Apparent distance ===
% Apparent distance is the relative distance between the sound source and the
% listener
%
% Get listener positon in spherical coordinates
ListenerPosition = SOFAconvertCoordinates( ...
Obj.ListenerPosition,Obj.ListenerPosition_Type,'spherical');
% Relative distance
APVdistance = bsxfun(@minus,SourcePosition(:,3),ListenerPosition(:,3));
% Combine to matrix
ApparentPositionVector = [ ...
APVazimuth, ...
APVelevation, ...
APVdistance, ...
];
end
function phi = correctAzimuth(phi)
% Ensure -360 <= phi <= 360
phi = rem(phi,360);
% Ensure -180 <= phi < 180
phi(phi<-180) = phi(phi<-180) + 360;
phi(phi>=180) = phi(phi>=180) - 360;
end
% TODO: check what convetion we are using for delta!
function delta = correctElevation(delta)
% Ensure -180 <= delta <= 180
delta = correctAzimuth(delta);
% Ensure -90 <= delta <= 90
delta(delta<-90) = -delta(delta<-90) - 180;
delta(delta>90) = -delta(delta>90) + 180;
end
function newfn=SOFAcheckFilename(fn)
%SOFACHECKFILENAME
% newFN = SOFAcheckFilename(FN) checks the filename FN and:
% SOFA API - function SOFAcheckFilename
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or ñ as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
% filename = string?
if ~ischar(fn)
error('Filename must be a string.');
end
newfn=fn;
function [Obj, log] = SOFAcompact(Obj)
%SOFAcompact
% Obj = SOFAcompact(Obj) compacts the unique value to singleton dimensions
% of variables where possible.
% Current limitation: Variables with 3 dimensions will be only compacted
% when the third dimension is the compressible one.
%
% SOFA API - function SOFAcompact
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence")
% You may not use this work except in compliance with the Licence.
% You may obtain a copy of the Licence at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the Licence for the specific language governing permissions and limitations under the Licence.
%% Initial check
OC = SOFAgetConventions(Obj.GLOBAL_SOFAConventions,'a');
log={''};
%% Update dimensions
Obj=SOFAupdateDimensions(Obj);
dims=SOFAdefinitions('dimensions');
%% compact w/o data
X=rmfield(Obj,{'Data','API'});
Xf=fieldnames(X);
for ii=1:length(Xf)
if ~isempty(strfind(Xf{ii},'_')), continue; end; % is an attribute --> not compressible
if ~isfield(OC.API.Dimensions, Xf{ii}), continue; end; % is a used-defined variable --> not compressible
dims=OC.API.Dimensions.(Xf{ii}); % get all possible dimensions
if ~iscell(dims), continue; end; % variable with a single dimension definition --> not compressible
if numel(dims)==1, continue; end; % variable with a single dimension definition --> not compressible
switch length(dims{1}) % how many dimensions do we have?
case 1
n=unique(Obj.(Xf{ii}));
if length(n)>1, continue; end; % entries not unique --> not compressible
Obj.(Xf{ii})=n; % compressed!
case 2
d=cell2mat(strfind(dims,'I')); % get all choices for a singleton dimensions
if strcmp(dims{d}(1),'I'), n=unique(Obj.(Xf{ii}),'rows'); else n=unique(Obj.(Xf{ii})','rows')'; end;
if size(n,1)>1, continue; end; % entries not unique --> not compressible
if strcmp(dims{d}(1),'I'), Obj.(Xf{ii})=n; else Obj.(Xf{ii})=n'; end; % compressed!
case 3
d=cell2mat(strfind(dims,'I'));
switch d
case 3
y=unique(reshape(Obj.(Xf{ii}),[],size(Obj.(Xf{ii}),d))','rows');
if size(y,1)>1, continue; end; % entries not unique --> not compressible
Obj.(Xf{ii})=reshape(y',size(Obj.(Xf{ii}),1),size(Obj.(Xf{ii}),2));
otherwise
warning('SOFA:compact',[Xf{ii} ' not compressed (currently limited)']);
end
end
end
%% Compact the data
Xf=fieldnames(Obj.Data);
for ii=1:length(Xf)
if ~isempty(strfind(Xf{ii},'_')), continue; end; % is an attribute --> not compressible
if ~isfield(OC.API.Dimensions.Data, Xf{ii}), continue; end; % is a used-defined variable --> not compressible
dims=OC.API.Dimensions.Data.(Xf{ii}); % get all possible dimensions
if ~iscell(dims), continue; end; % variable with a single dimension definition --> not compressible
if numel(dims)==1, continue; end; % variable with a single dimension definition --> not compressible
switch length(dims{1}) % how many dimensions do we have?
case 1
n=unique(Obj.Data.(Xf{ii}));
if length(n)>1, continue; end; % entries not unique --> not compressible
Obj.Data.(Xf{ii})=n; % compressed!
case 2
d=cell2mat(strfind(dims,'I')); % all choices for a singleton dimensions
if strcmp(dims{d}(1),'I'), n=unique(Obj.Data.(Xf{ii}),'rows'); else n=unique(Obj.Data.(Xf{ii})','rows')'; end;
if size(n,1)>1, continue; end; % entries not unique --> not compressible
if strcmp(dims{d}(1),'I'), Obj.Data.(Xf{ii})=n; else Obj.Data.(Xf{ii})=n'; end; % compressed!
case 3
% missing
warning('SOFA:compact',['Data.' Xf{ii} ' not compressed (functionality limited)']);
end
end
%% clean up
Obj=SOFAupdateDimensions(Obj);
if length(log)>1, log=log(2:end); else log={}; end;
function vec=getdim(Obj,str)
vec=NaN(1,length(str));
for ii=1:length(str)
vec(ii)=Obj.(upper(str(ii)));
end
\ No newline at end of file
function [tf,reason,where] = SOFAcompare(Obj1, Obj2, varargin)
%SOFASOFAcompare
% TF = SOFAcompare(A, B) compares A and B and
% returns logical 1 (true) if they are identical.
%
% [TF,REASON,WHERE] = SOFAcompare(A, B) provides the REASON
% and shows WHERE the difference arose.
%
% ... = SOFAcompare(A, B, 'ignoreDate') ignores the global attributes
% DateCreated and DateModified.
%
%
% Limited functionality!!! Only attributes are compared now.
%
%
%
% SOFA API - function SOFAcompare
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or ñ as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
definput.flags.type={'all','ignoreDate'};
[flags,~]=SOFAarghelper({},definput,varargin);
tf=1;
reason='';
where='';
% % check if the size is equal
% o1=whos('Obj1');
% o2=whos('Obj2');
% if o1.bytes ~= o2.bytes, tf=0; reason='Different size'; return; end
% get the field names
Xf=fieldnames(Obj1);
% ignore DateCreated and DateModified?
if flags.do_ignoreDate
Xf=fieldnames(rmfield(Obj1,{'GLOBAL_DateCreated','GLOBAL_DateModified'}));
end
% check if we have the same fields in Obj2 as in Obj1
for ii=1:length(Xf)
if ~isfield(Obj2,Xf{ii}), tf=0; reason='Field missing in B'; where=Xf{ii}; return; end
end
% check if we have the same content of attributes in Obj2 as in Obj1
for ii=1:length(Xf)
if isempty(strfind(Xf{ii},'_')), continue; end
if ~strcmp(Obj1.(Xf{ii}),Obj2.(Xf{ii})), tf=0; reason='Field not equal'; where=Xf{ii}; return; end
end
function SOFAcompileConventions(conventions)
%SOFAcompileConventions
%
% Obj = SOFAcompileConventions(sofaconventions) compiles the specified
% SOFA conventions. For every convention a CSV file has to exist which
% will be compiled to a .mat file used later by SOFAgetConventions().
%
% The CSV file must be in the directory conventions and have the same
% filename as conventions. SOFAcompileConventions generates 3 files, one
% for each flag (r, m, and all).
%
% Before compiling, SOFAcompileConventions checks if the modification
% date of the .mat files is older than that of the .csv file. Compiling
% is not performed if all .mat files are newer than the .csv file. This
% behaviour is required for operation in a read-only directory.
% SOFA API
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
baseFolder = fileparts(which('SOFAstart'));
if nargin<1
conventionFiles = dir(fullfile(baseFolder,'conventions','*.csv'));
conventions={};
for file = conventionFiles'
[~,name,ext] = fileparts(file.name);
% Check if mat files exist for every convention flag (r,m,a)
flagsCounter = 0;
for flag = 'rma'
flagFile = dir(fullfile(baseFolder,'conventions', ...
strcat(name,'-',flag,'.mat')));
if ~isempty(flagFile) && flagFile(1).datenum>file.datenum
flagsCounter = flagsCounter+1;
end
end
% If not all three files are up to request conventions compilation
if flagsCounter~=3
conventions{end+1} = name;
end
end
elseif ~iscell(conventions)
conventions={conventions};
end
%% ----- Convert convention csv files into mat files -----
for convention = conventions
% Read convention description from csv file
fid = fopen(fullfile(baseFolder,'conventions', ...
strcat(convention{:},'.csv')));
C = textscan(fid,'%s%s%s%s%s%s','Delimiter','\t','Headerlines',1);
fclose(fid);
% Convert to mat files for r,m,a cases
for flag = 'rma'
% Convert to SOFA object
Obj = compileConvention(C,flag);
% Write to mat file
if strcmp(Obj.GLOBAL_SOFAConventions,convention{:})
if strcmp(flag,'r') % Display message only the very first time
disp(['Compiling ',convention{:},' ', ...
Obj.GLOBAL_SOFAConventionsVersion]);