Change fot computing GLM fNIRS

Hello,

I happened to find what I think is a bug during the computation of the GLM from the HbO sources extracted at cortex level. In line 439 of process_nst_glm_fit:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if save_betas

    % Saving B as maps

for i_reg_name=1:length(model.reg_names)

         data_out = zeros(size(DataMat.F, 1), 1); ←– This

        output_tag = sprintf('ir%d_beta%d', sInput.iItem, i_reg_name);

        output_comment = \[output_prefix '- beta ' model.reg_names{i_reg_name}\];

if surface_data

            \[sStudy, ResultFile\] = nst_bst_add_surf_data(results.B(i_reg_name,:)', \[1\], \[\], output_tag, output_comment, ...

                                                         \[\], sStudy, 'GLM', DataMat.SurfaceFile);

else

            data_out(nirs_ichans,:) = results.B(i_reg_name,:);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

the row:

            data_out = zeros(size(DataMat.F, 1), 1);

always returns error, since DataMat, when GLM is computed from sources, does not contain the F field.

I happened to resolve this problem moving that line in the else section of the following if.

Can you verify if this behaviour was intended and the GLM is not supposed to run on sources, or if it was unintended?

Thanks,

Zanchi

Ping @edelaire

hello,

Thanks a lot for the report. I have to finish some abtract for a conference but i should have time to fix this at the end of the week.

For now, you should be able to use the GLM without checking the ‘Save extra output options’

Hello,

Thanks a lot for the report. It has been fixed here: [bugfix] Fix extra output for GLM by Edouard2laire · Pull Request #288 · Nirstorm/nirstorm · GitHub

It should be working fine after updating nirstorm :slight_smile:

Edouard