<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hi Grant,<DIV><BR class="khtml-block-placeholder"></DIV><DIV><DIV><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Pardon me if I missed it, but are there functions in FT for computing Spectral Edge, Medium and Dominant Frequency for a data trial?</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If not, perhaps someone knows of an implementation of such algorithms somewhere else?</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>As far as I am aware, there are no direct functions in Fieldtrip for extracting these measures from power spectra (since this sort of approach to spectral analysis is a tad more reductionist that is useful for most FT purposes). There is also nothing in the Signal Processing Toolbox, since this has mainly to do with spectral estimation as such, filter design, prediction, etc ...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>However, computing these measures is quite straightforward in matlab assuming you have the power spectum of the data (The matlab help for FFT tells you how to compute the power spectrum in a few simple lines, which you can turn into your own function). The following is only pseudo/outline code for a little function to get median, spectral edge and dominant frequencies:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>function [mf, sef, df] = specstats(freq, pyy) </DIV><DIV>% your frequency axis is freq (a vector)</DIV><DIV>% your power spectrum is pyy (a vector)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>% normalize spectrum to get a density</DIV><DIV>pyy_norm = pyy./sum(pyy);</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>% compute cumulative density</DIV><DIV>pyy_cum = cumsum(pyy_norm);</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>% median frequency corresponds to the frequency at (nearest to) </DIV><DIV>% the point on the freq axis where pyy_cum = 0.5</DIV><DIV>[val, idx] = min(abs(pyy_cum-0.5));</DIV><DIV>mf = freq(idx);</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>% spectral edge frequency corresponds to the frequency at (nearest to)</DIV><DIV>% the point on the freq axis where pyy_cum = 0.05</DIV><DIV>[val, idx] = min(abs(pyy_cum-0.05));</DIV><DIV>sef = freq(idx);</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>% you can extend this code for dominant frequency accordingly ... if all you mean </DIV><DIV>% is the peak frequency then you have</DIV><DIV>[val, idx] = max(pyy);</DIV><DIV>df = freq(idx);</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Depending on how sophisticated you want to get you can apply a bit of interpolation to pyy as well, but that is probably overkill.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I hope that helps</DIV><DIV>Christian</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>----------------------------------------------------------------------</DIV><DIV>Christian Hesse, PhD, MIEEE</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">F.C. Donders Centre for Cognitive Neuroimaging </DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">P.O. Box 9101 </DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">NL-6500 HB Nijmegen </DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The Netherlands</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Tel.: +31 (0)24 36 68293</DIV><DIV>Fax: +31 (0)24 36 10989</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Email: <A href="mailto:c.hesse@fcdonders.ru.nl">c.hesse@fcdonders.ru.nl</A></DIV><DIV>Web: <A href="http://www.fcdonders.ru.nl">www.fcdonders.ru.nl</A></DIV><DIV>----------------------------------------------------------------------</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "></SPAN><BR class="Apple-interchange-newline"></SPAN></SPAN></SPAN></SPAN></SPAN> </DIV><BR></DIV></BODY></HTML>