huppertt / nirs-toolbox

Toolbox for fNIRS analysis
89 stars 61 forks source link

error produced by nirs.modules.MixedEffectsConnectivity() #34

Closed superhenrikke closed 8 months ago

superhenrikke commented 1 year ago

Hi. I have also posted this on the FNIRS Analysis Club on Facebook. Sorry for cross-posting. Describe the bug

When trying to run nirs.modules.MixedEffectsConnectivity() I am running into errors.

1) First I simply tried to create a group-level connectivity job, using basic code and all defaults (code follows):

j = nirs.modules.Connectivity(); % Create the subject-level connectivity job
j.corrfcn = @(data) nirs.sFC.ar_corr(data,'4xFs',true);
j.divide_events = 1; % Split connectivity model according to conditions
SubjStats = j.run(hb) % Run connectivity job
j = nirs.modules.MixedEffectsConnectivity() % Group level connectivity
GroupStats = j.run(SubjStats)

when running that I get an error that I do not understand:

Unrecognized function or variable 'models'.
Error in nirs.modules.MixedEffectsConnectivity/runThis (line 152)
G.variables.model=models;
Error in nirs.modules.AbstractModule/run (line 77)
out = obj.runThis( inputs );

Does this have anything to do with my data and is there anything I can do to resolve this issue?

2) [RESOLVED] Second, I used the same code as above, but before computing subject-level connectivity stats I removed bad channels (both regular and short channels) by setting them to zero. This produced a different error, which I assume is related to my data, specifically the bad channels:

Unable to perform assignment because the size of the left side is 101-by-3134 and the size of the right side is 77-by-3134.
Error in nirs.math.fitlme (line 25) beta(:,~bad_vars),bHat(:,~bad_vars),covb(:,:,~bad_vars),LL(~bad_vars),w(:,~bad_vars)] = nirs.math.fitlme(X,Y(:,~bad_vars),Z,robust_flag,zero_theta,verbose);
Error in nirs.modules.MixedEffectsConnectivity/runThis (line 102)
[Coef,~,StdErr] = nirs.math.fitlme(X,D,Z,obj.robust,false,false);
Error in nirs.modules.AbstractModule/run (line 77)
out = obj.runThis( inputs );

[RESOLVED] Is the mixed-effects connectivity module designed to work with missing data? Is there anything I can do to make it work? [EDIT: I received one answer from the facebook group saying "this module can not take care of NaN values", which answers my question.]

I updated nirs-toolbox 01.11.23.

Thanks for any help! Henrikke Dybvik

Screenshots 1) error1 2) error2

Desktop (please complete the following information):

superhenrikke commented 8 months ago

After a few months and updates to the toolbox I am not longer facing this issue.