<jupyter_start><jupyter_text>Spatiotemporal Energy ModelAcelson & Bergen 1984<jupyter_code>import numpy as np
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Spatial Filters: 1D<jupyter_code>def spatial_filter_1d(x, order=2):
    if order == 2:
        #second derivative of gaussian
        response = (np.exp(-(x**2/2))*(-1+x)*(1+x))/np.sqrt(2*np.pi)
    elif order == 3:
        #third derivative of gaussian
        response = -(np.exp(-(x**2/2))*x*(-3+x**2))/np.sqrt(2*np.pi)
    else:
        print('Must be 2nd or 3rd order!')
        return
    return response
    
space = np.arange(-5,5,0.1)
response_1 = spatial_filter_1d(space, order=2)
response_2 = spatial_filter_1d(space, order=3)
plt.plot(space,response_1, label='2nd order')
plt.plot(space,response_2, label='3rd order')
plt.axhline(0,c='k')
plt.axvline(0,c='k')
plt.legend()
plt.title("1D Spatial Filter Quadrature Pairs")<jupyter_output><empty_output><jupyter_text>Spatial Filters: 2DTodo: Specify Oriented Filter Equations<jupyter_code>def spatial_filter_2d(x1, x2, order=2, oriented=False):
    if oriented:
        print('Oriented Not Yet Implmented')
        return
    else:
        if order == 2:
            #second derivative of gaussian
            x1_response = (np.exp(-(x1**2/2))*(-1+x1)*(1+x1))/np.sqrt(2*np.pi)
            x2_response = (np.exp(-(x2**2/2))*(-1+x2)*(1+x2))/np.sqrt(2*np.pi)
        elif order == 3:
            #third derivative of gaussian
            x1_response = -(np.exp(-(x1**2/2))*x1*(-3+x1**2))/np.sqrt(2*np.pi)
            x2_response = -(np.exp(-(x2**2/2))*x2*(-3+x2**2))/np.sqrt(2*np.pi)
        else:
            print('Must be 2nd or 3rd order!')
            return
            
    response = np.outer(x1_response, x2_response)
    return(response)

space_x = np.arange(-5,5,0.1)
space_y = np.arange(-5,5,0.1)
response_1 = spatial_filter_2d(space_x, space_y, order=2)
response_2 = spatial_filter_2d(space_x, space_y, order=3)
cmax=np.max((response_1,response_2))
cmin=np.min((response_1,response_2))
plt.pcolormesh(space_x, space_y, response_1, shading='auto', vmin=cmin, vmax=cmax)
plt.colorbar()
plt.title("2D Spatial Filter - Gausian Order 2 Deriv")
plt.show()
plt.pcolormesh(space_x, space_y, response_2, shading='auto', vmin=cmin, vmax=cmax)
plt.colorbar()
plt.title("2D Spatial Filter - Gausian Order 3 Deriv")
plt.show()<jupyter_output><empty_output><jupyter_text>Temporal Filters<jupyter_code>def temporal_filter(t, n=3, k=1):
    a = (k*t)**n
    b = np.exp(-k*t)
    c = (1/np.math.factorial(n))-((k*t)**2)/(np.math.factorial(n+2))
    return(a*b*c)

times = np.arange(0,5,0.1)
response_1 = temporal_filter(times, n=3, k=5)
response_2 = temporal_filter(times, n=5, k=5)
plt.plot(times,response_1, label='Curve 1, n=3')
plt.plot(times,response_2, label='Curve 2, n=5')
plt.axhline(0,c='k')
plt.axvline(0,c='k')
plt.legend()
plt.title("Temporal Filter Quadrature Pairs")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17401628222523746, 'fraction_numerical': 0.04477611940298507, 'mean_word_length': 4.191901408450704, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '534475', 'license': 'MIT', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1204, 'n_words': 198, 'path': 'adelsonbergen1984.ipynb', 'repo_name': 'vdutell/linearfiltering', 'size': '2948'}