Commit d4a3b451 authored by mayucel's avatar mayucel
Browse files

rcMap related two fixes

1) moved rcMap up front before the user inputs, so that GLM reads it from the prior tCCA_GLM function.
2) Because of the (rather annoying or stlll mysterious) iBlk index, the ischar vs iscell check was not working, since it was now all cell arrays. So added rcMap{iBlk} which fixed it.
3) And after this fix, this was the first full run of homer with our function, so an important moment!, wanted to share with you but you are busy with combe:)
parent 0432118a
Loading
Loading
Loading
Loading
+692 −0

File added.

Preview size limit exceeded, changes collapsed.

+11 −12
Original line number Diff line number Diff line
% SYNTAX:
% [yavg, yavgstd, tHRF, nTrials, ynew, yresid, ysum2, beta, R] = hmrR_GLM(data, stim, probe, mlActAuto, Aaux, tIncAuto, trange, glmSolveMethod, idxBasis, paramsBasis, rhoSD_ssThresh, flagNuisanceRMethod, driftOrder, flagMotionCorrect, rcMap )
% [yavg, yavgstd, tHRF, nTrials, ynew, yresid, ysum2, beta, R] = hmrR_GLM(data, stim, probe, mlActAuto, Aaux, tIncAuto, trange, rcMap, glmSolveMethod, idxBasis, paramsBasis, rhoSD_ssThresh, flagNuisanceRMethod, driftOrder, flagMotionCorrect )
%
% UI NAME:
% GLM_HRF_Drift_SS
@@ -20,6 +20,9 @@
% Aaux - A matrix of auxilliary regressors (#time points x #Aux channels)
% tIncAuto - a vector (#time points x 1) indicating which data time points
%            are motion (=0) or not (=1)
% rcMap - An array of cells (1 x #fNIRS channels) containing aux regressor 
%           indices for individual regressor-channel mapping. Currently
%           only relevant when flagNuisanceRMethod = 3 (tCCA regressors).
% trange - defines the range for the block average [tPre tPost]
% glmSolveMethod - this specifies the GLM solution method to use
%            1 - use ordinary least squares (Ye et al (2009). NeuroImage, 44(2), 428?447.)
@@ -66,9 +69,6 @@
%            mapped by rcMap, provided by hmr_tCCA()
% driftOrder - Polynomial drift correction of this order
% flagMotionCorrect - set to 1 to baseline correct between motion epochs indicated in tIncAuto, otherwise set to 0
% rcMap - An array of cells (1 x #fNIRS channels) containing aux regressor 
%           indices for individual regressor-channel mapping. Currently
%           only relevant when flagNuisanceRMethod = 3 (tCCA regressors).
%
%
% OUTPUTS:
@@ -87,7 +87,7 @@
%
%
% USAGE OPTIONS:
% GLM_HRF_Drift_SS_Concentration: [dcAvg, dcAvgStd, nTrials, dcNew, dcResid, dcSum2, beta, R] = hmrR_GLM(dc, stim, probe, mlActAuto, Aaux, tIncAuto, trange, glmSolveMethod, idxBasis, paramsBasis, rhoSD_ssThresh, flagNuisanceRMethod, driftOrder, flagMotionCorrect, rcMap )
% GLM_HRF_Drift_SS_Concentration: [dcAvg, dcAvgStd, nTrials, dcNew, dcResid, dcSum2, beta, R] = hmrR_GLM(dc, stim, probe, mlActAuto, Aaux, tIncAuto, rcMap, trange, glmSolveMethod, idxBasis, paramsBasis, rhoSD_ssThresh, flagNuisanceRMethod, driftOrder, flagMotionCorrect)
%
%
% PARAMETERS:
@@ -99,11 +99,10 @@
% flagNuisanceRMethod: 1
% driftOrder: 3
% flagMotionCorrect: 0
% rcMap: 'all'
%
%
function [data_yavg, data_yavgstd, nTrials, data_ynew, data_yresid, data_ysum2, beta_blks, yR_blks] = ...
    hmrR_GLM(data_y, stim, probe, mlActAuto, Aaux, tIncAuto, trange, glmSolveMethod, idxBasis, paramsBasis, rhoSD_ssThresh, flagNuisanceRMethod, driftOrder, flagMotionCorrect, rcMap )
    hmrR_GLM(data_y, stim, probe, mlActAuto, Aaux, tIncAuto, rcMap, trange, glmSolveMethod, idxBasis, paramsBasis, rhoSD_ssThresh, flagNuisanceRMethod, driftOrder, flagMotionCorrect)

% Init output
data_yavg     = DataClass().empty();
@@ -212,9 +211,9 @@ for iBlk=1:length(data_y)
            case 2 % use average of all active SS as regressor
                mlSSlst = 1;
            case 3 % use tCCA regressors and channel map from hmrR_tCCA()
                if ischar(rcMap) % use all regressors for all channels (only one group)
                if ischar(rcMap{iBlk}) % use all regressors for all channels (only one group)
                    mlSSlst = 1;
                elseif iscell(rcMap) % use channel regressor map
                elseif iscell(rcMap{iBlk}) % use channel regressor map
                    mlSSlst = 1:size(rcMap,2); 
                end

@@ -482,11 +481,11 @@ for iBlk=1:length(data_y)
                Ass = mean(y(:,conc,lstSS),3);
                At = [A(:,:,conc) Ass];
            elseif flagNuisanceRMethod==3
                if ischar(rcMap) % no channel map: use all tCCA regressors for one group of all channels
                if ischar(rcMap{iBlk}) % no channel map: use all tCCA regressors for one group of all channels
                    lstML = lstMLtmp(find(mlAct(lstMLtmp)==1));
                    At = [A(:,:,conc) Aaux]; 
                elseif iscell(rcMap) % channel map: each single regressor corresponds to one channel (nCH groups)
                    lstML = lstMLtmp(find(mlAct(rcMap{conc,iSS})==1));
                elseif iscell(rcMap{iBlk}) % channel map: each single regressor corresponds to one channel (nCH groups)
                    lstML = lstMLtmp(find(mlAct(rcMap{iBlk}{conc,iSS})==1));
                    Atcca = Aaux(:,rcMap{conc,iSS});
                    At = [A(:,:,conc) Atcca];
                end