sofacoustics / SOFAtoolbox

SOFA Toolbox (API for Matlab, Octave)
http://sofaconventions.org
European Union Public License 1.2
116 stars 31 forks source link

SOFAhrtf2dtf needs field GLOBAL_Comment to exist #64

Closed germknoedlspeck closed 1 year ago

germknoedlspeck commented 1 year ago
Unrecognized field name "GLOBAL_Comment".

Error in SOFAhrtf2dtf (line 137)
dtf.GLOBAL_Comment = [dtf.GLOBAL_Comment '. Directional transfer functions (DTFs) were generated by removing from the HRTFs the direction-independent log-amplitude spectrum for each ear.'];

My workaround is to create the field and assigning it an empty string, i.e.,

HRTF_Obj.GLOBAL_Comment = ' ';

isfmiho commented 1 year ago

I ran the demo script 'demo_SOFAHRTF2DTF.m' and could not reproduce the error.

Can you tell me which data to test in order to reproduce the error?

germknoedlspeck commented 1 year ago

I tried creating a SimpleFreeFieldHRIR object by

SOFAstart;
Obj = SOFAgetConventions('SimpleFreeFieldHRIR');

and this will leave out the GLOBAL_Comment (and some other) variables that are part of a measured or calculated HRIR. Can you reproduce this?

This issue does not happen when executing output2hrtf within Mesh2HRTF, but it happens with merge_sofa_files from the same project, and I do not understand where the difference comes from (function call is the same).

isfmiho commented 1 year ago

I have neither an error nor a warning with the following code:

clear all;   % optional
SOFAstart;
Obj = SOFAgetConventions('SimpleFreeFieldHRIR');
Obj.Data.IR = rand(1000,2,256);
[dtf,ctf] = SOFAhrtf2dtf(Obj);

(tested with SOFA Toolbox for Matlab/Octave 2.1.2, SOFA version 2.1, SimpleFreeFieldHRIR conventions version 1.0)

What happens if you run the code above?

germknoedlspeck commented 1 year ago

This is the output on the console:

SOFA Toolbox for Matlab/Octave 2.1.2. Copyright: Acoustics Research Institute.
This API implements SOFA version 2.1.
Available SOFA Conventions: FreeFieldDirectivityTF, FreeFieldHRIR, FreeFieldHRTF, General, GeneralFIR, GeneralFIR-E, GeneralFIRE, GeneralSOS, GeneralString, GeneralTF, GeneralTF-E, SimpleFreeFieldHRIR, SimpleFreeFieldHRSOS, SimpleFreeFieldHRTF, SimpleFreeFieldSOS, SimpleHeadphoneIR, SingleRoomMIMOSRIR, SingleRoomSRIR
SOFAdbPath (local HRTF database): C:\Users\kpollack\Documents\MATLAB\SOFAtoolbox\data\SOFA
SOFAdbURL (internet repository): http://www.sofacoustics.org/data

and I have three structs in the workspace: ctf, dtf, and Obj None of them have the field GLOBAL_Comment - I don't understand 😬

petibub commented 1 year ago

This means, that SOFAhrtf2dtf works as expected on your machine.

Now, could you provide information to reproduce your problem?

isfmiho commented 1 year ago

GLOBAL_Comment is not a mandatory field (anymore) in SimpleFreeFieldHRIR.

germknoedlspeck commented 1 year ago

I could solve the problem by using a fresh Matlab session! Thank you for your help :)

petibub commented 1 year ago

You're welcome :-)