Unverified Commit c4f0a268 authored by mayucel's avatar mayucel Committed by GitHub
Browse files

Merge pull request #48 from mayucel/development

hmrR_CrossCorrelation
parents 2ca4384f eb791781
Loading
Loading
Loading
Loading
+106 KiB

File added.

No diff preview for this file type.

+87 −0
Original line number Diff line number Diff line
% SYNTAX:
% [cc, ml, cc_thresh] = hmrR_CrossCorrelation(data, cc_thresh, plot_on)
%
% UI NAME:
% hmrR_CrossCorrelation
%
% DESCRIPTION:
% This script calculates cross correlation across all channel pairs.
%
%
% INPUTS:
% data - this is the concentration data with dimensions #time points x [HbO/HbR/HbT] x #channels
% cc_thresh - cross correlation theshold, sets any correlation below cc_thresh to 0 in plots (display purpose only)
% plot_on - (1) displays cross correlation for HbO and HbR for each run; (0) no display
%
% OUTPUTS:
% cc -  cross correlation matrix
% ml -  measurement list
% cc_thresh - cross correlation theshold, sets any correlation below cc_thresh to 0 in plots (display purpose only)
%
% USAGE OPTIONS:
% hmrR_CrossCorrelation_conc: [cc, ml, cc_thresh] = hmrR_CrossCorrelation(dc, cc_thresh, plot_on)
%
% PARAMETERS:
% cc_thresh: 0.4
% plot_on: 0
%
% PREREQUISITES:
% GLM_HRF_Drift_SS_Concentration: [dcAvg, dcAvgStd, nTrials, dcNew, dcResid, dcSum2, beta, R, hmrstats] = hmrR_GLM(dc, stim, probe, mlActAuto, Aaux, tIncAuto, rcMap, trange, glmSolveMethod, idxBasis, paramsBasis, rhoSD_ssThresh, flagNuisanceRMethod, driftOrder, c_vector)


function [cc, ml, cc_thresh] = hmrR_CrossCorrelation(data, cc_thresh, plot_on)

for iBlk=1:length(data)
    y      = data(iBlk).GetDataTimeSeries('reshape');
    ml     = data(iBlk).GetMeasListSrcDetPairs();
end

% HbO
dc = squeeze(y(:,1,:));
dc = (dc-ones(length(dc),1)*mean(dc,1))./(ones(length(dc),1)*std(dc,[],1));
cc(:,:,1) = dc'*dc / length(dc);

% HbR
dc = squeeze(y(:,2,:));
dc = (dc-ones(length(dc),1)*mean(dc,1))./(ones(length(dc),1)*std(dc,[],1));
cc(:,:,2) = dc'*dc / length(dc);

%% plot

if plot_on == 1
    nch = length(ml);
    tlabel = '';
    for ii = 1:length(ml)
        tlabel = sprintf( '%s,''%c%d''',tlabel,char(64+ml(ii,1)), ml(ii,2) );
    end
    tlabel(1) = [];
    
    
    % HbO
    figure;
    
    cc0 = cc(:,:,1);
    cc0(find(abs(cc(:,:,1))<cc_thresh))=0;
    
    imagesc(cc0,[-1 1])
    colorbar
    set(gca,'xtick',[1:nch])
    set(gca,'xticklabel',eval(sprintf('{%s}', tlabel)) )
    set(gca,'ytick',[1:nch])
    set(gca,'yticklabel',eval(sprintf('{%s}', tlabel)) )
    title( 'HbO Cross-Correlation')
    
    % HbR
    figure;
    
    cc0 = cc(:,:,2);
    cc0(find(abs(cc(:,:,2))<cc_thresh))=0;
    
    imagesc(cc0,[-1 1])
    colorbar
    set(gca,'xtick',[1:nch])
    set(gca,'xticklabel',eval(sprintf('{%s}', tlabel)) )
    set(gca,'ytick',[1:nch])
    set(gca,'yticklabel',eval(sprintf('{%s}', tlabel)) )
    title( 'HbR Cross-Correlation')
end
 No newline at end of file

Homer3.log

0 → 100644
+50 −0
Original line number Diff line number Diff line

March 24, 2021, 13:27:41
Running Homer3 v1.31.2, R2019b

============
SYSTEM INFO:
============
Platform Arch  : PCWIN64
RAM Total      : 17.1 GB
RAM Free       : 6.3 GB
HD Space Total : 482.8 GB
HD Space Free  : 180.8 GB

Opened application config file C:/Users/mayucel/Documents/PROJECTS/CODES/Homer3_Meryem_fork/Homer3/AppSettings.cfg

MainGUI: March 24, 2021, 13:27:43 -  Will load group folder #1 - C:/Users/mayucel/Documents/PROJECTS/FNIRS TEST DATA/mci/Subj1/

Current GroupClass version 1.2
DataTreeClass.FindAndLoadGroups: Found 2 data files in 1 folders
Current GroupClass version 1.2

Added group Subj1 to dataTree.
   Added subject run1_seq1 to group Subj1.
     Added run run1_seq1.snirf to subject run1_seq1.
   Added subject run2_seq2 to group Subj1.
     Added run run2_seq2.snirf to subject run2_seq2.

Loaded acquisition data in 2.2 seconds

Saved group data, version 1.2 exists
Loaded data set in 3.6 seconds
Loaded saved registry C:/Users/mayucel/Documents/PROJECTS/CODES/Homer3_Meryem_fork/Homer3/FuncRegistry/UserFunctions/Registry.mat
Displaying channels [] in data blocks [1]

Logger: Chapter 1

MainGUI: March 24, 2021, 13:27:59 - Startup time - 16.1 seconds

Displaying channels [] in data blocks [1]
Processing iGroup=1, iSubj=1, iRun=1
Processing iGroup=1, iSubj=1, iRun=0
Processing iGroup=1, iSubj=2, iRun=1
Processing iGroup=1, iSubj=2, iRun=0
Processing iGroup=1, iSubj=0, iRun=0
Saving group 1 in C:/Users/mayucel/Documents/PROJECTS/FNIRS TEST DATA/mci/Subj1/groupResults.mat
Saving processed data in C:/Users/mayucel/Documents/PROJECTS/FNIRS TEST DATA/mci/Subj1/groupResults.mat
Auto-saving processing results ...
Current GroupClass version 1.2
Completed saving groupResults.mat for all groups in 1.912 seconds.
Displaying channels [] in data blocks [1]
+1 −0
Original line number Diff line number Diff line
24-Mar-2021 13:27:42