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(' %s ms' ,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