2323%%
2424sinePeaksNorm = FrequencyAnalysis(ephysData , ephysMetaData , protList , ' matchType' , matchType , ' norm' , 1 );
2525
26+ % okay we're just going to plot the power spectrum in the morning and
27+ % ignore the bode plot because I don't know what a "system" object really
28+ % is in matlab or if my data can be one, or what a linear time-invariant
29+ % system is or why a Bode plot is useful
30+ %%
31+ eachFreq = [0 10 30 100 200 500 1000 ];
32+ sf = 10000 ; % Hz
33+ allPSD = [];
34+ allF = [];
35+ allSize = [];
36+
37+ for iRec = 1 : size(sinePeaksNorm ,1 )
38+ theseRecs = sinePeaksNorm{iRec ,2 };
39+ theseSizes = sinePeaksNorm{iRec ,3 }(: ,1 : 3 );
40+
41+ for iFreq = 1 : length(theseRecs )
42+ try thisRec = theseRecs{iFreq }(theseSizes(iFreq ,1 ): theseSizes(iFreq ,2 ),: );
43+ [pxx ,f ] = periodogram(thisRec ,[],[],sf );
44+ allF = [allF mean(f ,2 )];
45+ allPSD = [allPSD mean(pxx ,2 )];
46+ allSize = [allSize theseSizes(iFreq ,3 )];
47+ catch
48+ end
49+ end
50+
51+ end
52+
53+ [sortedSize , sortIdx , eachStimProfile , profileStartIdx , profileEndIdx ] = ...
54+ sortRowsTol(allSize ' , 1 , 1 );
55+
56+ sortedPSD = allPSD(: ,sortIdx );
57+ meanF = allF(: ,1 );
58+ groupIdx = cell(0 );
59+ meansByFreq = [];
60+
61+ for iProfile = 1 : length(eachFreq )
62+ groupIdx{iProfile } = profileStartIdx(iProfile ): profileEndIdx(iProfile );
63+ thesePSD = sortedPSD(: ,groupIdx{iProfile });
64+ meansByFreq (: ,iProfile ) = mean(thesePSD ,2 );
65+ end
66+
67+ plot(meanF ,10 * log10(meansByFreq ));
68+ xlabel(' frequency (Hz)' );
69+ ylabel(' dB' );
70+ legend(num2str(eachFreq ' ));
71+ box off ;
72+ % plotfixer;
73+
74+ chH = get(gca ,' children' );
75+ set(gca ,' children' ,flipud(chH ));
0 commit comments