Home > BauerLab > MATLAB > lib > +mouse > +conn > regionalLag.m

regionalLag

PURPOSE ^

regionalFC finds the connectivity of the ROI with the rest

SYNOPSIS ^

function [lagDataTime, lagDataAmp] = regionalLag(data,mask,fRange,sR,roi,validInd,edgeLen,corrThr)

DESCRIPTION ^

 regionalFC finds the connectivity of the ROI with the rest
   inputs:
       data = 3D matrix. (spatial x spatial x time)
       roi = indices of the roi
       validInd = valid indices at which lag time is justified. cell array

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [lagDataTime, lagDataAmp] = regionalLag(data,mask,fRange,sR,roi,validInd,edgeLen,corrThr)
0002 % regionalFC finds the connectivity of the ROI with the rest
0003 %   inputs:
0004 %       data = 3D matrix. (spatial x spatial x time)
0005 %       roi = indices of the roi
0006 %       validInd = valid indices at which lag time is justified. cell array
0007 
0008 lagDataTime = [];
0009 lagDataAmp = [];
0010 for freq = 1:size(fRange,1)
0011     fMin = fRange(freq,1);
0012     fMax = fRange(freq,2);
0013     
0014     %% spectral filter
0015     filtData = zeros(size(data));
0016     % for each spatial and species
0017     for spatDim1 = 1:size(data,1)
0018         for spatDim2 = 1:size(data,2)
0019             ind = [1 size(data,3)];
0020             % select the data. Edges are considered to reduce edge effects.
0021             edgeLength = round(sR/fMin/2); % consider at least half the wavelength
0022             [selectedData, realInd, ~] = mouse.freq.selectWithEdges(squeeze(data(spatDim1,spatDim2,:)),ind,edgeLength);
0023             
0024             % filter
0025             filtDataTemp = highpass(selectedData,fMin,sR);
0026             filtDataTemp = lowpass(filtDataTemp,fMax,sR);
0027             filtDataTemp = filtDataTemp(realInd(1):realInd(2));
0028             
0029             filtData(spatDim1,spatDim2,:) = filtDataTemp;
0030         end
0031     end
0032     
0033     %% fc
0034     filtData = reshape(filtData,size(filtData,1)*size(filtData,2),size(filtData,3));
0035     roiData = nanmean(filtData(roi,:),1)';
0036     lagDataTimeFreq = nan(size(data,1),size(data,2));
0037     lagDataAmpFreq = nan(size(data,1),size(data,2));
0038     for i = 1:size(filtData,1)
0039         if mask(i)
0040             data2 = filtData(i,:)';
0041             [lagDataTimeFreq(i), lagDataAmpFreq(i)] = mouse.freq.findLag(roiData,data2,true,false,validInd{freq},edgeLen,corrThr);
0042         end
0043     end
0044     lagDataTimeFreq = lagDataTimeFreq./sR;
0045     lagDataTime = cat(3,lagDataTime,lagDataTimeFreq);
0046     lagDataAmp = cat(3,lagDataAmp,lagDataAmpFreq);
0047 end
0048 end

Generated on Fri 28-Dec-2018 21:42:50 by m2html © 2005