Hi Forum,
I am looking to batch process many files and audiograms with NAL-NL2. The script MHAGUI_FITTING_OFFLINE has most functionality but I want no GUI. And the matlab code is complicated, so eliminating the GUI is not easy. Has anyone written such a script, that they will share?
Thanks,
Lars
Batch processing without GUI
-
- Posts: 40
- Joined: Fri May 10, 2019 7:58 am
Re: Batch processing without GUI
Hello Lars,
I can share some code that I used it to compute gaintables using the NAL-NL2 function from the openMHA toolset directly. I have extracted the relevant lines of code from the fitting GUI.
This should be the part that is useful to eliminate the fitting GUI part for your approach:
sGT can then be set in the running configuration to process the audiofiles.
I hope that helps!
Hendrik
I can share some code that I used it to compute gaintables using the NAL-NL2 function from the openMHA toolset directly. I have extracted the relevant lines of code from the fitting GUI.
This should be the part that is useful to eliminate the fitting GUI part for your approach:
Code: Select all
%% Start openMHA instance
mha = mha_start;
% Read configuration containing dynamic range compressor
mha_query(mha,'','read:openmha.cfg');
% State "prepare" is sufficient for computation of gaintables
mha_set(mha,'cmd','prepare');
%% Compute gaintable
% sID: String that must contain subject's date of birth preceeded by two arbritrary entries (initials): XXYYMMDD
% vF: Audiogram frequencies
% vAudiogram_R: rigth ear audiogram values
% vAudiogram_L: left ear audiogram values
% Prepare input struct for gain prescription rule
sAud.client_id = sID;
for IDXf = 1:length(vF)
sAud.r.htl_ac.data(IDXf).f = vF(IDXf);
sAud.r.htl_ac.data(IDXf).hl = vAudiogram_R(IDXf);
sAud.l.htl_ac.data(IDXf).f = vF(IDXf);
sAud.l.htl_ac.data(IDXf).hl = vAudiogram_L(IDXf);
end
% Read current openMHA configuration
mha_get_basic_cfg_network( mha );
global mha_basic_cfg;
libmultifit();
libconfigdb();
csPlugs = multifit.query(mha_basic_cfg.mha);
sFitmodel = csPlugs{1}.fitmodel;
%% Optional: Extract level paramters from running dc configuration and set for gain computation, other wise default input level range (-10dB to 110 dB) will be used
GT_info = mha_get(mha,'mha.transducers.mhachain.ola.dc');
sFitmodel.levels = GT_info.gtmin:GT_info.gtstep:size(GT_info.gtdata,2)-1;
%%
if sFitmodel.channels == 2
sFitmodel.side = 'lr';
end
% compute gaintable
sGT = gainrule_NAL_NL2(sAud,sFitmodel);
sGT can then be set in the running configuration to process the audiofiles.
I hope that helps!
Hendrik
-
- Posts: 2
- Joined: Tue Apr 15, 2025 8:34 am
Re: Batch processing without GUI
Hi again
Thanks - that worked for me and I can process for a particular audiogram. However, I would like to create and store targets for a list of audiograms, for later processing by another script that runs the openMHA. In trying to do that I've been looking at the code in the fitting GUI and copied some of the API calls to eg multifit and configdb. There is clearly an API for all of this but the source files have very little documentation, so I am struggling to get the code working and I have a feeling all I need is there already. If there is an API documentation, can you share that?
Best,
Lars
Thanks - that worked for me and I can process for a particular audiogram. However, I would like to create and store targets for a list of audiograms, for later processing by another script that runs the openMHA. In trying to do that I've been looking at the code in the fitting GUI and copied some of the API calls to eg multifit and configdb. There is clearly an API for all of this but the source files have very little documentation, so I am struggling to get the code working and I have a feeling all I need is there already. If there is an API documentation, can you share that?
Best,
Lars