
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/representations/plot_toimage.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_representations_plot_toimage.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_representations_plot_toimage.py:


=======
ToImage
=======

:class:`~tonic.transforms.ToImage` bins all the events to a single image.
Typically used in conjunction with SlicedDataset, to chunk recordings
into smaller samples.

.. GENERATED FROM PYTHON SOURCE LINES 11-28



.. image-sg:: /auto_examples/representations/images/sphx_glr_plot_toimage_001.png
   :alt: plot toimage
   :srcset: /auto_examples/representations/images/sphx_glr_plot_toimage_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt

    import tonic

    nmnist = tonic.datasets.NMNIST("../../tutorials/data", train=False)
    events, label = nmnist[0]

    transform = tonic.transforms.ToImage(
        sensor_size=nmnist.sensor_size,
    )

    image = transform(events[:1000])

    plt.imshow(image[1] - image[0])
    plt.axis(False)
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.070 seconds)


.. _sphx_glr_download_auto_examples_representations_plot_toimage.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_toimage.ipynb <plot_toimage.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_toimage.py <plot_toimage.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_toimage.zip <plot_toimage.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
