Skip to content

Commit ae64335

Browse files
committed
fixed ExcludeSweeps to include cell id in output. AnalyzePatchData import cleans up the messed up names
1 parent 162bb89 commit ae64335

3 files changed

Lines changed: 96 additions & 1 deletion

File tree

Analysis/SK/AnalyzePatchData.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919
projects = {'FAT';'SYM'};
2020
% projects = {'SAR','FAT'};
2121

22+
%fix a couple messed up names
23+
ephysData.FAT029 = ephysData.FAT029s;
24+
ephysData.FAT017 = ephysData.FAT017e001;
25+
ephysData.FAT164 = ephysData.FAT164001;
26+
ephysData = rmfield(ephysData,{'FAT017e001';'FAT029s';'FAT164001'});
2227

28+
%get rid of the crap/unrelated recordings
2329
ephysData = FilterProjectData(ephysData, projects);
2430

2531
clear projects;

Analysis/SK/ExcludeSweeps.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
sweepsTxt = sweepsTxt(1:end-1); % trim last comma
203203
sweepsTxt = horzcat('''',sweepsTxt); % prepend ' to force xls text format
204204

205-
selectedSweeps{totSeries,1}=keepCells(iCell);
205+
selectedSweeps{totSeries,1}=keepCells{iCell};
206206
selectedSweeps{totSeries,2}=keepProts{iCell}(iSeries);
207207
selectedSweeps{totSeries,3}=sweepsTxt;
208208

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
%PreIndentNoiseAnalysis.m
2+
3+
4+
strainList = {'TU2769'};
5+
internalList = {'IC6'};
6+
stimPosition = {'anterior'};
7+
8+
wormPrep = {'dissected'};
9+
cellDist = [40 100];
10+
resistCutoff = '<251';
11+
extFilterFreq = [2.5 5];
12+
13+
noisePreCells = FilterRecordings(ephysData, ephysMetaData,...
14+
'strain', strainList, 'internal', internalList, ...
15+
'stimLocation', stimPosition, 'wormPrep', wormPrep, ...
16+
'cellStimDistUm',cellDist, 'RsM', resistCutoff, ...
17+
'stimFilterFrequencykHz', extFilterFreq);
18+
19+
noisePreCells = {'FAT231','FAT232','FAT233','FAT234','FAT235'};
20+
21+
%% Exclusion
22+
protList ={'NoisePre','WC_Probe'};
23+
24+
matchType = 'first';
25+
26+
ExcludeSweeps(ephysData, protList, testCell,'matchType',matchType);
27+
%TODO: Upgrade ExcludeSweeps to allow passing in an existing list, then
28+
%check recording name/series number against it and skip (if overWriteFlag)
29+
%if it's already been vetted. Add new recordings to the end of the list,
30+
%sortrows (and maybe check unique/warn which rows have multiple) and save
31+
%as new file.
32+
33+
%% Running analysis
34+
35+
noisePre = NonStatNoiseAnalysis(ephysData,protList,noisePreCells,'matchType',matchType);
36+
clear protList matchType
37+
38+
%% Turn data into tables for Igor
39+
40+
%Get protocol name parts and means/variances for each recording
41+
preRecs = fieldnames(noisePre);
42+
recNames = cell(0); % name of cell
43+
protNames = cell(0); % name of protocol
44+
stimNames = cell(0); % number of stim (e.g., 1=on, 2=off) as string
45+
totMeans = cell(0);
46+
totVars = cell(0);
47+
48+
for iRec = 1:length(preRecs);
49+
%get rid of empty rows, which mess with sorting strings later
50+
clearEmpty = arrayfun(@(s) isempty(s.protocol),noisePre.(preRecs{iRec}));
51+
noisePre.(preRecs{iRec})(clearEmpty)=[];
52+
53+
theseStim = cellfun(@(x) sprintf('stim%d',x),...
54+
num2cell([noisePre.(preRecs{iRec})(:).stimNum]),'un',0);
55+
56+
stimNames = [stimNames theseStim];
57+
protNames = [protNames vertcat({noisePre.(preRecs{iRec})(:).protocol})];
58+
totMeans = [totMeans vertcat({noisePre.(preRecs{iRec})(:).totalMean})];
59+
totVars = [totVars vertcat({noisePre.(preRecs{iRec})(:).totalVar})];
60+
recNames = [recNames repmat(preRecs(iRec),1,length(noisePre.(preRecs{iRec})))];
61+
end
62+
63+
[protNames, protIdx] = sort(protNames);
64+
totMeans = totMeans(protIdx);
65+
totVars = totVars(protIdx);
66+
recNames = recNames(protIdx);
67+
stimNames = stimNames(protIdx);
68+
69+
% Pad with nans and turn means/vars into arrays
70+
meanLengths = cellfun('length',totMeans);
71+
maxLength = max(meanLengths);
72+
totMeans = cellfun(@(x)cat(1,x,NaN(maxLength-length(x),1)),totMeans,'UniformOutput',false);
73+
totMeans = cell2mat(totMeans);
74+
totVars = cellfun(@(x)cat(1,x,NaN(maxLength-length(x),1)),totVars,'UniformOutput',false);
75+
totVars = cell2mat(totVars);
76+
77+
protTimes = cellfun(@(x) sprintf('%sms',x(isstrprop(x,'digit'))), protNames,'un',0);
78+
79+
% Create identifying wave names for Igor
80+
waveMeanNames = cellfun(@(x,y,z) sprintf('mean_%s_%s_%s', x, y,z), protTimes, stimNames, recNames, 'un',0);
81+
waveVarNames = cellfun(@(x,y,z) sprintf('var_%s_%s_%s', x, y,z), protTimes, stimNames, recNames, 'un',0);
82+
83+
84+
% write into Excel file for loading into Igor
85+
xlswrite('PatchData/testTrap.xls',waveMeanNames,'means');
86+
xlswrite('PatchData/testTrap.xls',totMeans,'means','A2');
87+
88+
xlswrite('PatchData/testTrap.xls',waveVarNames,'vars');
89+
xlswrite('PatchData/testTrap.xls',totVars,'vars','A2');

0 commit comments

Comments
 (0)