Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to fix properly dimensions of data #81

Open
ReiNagahashi opened this issue Dec 13, 2023 · 1 comment
Open

How to fix properly dimensions of data #81

ReiNagahashi opened this issue Dec 13, 2023 · 1 comment

Comments

@ReiNagahashi
Copy link

ReiNagahashi commented Dec 13, 2023

I am trying to convert 10 impulse responses into a single SOFA format data. I stored the data of the impulse responses in the field named hrtfData.Data.IR with dimensions MNR (where M is the number of measurements, N is the length of each impulse response, and R is the number of microphones).

When I executed SOFASave, I encountered the following error. Upon inspecting the data in hrtfData.API.Dimensions.Data.IR, it appeared to be cell-type data with the string 'mRn'. Even after updating it to hrtfData.API.Dimensions.Data.IR {1} = 'MNR' to match the dimensions of MNR, the error persists. Can you please provide guidance on the correct method for verifying and correcting the dimensions?

CODE:

M = 10;
N = 4800;
R = 2;

hrir_matrix = zeros(M, N, R);
%...Manipulation of inserting impulse response data into hrir_matrix for hrtfData.Data.IR...

sourcePosition = zeros(M, 3); # ex: [azimuth(deg), elavation(deg), radius(m)]
%...Manipulation of sourcePosition for hrtfData.SourcePosition...

% Create SOFA structure
hrtfData = SOFAgetConventions('SimpleFreeFieldHRIR');
%Configuration for hrtfData
hrtfData.API.M = M;
hrtfData.API.N = N;
% hrtfData.API.Dimensions.Data.IR{1} = 'MRN';

hrtfData.Data.SamplingRate = 48000;
hrtfData.Data.IR = hrir_matrix;
hrtfData.ListenerPosition = [0, 0, 0];  % 
hrtfData.SourcePosition = sourcePosition;
hrtfData.GLOBAL_History = 'converted by Rei';
% Save SOFAfile
SOFAsave('converted_measured_hrirs.sofa', hrtfData);

Error Message: 
Error: SOFAupdateDimensions (line 125)
Data.IR: dimension could not be matched.

Error: SOFAsave (line 60)
Obj=SOFAupdateDimensions(Obj);

Error: main (line 168)
SOFAsave('converted_measured_hrirs.sofa', hrtfData);

@petibub
Copy link
Member

petibub commented Dec 13, 2024

Dear ReiNagahashi,

sorry for the late reply. I think that the problem is that Data.IR needs to have dimensions MRN, not MNR. Did you try that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants