multitaper_spectrogram_release

multitaper_spectrogram_release(varargin)

MULTITAPER_SPECTROGRAM Compute the multitaper spectrogram for time series data

This version has extensive commenting for release compatibility.

Usage: Direct input: [spect,stimes,sfreqs] = multitaper_spectrogram(data, Fs, frequency_range, taper_params, window_params, min_NFFT, detrend_opt, plot_on, verbose)

Input: data: 1 x <number of samples> vector - time series data– required Fs: double - sampling frequency in Hz – required frequency_range: 1x2 vector - [<min frequency>, <max frequency>] (default: [0 nyquist]) taper_params: 1x2 vector - [<time-halfbandwidth product>, <number of tapers>] (default: [5 9]) window_params: 1x2 vector - [window size (seconds), step size (seconds)] (default: [5 1]) detrend_opt: string - detrend data window (‘linear’ (default), ‘constant’, ‘off’); min_NFFT: double - minimum allowable NFFT size, adds zero padding for interpolation (closest 2^x) (default: 0) plot_on: boolean to plot results (default: true) verbose: boolean to display spectrogram properties (default: true)

Output: spect: FxT matrix of spectral power stimes: 1XT vector of times for the center of the spectral bins sfreqs: 1XF vector of frequency bins for the spectrogram

Example:

Fs=200; %Sampling Frequency frequency_range=[0 25]; %Limit frequencies from .5 to 25 Hz taper_params=[3 5]; %Time bandwidth and number of tapers window_params=[4 1]; %Window size is 4s with step size of 1s

%Generate sample chirp data t=1/Fs:1/Fs:600; %Create 10 minutes of data f_start=1;f_end=20; % Set chirp range in Hz data=chirp(t,f_start,t(end),f_end,’logarithmic’);

%Compute the multitaper spectrogram [spect,stimes,sfreqs] = multitaper_spectrogram(data,Fs,frequency_range, taper_params, window_params);

This code is companion to the paper:

“Sleep Neurophysiological Dynamics Through the Lens of Multitaper Spectral Analysis” Michael J. Prerau, Ritchie E. Brown, Matt T. Bianchi, Jeffrey M. Ellenbogen, Patrick L. Purdon December 7, 2016 : 60-92 DOI: 10.1152/physiol.00062.2015

which should be cited for academic use of this code.

A full tutorial on the multitaper spectrogram can be found at: http://www.sleepEEG.org/multitaper

Copyright 2019 Michael J. Prerau, Ph.D. - http://www.sleepEEG.org This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. (http://creativecommons.org/licenses/by-nc-sa/4.0/)

Last modified 1/11/2019