huppertt / nirs-toolbox

Toolbox for fNIRS analysis
89 stars 61 forks source link

Updates by Emma #14

Closed ebaillargeon closed 1 year ago

ebaillargeon commented 2 years ago

Hi Ted, I've tried making three updates to the code: 1) update oxysoft2matlab version, 2) handle .oxy4 files in nirs.loadDirectory, and 3) incorporate the edits we made to roiAverage.m to handle NaN in Andi's data (need to take a look to confirm ok for general cases). Happy to discuss any questions. Thanks, Emma

ebaillargeon commented 2 years ago

Three additional notes, which I have not coded in the toolbox:

1) Edit nirs t-test.m function so that if either A or B is all NaN then A-B is NaN (not A or B). Currently, I fix this based on what conditions I know are NaN after computing the t-tests

2) Update nirs.jointTest to allow for a vector input (currently need to run as in a loop)

3) I'm using my own code to identify flat channels because the code in the toolbox was too sensitive. I changed from using a moving average to a moving variance window. . Below is the code that I use to identify flat channels in case this is useful for other contexts

d = data(ii).data; %raw data
Fs = data(ii).Fs; %sampling frequency

%compute the variance of the signal over a 3s moving window:
f = round(Fs*3);
d_movvar = movvar(d,f);

% flat channels
bad = find(any(d_movvar < 1e-9));

if ~isempty(bad)
    flatCh_idx = [flatCh_idx;ii];
    flatCh_ch = [flatCh_ch;{bad}];

    disp(['bad channels: ', num2str(bad)])
end