import os, h5py, wave, struct
import numpy as  np

###############################################################################
# TODO: here are the functions that you need to write
def todo_lpf(nsamps, omegaL):
    '''
    Create a Hamming-windowed lowpass filter with cutoff omegaL radians/second, length nsamps.
    Your code can use np.sinc and np.hamming, but notice that np.sinc uses unusual arguments.
    
    Input: 
    nsamps = length of the filter (an even number)
    omegaL = cutoff frequency, in radians/sample
    
    Output: 
    h = impulse respose of a LPF with those parameters, 
    computed by multiplying a Hamming window times a delayed ideal LPF.
    '''
    raise NotImplementedError("You need to write this!")
    
def todo_h_theta(sfreq, filterlength):
    '''
    Input:
    sfreq (scalar): sampling frequency, samples per second
    filterlength (scalar): length of the filter, in seconds
    Output:
    h_theta: impulse response of a lowpass filter that retains the theta and delta bands
     (all bands below 7Hz), computed using todo_lpf_even or todo_lpf_odd,
    depending on whether filterlength turns out to be an odd or even number of samples.
    '''
    raise NotImplementedError("You need to write this!")

def todo_convolve(data, h):
    '''
    Input:
    data (nchannels,nsamps): nchannels different time-domain signals, each nsamps long
    h (filterlength): impulse response of the filter
    Output
    filtered (nchannels,nsamps+filterlength-1): results of filtering each row of data by h
    '''
    raise NotImplementedError("You need to write this!")

def todo_h_alpha(sfreq, filterlength):
    '''
    Input:
    sfreq (scalar): sampling frequency, samples per second
    filterlength (scalar): length of the filter, in samples
    Output:
    h_alpha: impulse response of a bandpass filter that retains only the alpha bands
     (7-15Hz), computed by wisely making use of either todo_lpf_even or todo_lpf_odd,
    depending on whether filterlength turns out to be an odd or even number of samples.
    '''
    raise NotImplementedError("You need to write this!")

def todo_h_beta(sfreq, filterlength):
    '''
    Input:
    sfreq (scalar): sampling frequency, samples per second
    filterlength (scalar): length of the filter, in samples
    Output:
    h_beta: impulse response of a bandpass filter that retains only the beta bands
     (15-30H),  computed by wisely making use of either todo_lpf_even or todo_lpf_odd,
    depending on whether filterlength turns out to be an odd or even number of samples.
    '''
    raise NotImplementedError("You need to write this!")

def todo_h_gamma(sfreq, filterlength):
    '''
    Input:
    sfreq (scalar): sampling frequency, samples per second
    filterlength (scalar): length of the filter, in samples
    Output:
    h_theta: impulse response of a highpass filter that retains only the gamma bands
     (above 30Hz),  computed by wisely making use of either todo_lpf_even or todo_lpf_odd,
    depending on whether filterlength turns out to be an odd or even number of samples.
    The following information was not covered in lecture:
    If you need an even number of samples, construct a bandpassfilter insted of a highpass
    filter, but with an upper cutoff frequency of omegaL=pi.
    '''
    raise NotImplementedError("You need to write this!")
