Commit d70ace5b authored by Meryem Ayse Yucel's avatar Meryem Ayse Yucel
Browse files

Update hmrG_SubjAvg.m

FIX; When a subject had nan values on a channel/sbj, the group result ended being nan, even though the rest of the sbjs are good. Homer2 was unconsciously dealing with this issue by pruning outliers from group with a preset threshold. Since we do not have that feature in homer3, the issue came up. Issue is fixed now by identifying those channels with nan and removing them from group averaging.
parent 3bfe60d3
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -72,21 +72,23 @@ for iBlk = 1:nDataBlks
                    continue;
                    continue;
                end
                end
                
                
                lstPass = find(~isnan(squeeze(mean(yAvg(:,1,:,iC),1))) == 1);
                
                if iSubj==1 | iC>nStim
                if iSubj==1 | iC>nStim
                    for iCh = 1:nCh
                    for iPass=1:length(lstPass)
                        for iHb=1:3
                        for iHb=1:3
                            % Make sure 3rd arg to interp1 is column vector to guarauntee interp1 output is column vector
                            % Make sure 3rd arg to interp1 is column vector to guarauntee interp1 output is column vector
                            % which matches grp1 dimensions when adding the two.
                            % which matches grp1 dimensions when adding the two.
                            grp1(:,iHb,iCh,iC) = interp1(tHRF, yAvg(:,iHb,iCh,iC), tHRF(:));
                            grp1(:,iHb,lstPass(iPass),iC) = interp1(tHRF, yAvg(:,iHb,lstPass(iPass),iC), tHRF(:));
                        end
                        end
                    end
                    end
                    nStim = iC;
                    nStim = iC;
                else
                else
                    for iCh = 1:size(yAvg,3)
                    for iPass=1:length(lstPass)
                        for iHb=1:3
                        for iHb=1:3
                            % Make sure 3rd arg to interp1 is column vector to guarauntee interp1 output is column vector
                            % Make sure 3rd arg to interp1 is column vector to guarauntee interp1 output is column vector
                            % which matches grp1 dimensions when adding the two.
                            % which matches grp1 dimensions when adding the two.
                            grp1(:,iHb,iCh,iC) = grp1(:, iHb, iCh, iC) + interp1(tHRF, yAvg(:,iHb,iCh,iC), tHRF(:));
                            grp1(:,iHb,lstPass(iPass),iC) = grp1(:, iHb, lstPass(iPass), iC) + interp1(tHRF, yAvg(:,iHb,lstPass(iPass),iC), tHRF(:));
                        end
                        end
                    end
                    end
                end
                end