Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

%% MODULE 3 %% SECTION 1: Bandpass filter the spike data % extract data from EEG structure data = load( 'spikes.mat' ); % data is

%% MODULE 3

%% SECTION 1: Bandpass filter the spike data

% extract data from EEG structure

data = load( 'spikes.mat' );

% data is a variable that contains both 'Data' and 'fs'

fs = 22321.428;

% create timestamps

ts = linspace( 0, length( data.data ) / fs, length( data.data ) );

% TODO: Fill in lowpass and highpass frequencies

fl = 244;

fh = 6104;

% bandpass filter the recorded spike data

fdata = bpf( data.data, fl, fh, fs );

figure();

titles = { 'RAW SPIKES', sprintf( 'BPF SPIKES (%.2f - %.2f Hz)', fl, fh ) };

for i = 1:2

if i == 1

signal = data.data;

else

signal = fdata;

end

signal_length = length( signal ); % calculate the signal length

signal = detrend( signal ); % remove the linear trend of the signal

fft_length = 2 ^ nextpow2( signal_length ); % compute the next power of 2 from the signal length

% compute the FFT of the input signal

Y = fft( signal, fft_length ) / signal_length; % the FFT of the spike channel

f = fs / 2 * linspace( 0, 1, fft_length / 2 ); % the frequency range of the single-sided FFT

% plot the single-sided FFT

subplot( 2, 2, i )

plot( f, 2 * abs( Y(1:fft_length/2) ) );

xlabel( 'Frequency (Hz)' );

ylabel( '|Y(f)|' );

title( titles{ i } );

% plot the first 0.5 sec of time-series signal

idx = round( 0.5 * fs );

subplot( 2, 2, i + 2 );

plot( ts(1:idx), signal(1:idx) );

xlim( [ 0, ts(idx) ] );

xlabel( 'Time (s)' );

ylabel( 'Voltage (uV)' );

end

%% SECTION 2: Compute the nonlinear energy operator (NEO) to the recording data

% TODO: Implement the nonlinear energy operator in a function called 'neo'

neodata = neo( fdata );

% plot the first 1.0 sec of the NEO signal

idx = round( 1.0 * fs );

plot( ts(1:idx), neodata(1:idx) );

xlabel( 'Time (s)' );

ylabel( 'NEO (uV^2)' );

title( 'NEO of Filtered Signal' );

INSTRUCTIONS: Implement the nonlinear energy operator in a function called 'neo' (created in a neo.m file) in the TODO section using the template below:

function y = neo( x )

% @param x : the input neural data [num_samples 1]

% @return y : the NEO transformed data [num_samples 1]

return

end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Physics For Scientists And Engineers With Modern Physics

Authors: Raymond A. Serway, John W. Jewett

9th Edition

1133954057, 978-1133954057

More Books

Students also viewed these Physics questions

Question

What is commercial substance?

Answered: 1 week ago

Question

What is Bacons approach to scientific methodology?

Answered: 1 week ago