Batch processing without GUI

Post Reply
larsbramslow
Posts: 1
Joined: Tue Apr 15, 2025 8:34 am

Batch processing without GUI

Post by larsbramslow » Tue Apr 15, 2025 11:21 am

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

hendrikkayser
Posts: 40
Joined: Fri May 10, 2019 7:58 am

Re: Batch processing without GUI

Post by hendrikkayser » Wed Apr 16, 2025 3:49 pm

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:

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

Post Reply