Skip to content

Commit 48c70f3

Browse files
committed
Added ability to subtract baseline/zero charge from charge calculations to findMRCs and IdAnalysis, and used in AntVPost and Velocity scripts.
1 parent f389e5c commit 48c70f3

13 files changed

Lines changed: 147 additions & 28 deletions

Analysis/SK/AnnotatedScripts/AntVsPost_VoltageAttenuation_180803.m

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,30 @@
2020

2121
strainList = {'TU2769'};
2222
internalList = {'IC2'};
23-
stimPosition = {'posterior'};
23+
stimPosition = {'anterior'};
2424

2525
wormPrep = {'dissected'};
2626
cellDist = [40 200]; % stimulus/cell distance in um
2727
resistCutoff = '<250'; % Rs < 250 MOhm
2828
extFilterFreq = 2.5; % frequency of low-pass filter for stimulus command
2929
includeFlag = 1;
3030

31-
posteriorDistCells = FilterRecordings(ephysData, ephysMetaData,...
31+
anteriorDistCells = FilterRecordings(ephysData, ephysMetaData,...
3232
'strain', strainList, 'internal', internalList, ...
3333
'stimLocation', stimPosition, 'wormPrep', wormPrep, ...
3434
'cellStimDistUm',cellDist, 'RsM', resistCutoff, ...
3535
'stimFilterFrequencykHz', extFilterFreq, 'included', includeFlag);
3636

37-
stimPosition = {'anterior'};
3837

39-
anteriorDistCells = FilterRecordings(ephysData, ephysMetaData,...
38+
39+
stimPosition = {'posterior'};
40+
41+
posteriorDistCells = FilterRecordings(ephysData, ephysMetaData,...
4042
'strain', strainList, 'internal', internalList, ...
4143
'stimLocation', stimPosition, 'wormPrep', wormPrep, ...
4244
'cellStimDistUm',cellDist, 'RsM', resistCutoff, ...
4345
'stimFilterFrequencykHz', extFilterFreq, 'included', includeFlag);
4446

45-
4647
clear cellDist strainList internalList cellTypeList stimPosition resistCutoff ans wormPrep excludeCells;
4748

4849
% This results in a file with three columns: cell ID, series, and sweeps
@@ -68,11 +69,11 @@
6869

6970
[anteriorMRCs, antStim] = IdAnalysis(ephysData,protList,anteriorDistCells,'num','matchType',matchType, ...
7071
'tauType','thalfmax', 'sortSweepsBy', sortSweeps, 'integrateCurrent',1 , ...
71-
'recParameters', ephysMetaData,'sepByStimDistance',1);
72+
'recParameters', ephysMetaData,'sepByStimDistance',1,'subZeroCharge',1);
7273

7374
posteriorMRCs = IdAnalysis(ephysData,protList,posteriorDistCells,'num','matchType',matchType, ...
7475
'tauType','thalfmax', 'sortSweepsBy', sortSweeps, 'integrateCurrent',1 , ...
75-
'recParameters', ephysMetaData,'sepByStimDistance',1);
76+
'recParameters', ephysMetaData,'sepByStimDistance',1,'subZeroCharge',1);
7677

7778
clear protList sortSweeps matchType
7879

@@ -81,20 +82,20 @@
8182
%% Correct all sizes and export for Igor fitting of Boltzmann to each recording
8283

8384
% Set the filename
84-
fname = 'PatchData/antVPost_off_allDist(181204).xls';
85+
fname = 'PatchData/antVPost_off_allDist_subQ(190215).xls';
8586

8687

8788
eachSize = [0.5 1 1.5 3 4 5 6 7 8 9 10 11 12]';
8889
distLimits = [40 200]; % limit to same average distance for anterior and posterior
8990
distCol = 12;
90-
whichStim = 1; %on or off
91+
whichStim = 2; %on or off
9192
noCorr = 0; % 1 to skip space clamp voltage attenuation correction
9293
Vc = -0.06; %in V
9394
Ena = 0.094; % in V
9495

9596

9697
whichMRCs = anteriorMRCs;
97-
dType = 'curr';
98+
dType = 'char';
9899

99100
switch dType
100101
case 'curr'
@@ -201,8 +202,9 @@
201202

202203

203204
%% Normalize based on current/charge at given step size and write to xls
205+
% Normalizes within each condition
204206

205-
stepSize = 10; % must be negative for off
207+
stepSize = -10; % must be negative for off
206208

207209
%Anterior
208210
which_Out = ant_Out;
@@ -241,8 +243,8 @@
241243

242244
%% Calculate ratios
243245
% re-save ant_Out as antOff/antOnCurr for the corresponding cases
244-
on = postOnCurr;
245-
off = postOffCurr;
246+
on = antOnCurr;
247+
off = antOffCurr;
246248
out = on(1,:);
247249

248250
onVel = [on{2:end,1}];
@@ -257,7 +259,7 @@
257259
out = out(~cellfun(@isempty,out(:,1)),:);
258260
out(1,:) = cellfun(@(x) regexprep(x,'stim1','ratio'),out(1,:),'un',0);
259261

260-
xlswrite(fname,out,['post_' dType '_Ratio']);
262+
xlswrite(fname,out,['ant_' dType '_Ratio']);
261263

262264

263265
%% Renormalize based on fit

Analysis/SK/AnnotatedScripts/Velocity_VoltageAtt_180913.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
[velocityMRCs, velocityStim] = IdAnalysis(ephysData,protList,velocityCells,'num','matchType',matchType, ...
7171
'tauType','thalfmax', 'sortSweepsBy', sortSweeps, 'integrateCurrent',1 , ...
72-
'recParameters', ephysMetaData,'sepByStimDistance',1,'pdCompare',1);
72+
'recParameters', ephysMetaData,'sepByStimDistance',1,'pdCompare',1,'subZeroCharge',1);
7373

7474
clear protList sortSweeps matchType
7575

File renamed without changes.
File renamed without changes.

Analysis/SK/IdAnalysis.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
p.addParameter('saveZero',0);
106106
p.addParameter('dropNeg',0); % if post-stimulus shift isn't being excluded as a stimulus, drop those sizes
107107
p.addParameter('sweepStats',0); % will only work with saveSweeps on.
108-
108+
p.addParameter('subZeroCharge',0);
109109
p.parse(ephysData, protList, varargin{:});
110110

111111
allCells = p.Results.allCells;
@@ -124,6 +124,7 @@
124124
saveLeak = p.Results.saveZero;
125125
dropNeg = p.Results.dropNeg;
126126
repsFlag = p.Results.sweepStats;
127+
zeroChargeFlag = p.Results.subZeroCharge;
127128

128129
baseTime = 30; % length of time (ms) to use as immediate pre-stimulus baseline
129130
smoothWindow = 5; % n timepoints for moving average window for findPeaks
@@ -637,10 +638,10 @@
637638
thisStim = repmat(stimMetaData(:,:,iStim),size(sweepsByStimProfile{iProfile},1),1);
638639
if length(sweepsByStimProfile) == 1
639640
mechPeaks{iCell,3+iStim} = findMRCs(thisStim, sweepsByStimProfile{iProfile}, sf, dataType, ...
640-
'tauType', tauType, 'integrateCurrent',integrateFlag);
641+
'tauType', tauType, 'integrateCurrent',integrateFlag, 'subZeroCharge',zeroChargeFlag);
641642
else
642643
mechPeaks{iCell,3+iStim}{iProfile} = findMRCs(thisStim, sweepsByStimProfile{iProfile}, sf, dataType, ...
643-
'tauType', tauType, 'integrateCurrent',integrateFlag);
644+
'tauType', tauType, 'integrateCurrent',integrateFlag, 'subZeroCharge',zeroChargeFlag);
644645
end
645646
end
646647
end
@@ -649,7 +650,7 @@
649650
% Find mechanoreceptor current peaks and append to seriesPeaks for
650651
% that stimulus number.
651652
mechPeaks{iCell,3+iStim} = findMRCs(stimMetaData(:,:,iStim), meansByStimProfile, sf, dataType, ...
652-
'tauType', tauType, 'integrateCurrent',integrateFlag);
653+
'tauType', tauType, 'integrateCurrent',integrateFlag, 'subZeroCharge',zeroChargeFlag);
653654
end
654655
end
655656
else
@@ -660,7 +661,7 @@
660661
% Find mechanoreceptor current peaks and append to seriesPeaks for
661662
% that stimulus number.
662663
mechPeaks{iCell,2+iStim} = findMRCs(stimMetaData(:,:,iStim), meansByStimProfile, sf, dataType, ...
663-
'tauType', tauType, 'integrateCurrent',integrateFlag);
664+
'tauType', tauType, 'integrateCurrent',integrateFlag, 'subZeroCharge',zeroChargeFlag);
664665
end
665666
end
666667

Analysis/SK/Scripts-in-progress/NonStatNoiseAnalysis.m renamed to Analysis/SK/NonStatNoiseAnalysis.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,17 @@
237237
nonStatOutput.(cellName)(whichRow).totalMean = totalMean;
238238
nonStatOutput.(cellName)(whichRow).totalVar = totalVar;
239239
nonStatOutput.(cellName)(whichRow).traces = leakSubtract(responseTime,:);
240+
nonStatOutput.(cellName)(whichRow).stimLoc = [preTime*sf+1 preTime*sf+1+stimLoc(2)-stimLoc(1)];
240241
nonStatOutput.(cellName)(whichRow).distance = thisDist;
241-
242-
243242
end
244-
243+
245244
clear thisDist;
246245
end
247246

248-
247+
% Clear empty rows
248+
nonStatOutput.(cellName) = ...
249+
nonStatOutput.(cellName)(~cellfun(@isempty,{nonStatOutput.(cellName).protocol}));
250+
249251
end
250252

251253
end
File renamed without changes.
File renamed without changes.

Analysis/SK/Scripts-in-progress/ChargeExploration.m

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,98 @@
1515
resistCutoff = '<250';
1616
extFilterFreq = [2.5 5];
1717

18-
noiseTrapCells = FilterRecordings(ephysData, ephysMetaData,...
18+
smallStepCells = FilterRecordings(ephysData, ephysMetaData,...
1919
'strain', strainList, 'internal', internalList, ...
2020
'stimLocation', stimPosition, 'wormPrep', wormPrep, ...
2121
'cellStimDistUm',cellDist, 'RsM', resistCutoff, ...
2222
'stimFilterFrequencykHz', extFilterFreq, 'included', 1);
23+
24+
clear strainList internalList stimPosition wormPrep cellDist resistCutoff extFilterFreq
25+
%% Exclusion
26+
protList ={'WCProbe1','WCProbe3','WCProbe8'};
27+
28+
matchType = 'full';
29+
30+
ExcludeSweeps(ephysData, protList, smallStepCells,'matchType',matchType);
31+
32+
%% Running noise analysis
33+
34+
protList ={'WCProbe1'};
35+
matchType = 'full';
36+
steps1 = NonStatNoiseAnalysis(ephysData,protList,smallStepCells,'matchType',matchType,...
37+
'recParameters',ephysMetaData,'responseTime',250);
38+
39+
protList ={'WCProbe3'};
40+
steps3 = NonStatNoiseAnalysis(ephysData,protList,smallStepCells,'matchType',matchType,...
41+
'recParameters',ephysMetaData,'responseTime',250);
42+
43+
44+
protList ={'WCProbe8'};
45+
steps8 = NonStatNoiseAnalysis(ephysData,protList,smallStepCells,'matchType',matchType,...
46+
'recParameters',ephysMetaData,'responseTime',250);
47+
48+
49+
clear protList matchType
50+
51+
52+
%% Calculate on/off charge for each trace of each recording
53+
whichSteps = steps1;
54+
theseNames = fieldnames(whichSteps);
55+
peaks = cell(0);
56+
charges = cell(0);
57+
cellPeaks = cell(0);
58+
peakRatios = cell(0);
59+
chargeRatios = cell(0);
60+
sf = 5; %khz
61+
dataType = 'A';
62+
tauType = 'thalfmax';
63+
integrateFlag = 1;
64+
65+
for iCell = 1:length(theseNames)
66+
cellName = theseNames{iCell};
67+
for iSeries = 1:2
68+
theseTraces(:,:,iSeries) = whichSteps.(cellName)(iSeries).traces';
69+
stimParams = [whichSteps.(cellName)(iSeries).stimLoc, whichSteps.(cellName)(iSeries).size, ...
70+
whichSteps.(cellName)(iSeries).size, whichSteps.(cellName)(iSeries).position, ...
71+
whichSteps.(cellName)(iSeries).velocity, 1, whichSteps.(cellName)(iSeries).distance];
72+
stimParams = repmat(stimParams,size(theseTraces,1),1);
73+
74+
cellPeaks{iCell,iSeries} = findMRCs(stimParams, theseTraces(:,:,iSeries), sf, dataType, ...
75+
'tauType', tauType, 'integrateCurrent',integrateFlag,'threshTime',15);
76+
end
77+
peaks{iCell}(:,1) = cellPeaks{iCell,1}(:,6);
78+
peaks{iCell}(:,2) = cellPeaks{iCell,2}(:,6);
79+
charges{iCell}(:,1) = cellPeaks{iCell,1}(:,7);
80+
charges{iCell}(:,2) = cellPeaks{iCell,2}(:,7);
81+
peakRatios{iCell} = cellPeaks{iCell,2}(:,6)./cellPeaks{iCell,1}(:,6);
82+
chargeRatios{iCell} = cellPeaks{iCell,2}(:,7)./cellPeaks{iCell,1}(:,7);
83+
end
84+
85+
% Pad and concatenate for Igor assuming max length is 64 sweeps
86+
for i = 1:length(peakRatios)
87+
peakRatios{i} = vertcat(peakRatios{i}, nan(64-length(peakRatios{i}),1));
88+
chargeRatios{i} = vertcat(chargeRatios{i}, nan(64-length(chargeRatios{i}),1));
89+
peaks{i} = vertcat(peaks{i}, nan(64-length(peaks{i}),2));
90+
charges{i} = vertcat(charges{i}, nan(64-length(charges{i}),2));
91+
end
92+
peakRatioCat = [peakRatios{:}]';
93+
chargeRatioCat = [chargeRatios{:}]';
94+
95+
peakCat = [];
96+
chargeCat = [];
97+
for i = 1:2
98+
a = [peaks{:}];
99+
peakCat(:,:,i) = a(:,i:2:end);
100+
a = [charges{:}];
101+
chargeCat(:,:,i) = a(:,i:2:end);
102+
end
103+
104+
%%
105+
figure();
106+
for i = 1:2
107+
subplot(1,2,i);
108+
plot((theseTraces(:,:,iSeries)+repmat(offset',1,1328))')
109+
vline(76)
110+
xlim([0 1000]);
111+
ylim([-70e-11,.5e-11]);
112+
end
File renamed without changes.

0 commit comments

Comments
 (0)