-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgetBurstLengthRealData.m
60 lines (50 loc) · 3.02 KB
/
getBurstLengthRealData.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [burstLengthCGT,burstLengthFeingold,burstLengthMP,burstLengthWT,burstLengthHilbert,diffPower,freqListCGT,freqListMP,freqListWT,modListMP]=getBurstLengthRealData(subjectName,expDate,protocolName,electrodeNum,thresholdFraction,cVal,gammaFreqRangeHz,runMPAnalysisFlag)
if ~exist('runMPAnalysisFlag','var'); runMPAnalysisFlag=1; end
gridType = 'Microelectrode';
folderSourceString = '';
stimulusPeriodS=[0.5 2];
baselinePeriodS=[-1.5 0];
% CGT and Feingold and Hilbert
cgtGaborSD = 25/1000;
filterOrder=4;
% MP
maxIteration=50;
adaptiveDictionaryParam=0.9;
dictionarySize=2500000;
% Get Data
folderName = fullfile(folderSourceString,'data',subjectName,gridType,expDate,protocolName,'segmentedData','LFP');
st = load(fullfile(folderName,['elec' num2str(electrodeNum) 'c' num2str(cVal) '.mat']));
analogData = st.analogData;
t = load(fullfile(folderName,'lfpInfo.mat'));
timeVals = t.timeVals;
% Compute Threshold
diffPower = getChangeInPower(analogData,timeVals,stimulusPeriodS,baselinePeriodS,gammaFreqRangeHz);
thresholdFactor = diffPower*thresholdFraction;
% Get Burst lengths using CGT, Wavelet, Feingold and Hilbert
[burstLengthCGT,freqListCGT] = getBurstLengthCGT(analogData,timeVals,thresholdFactor,0,stimulusPeriodS,baselinePeriodS,gammaFreqRangeHz,cgtGaborSD);
[burstLengthWT,freqListWT] = getBurstLengthWavelet(analogData,timeVals,thresholdFactor,0,stimulusPeriodS,baselinePeriodS,gammaFreqRangeHz);
burstLengthFeingold = getBurstLengthFeingold(analogData,timeVals,thresholdFactor,0,stimulusPeriodS,baselinePeriodS,gammaFreqRangeHz,filterOrder);
burstLengthHilbert = getBurstLengthHilbert(analogData,timeVals,thresholdFactor,0,stimulusPeriodS,baselinePeriodS,gammaFreqRangeHz,filterOrder);
if runMPAnalysisFlag
% Save MP results
folderNameMain = fullfile('data',subjectName,gridType,expDate,protocolName);
tag = ['elec' num2str(electrodeNum) 'c' num2str(cVal)];
% Output folder
outputFolder = fullfile(folderNameMain,'mpAnalysis',tag);
makeDirectory(outputFolder);
% Save gaborInfo as a mat file
gaborInfoFile = fullfile(outputFolder,['gaborInfo_G' num2str(gammaFreqRangeHz(1)) '-' num2str(gammaFreqRangeHz(2)) '_M' num2str(maxIteration) ...
'_D' num2str(100*adaptiveDictionaryParam) '_R' num2str(dictionarySize) '_S' num2str(1000*stimulusPeriodS(1)) '-' num2str(1000*stimulusPeriodS(2)) '.mat']);
if exist(gaborInfoFile,'file')
disp(['Opening saved file ' gaborInfoFile]);
load(gaborInfoFile);
[burstLengthMP,freqListMP,~,~,~,modListMP] = getBurstLengthMP(analogData,timeVals,sqrt(thresholdFactor),0,stimulusPeriodS,baselinePeriodS,gammaFreqRangeHz,maxIteration,adaptiveDictionaryParam,dictionarySize,gaborInfo,header);
else
[burstLengthMP,freqListMP,~,gaborInfo,header,modListMP] = getBurstLengthMP(analogData,timeVals,sqrt(thresholdFactor),0,stimulusPeriodS,baselinePeriodS,gammaFreqRangeHz,maxIteration,adaptiveDictionaryParam,dictionarySize);
save(gaborInfoFile,'gaborInfo','header');
end
else
burstLengthMP=[];
freqListMP=[];
end
end