Any2HRTF / Mesh2HRTF

Open software for the numerical calculation of head-related transfer functions
European Union Public License 1.2
111 stars 14 forks source link

merge_sofa_files throws error "unrecognized field name GLOBAL_Origin" #56

Closed germknoedlspeck closed 2 years ago

germknoedlspeck commented 2 years ago

calling merge_sofa_files.m throws the following error

Unrecognized field name "GLOBAL_Origin".

Error in merge_sofa_files (line 300)
    if isempty(sofa_read_L.GLOBAL_Origin) % added for spat5

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?

f-brinkmann commented 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.

germknoedlspeck commented 2 years ago

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?

f-brinkmann commented 2 years ago

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

germknoedlspeck commented 2 years ago

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

f-brinkmann commented 2 years ago

I meant you could completly remove it from the merge function. What need for checking if it exists, if we know it doesn't?

germknoedlspeck commented 2 years ago

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?

f-brinkmann commented 2 years ago

What comment? Sounds risky for an application to depend on mandatory data. I have no strong opinion on that - do it as you like :)

germknoedlspeck commented 2 years ago

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.