Closed germknoedlspeck closed 2 years ago
That's an optional field. I would suggest one of the following:
Maybe the second option with "simulated with Mesh2HRTF" would be nice.
The problem is the if statement asking for whether the field GLOBAL_Origin is empty - and if it does not even exist (because it's an optional field), an error is thrown.
I'd just rewrite it with isfield combined with isempty - ok?
If we don't write it in the first place it will always be empty. In that case you could also delete the line, unless the function is intended for use outside of Mesh2HRTF
nono, Matlab throws an error if you check a non-existent field whether it's empty or not.
So if we don't write it in the first place, it will always be non-existent
I meant you could completly remove it from the merge function. What need for checking if it exists, if we know it doesn't?
According to the comment, it's there for further use in spat5? I don't know if this is an optimal solution, maybe it would be useful for spat5 users changing the SOFA object themselves after the Mesh2HRTF pipeline or other code however they need it?
What comment? Sounds risky for an application to depend on mandatory data. I have no strong opinion on that - do it as you like :)
rewrote the statement as:
if isfield(sofa_read_L, 'GLOBAL_Origin') && isempty(sofa_read_L.GLOBAL_Origin) % added for spat5
Obj.GLOBAL_Origin = 'Mesh2HRTF_simulation';
elseif isfield(sofa_read_L, 'GLOBAL_Origin')
Obj.GLOBAL_Origin = sofa_read_L.GLOBAL_Origin;
end
to check for possible existence of the field GLOBAL_Origin, if there is no such field, then we don't create one.
calling merge_sofa_files.m throws the following error
because GLOBAL_Origin does not get written in output2hrtf.m
@f-brinkmann I can rewrite the if statement; is there a default value for GLOBAL_Origin?