.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/introduction/demo_gabor_filters.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_introduction_demo_gabor_filters.py: =============================================== Spatial components of the motion energy filters =============================================== This example shows the spatial components of the spatio-temporal filters used in motion energy features. It does not show the temporal components, since this gallery does not support animation. To visualize the filters with their temporal components, you can use :func:`moten.viz.plot_3dgabor`. Here we demonstrate how the spatial filters vary in term of spatial frequencies, locations, and directions. .. GENERATED FROM PYTHON SOURCE LINES 15-17 First, let's define a motion energy pyramid, using :class:`MotionEnergyPyramid`. It defines a set of spatio-temporal Gabor filters. .. GENERATED FROM PYTHON SOURCE LINES 17-22 .. code-block:: default import moten pyramid = moten.pyramids.MotionEnergyPyramid(stimulus_vhsize=(300, 400), stimulus_fps=25) .. GENERATED FROM PYTHON SOURCE LINES 23-25 Then, we define a plotting function, to show the spatial part of these spatio-temporal Gabor filters. .. GENERATED FROM PYTHON SOURCE LINES 25-67 .. code-block:: default import matplotlib.pyplot as plt # noqa def plot_spatial_gabors(pyramid, indices): """Plot the two quadrature spatial components of a list of Gabor filters. Note this only show the spatial components of the spatio-temporal filters. Parameters ---------- pyramid : moten.pyramid.MotionEnergyPyramid instance indices : list of int """ vdim = pyramid.definition['vdim'] size = 0.6 fig, axs = plt.subplots( 2, len(indices), figsize=((len(indices) * 4.25 + 0.25) * size, 7.5 * size), squeeze=False, sharex=True, sharey=True) axs.T[0][0].set_ylabel('spatial Gabor (cos)') axs.T[0][1].set_ylabel('spatial Gabor (sin)') for ii, axs_ in zip(indices, axs.T): spatial_sin, spatial_cos = pyramid.get_filter_spatial_quadrature(ii) axs_[0].imshow(spatial_cos, aspect='equal') axs_[1].imshow(spatial_sin, aspect='equal') axs_[0].set_title('filter %d' % ii) gabor = pyramid.filters[ii] for ax in axs_: ax.scatter(gabor['centerh'] * vdim, gabor['centerv'] * vdim, color='k', marker='+') ax.set_xticks([]) ax.set_yticks([]) plt.tight_layout() .. GENERATED FROM PYTHON SOURCE LINES 68-70 Different spatial frequencies ============================= .. GENERATED FROM PYTHON SOURCE LINES 70-72 .. code-block:: default plot_spatial_gabors(pyramid, [0, 23, 88, 577]) .. image:: /auto_examples/introduction/images/sphx_glr_demo_gabor_filters_001.png :alt: filter 0, filter 23, filter 88, filter 577 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 73-75 Different locations =================== .. GENERATED FROM PYTHON SOURCE LINES 75-77 .. code-block:: default plot_spatial_gabors(pyramid, [46, 52, 58, 64]) .. image:: /auto_examples/introduction/images/sphx_glr_demo_gabor_filters_002.png :alt: filter 46, filter 52, filter 58, filter 64 :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 78-80 Different directions ==================== .. GENERATED FROM PYTHON SOURCE LINES 80-81 .. code-block:: default plot_spatial_gabors(pyramid, [88, 157, 202, 247]) .. image:: /auto_examples/introduction/images/sphx_glr_demo_gabor_filters_003.png :alt: filter 88, filter 157, filter 202, filter 247 :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.209 seconds) .. _sphx_glr_download_auto_examples_introduction_demo_gabor_filters.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_gabor_filters.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_gabor_filters.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_