|
20 | 20 | p.addParameter('tauType','thalfmax', @(x) ischar(x) && ismember(x,{'fit' 'thalfmax'})); |
21 | 21 | p.addParameter('integrateCurrent',1); |
22 | 22 | p.addParameter('normToOn1',0); |
23 | | -p.addParameter('matchPhase',0'); |
| 23 | +p.addParameter('matchPhase',0); |
| 24 | +p.addParameter('channel',1, @(x) isnumeric(x) && ismember(x,1:6)); |
24 | 25 |
|
25 | 26 | p.parse(ephysData, ephysMetaData, protList, varargin{:}); |
26 | 27 |
|
|
30 | 31 | integrateFlag = p.Results.integrateCurrent; |
31 | 32 | normalizeFlag = p.Results.normToOn1; |
32 | 33 | phaseFlag = p.Results.matchPhase; |
| 34 | +channel = p.Results.channel; |
33 | 35 |
|
34 | 36 | % Load and format Excel file with lists (col1 = cell name, col2 = series number, |
35 | 37 | % col 3 = comma separated list of good traces for analysis) |
|
52 | 54 | sortStimBy = 'time'; |
53 | 55 | sortSweepsBy = {'frequency'}; |
54 | 56 | stimSortOrder = [1 2]; |
| 57 | +sqWindow = 5; |
55 | 58 |
|
56 | 59 | % pull cell distances and filter freqs |
57 | 60 | allCellInd = cellfun(@(x) find(strcmp(ephysMetaData(:,1),x)),allCells,'un',0)'; |
|
83 | 86 | end |
84 | 87 |
|
85 | 88 | % Initialize for allSeries |
86 | | - allLeakSub = cell(0); |
| 89 | + allLeakSub = cell(nSeries,1); |
87 | 90 | allSweeps = cell(nSeries,2); |
88 | 91 | allSine = cell(0); |
89 | 92 | stimSquareSum = []; |
|
102 | 105 | catch |
103 | 106 | end |
104 | 107 |
|
| 108 | + probeI = ephysData.(cellName).data{channel,thisSeries}(:,pickedTraces); |
| 109 | + |
105 | 110 |
|
106 | | - probeI = ephysData.(cellName).data{1,thisSeries}(:,pickedTraces); |
107 | 111 | stimComI = ephysData.(cellName).data{2,thisSeries}(:,pickedTraces); %in V, not um |
108 | 112 | % sampling frequency in kHz |
109 | 113 | sf = ephysData.(cellName).samplingFreq{thisSeries} ./ 1000; |
|
151 | 155 |
|
152 | 156 | sineTrace = leakSubtract(sineParams(1):sineParams(2)); |
153 | 157 |
|
154 | | - % Take the average current of the last steadyTime ms of the |
155 | | - % sine trace, regardless of sine frequency. |
156 | | - steadyStateI = -mean(sineTrace(end-steadyTime*sf:end))*1e12; |
| 158 | + if channel == 1 % to units of pA |
| 159 | + % Take the average current of the last steadyTime ms of the |
| 160 | + % sine trace, regardless of sine frequency. |
| 161 | + steadyStateI = -mean(sineTrace(end-steadyTime*sf:end))*1e12; |
| 162 | + |
| 163 | + else % original units |
| 164 | + steadyStateI = mean(sineTrace(end-steadyTime*sf:end)); |
| 165 | + end |
157 | 166 |
|
158 | 167 | theseSines = [sineParams steadyStateI thisSeries]; |
159 | 168 | % Implement later: use fit to calculate time constant of decay from peak |
|
171 | 180 |
|
172 | 181 |
|
173 | 182 | % Find MRC peaks at the on and off of square stimuli. |
174 | | - theseSquares = []; |
175 | | - for iStim = 1:size(squareParams,1) |
176 | | - theseSquares(iStim,:) = findMRCs(squareParams(iStim,:), leakSubtract, sf, dataType, ... |
177 | | - 'tauType', tauType, 'integrateCurrent',integrateFlag); |
| 183 | + theseSquares = nan(4,13); %adjust this if you change findMRCs output |
| 184 | + |
| 185 | + if channel == 1 |
| 186 | + for iStim = 1:size(squareParams,1) |
| 187 | + theseSquares(iStim,:) = findMRCs(squareParams(iStim,:), leakSubtract, sf, dataType, ... |
| 188 | + 'tauType', tauType, 'integrateCurrent',integrateFlag); |
| 189 | + end |
| 190 | + |
| 191 | + else % just find the actual voltage at the start and end of each step |
| 192 | + theseSquareAmps = nan(4,1); |
| 193 | + for iStim = 1:size(squareParams,1) |
| 194 | + if squareParams(iStim, 3) >= 0 |
| 195 | + theseSquareAmps(iStim) = mean(leakSubtract(squareParams(iStim,1)+sf:squareParams(iStim,1)+sqWindow*sf*2)); |
| 196 | + else |
| 197 | + theseSquareAmps(iStim) = mean(leakSubtract(squareParams(iStim,1)-sqWindow*sf:squareParams(iStim,1))); |
| 198 | + end |
| 199 | + end |
| 200 | + theseSquares(:,1:4) = squareParams(:,3:6); |
| 201 | + theseSquares(:,5:6) = [squareParams(:,1) theseSquareAmps]; |
| 202 | + theseSquares(:,13:14) = squareParams(:,7:8); |
178 | 203 | end |
| 204 | + |
179 | 205 | theseSquares = [theseSquares repmat(sineParams(4),iStim,1) repmat(thisSeries,iStim,1)]; |
180 | 206 |
|
181 | | - |
182 | 207 | %TODO: add to Sine output: peak at start, beginning average, tau of |
183 | 208 | % fit of smoothed trace |
184 | 209 | %TODO: add to SquareSum output: interval between squares, and |
|
214 | 239 |
|
215 | 240 | allSineSum = vertcat(allSweeps{:,1}); |
216 | 241 | allSquareSum = vertcat(allSweeps{:,2}); |
| 242 | + allLeakSub = allLeakSub(~cellfun(@isempty,allLeakSub)); |
217 | 243 | for iStim = 1:max(allSquareSum(:,13)) |
218 | 244 | stimSquareSum(:,:,iStim) = allSquareSum(allSquareSum(:,13)==iStim,:); |
219 | 245 | end |
|
272 | 298 | % stimSortOrder. Use unique to find unique sets of rows/stimulus |
273 | 299 | % profiles and separate them into groups. |
274 | 300 | [sweepsByParams, sortIdx] = sortrows(sweepsByParams, stimSortOrder(1:size(sweepsByParams,2))); |
275 | | - sortedLeakSub = allLeakSub(sortIdx,:); |
| 301 | + sortedLeakSub = allLeakSub(sortIdx); |
276 | 302 | sortedSquares = stimSquareSum(sortIdx,:,:); |
277 | 303 |
|
278 | 304 | for iStim = 1:nStim |
|
345 | 371 |
|
346 | 372 | if normalizeFlag |
347 | 373 | steadyMeans = steadyMeans./squareMeans(:,1); |
348 | | - normMeans = num2cell(squareMeans(:,1)*1e-12); |
| 374 | + if channel == 1 |
| 375 | + normMeans = num2cell(squareMeans(:,1)*1e-12); |
| 376 | + else |
| 377 | + normMeans = num2cell(squareMeans(:,1)); |
| 378 | + end |
349 | 379 | theseSweeps = cellfun(@(x,y) x/y, theseSweeps,normMeans','un',0); |
350 | 380 | end |
351 | 381 |
|
|
0 commit comments