.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/virtual_imaging/creating_virtual_images_from_vectors.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_virtual_imaging_creating_virtual_images_from_vectors.py: ==================================== Creating Virtual Images from Vectors ==================================== In this example we will show how to create virtual images from vectors. We will use the `find_peaks` method to find the vectors and then use the `get_unique_vectors` method to reduce the number of vectors to a unique set of vectors. We can convert the unique vectors to regions of interest (ROIs) objects using the `to_roi` method and then use the `get_virtual_image` method to create the virtual images. This method is flexible and any type of ROI defined in hyperspy can be used to create virtual images. We also included the include_labels argument to the `to_roi` method which will also return the labels for each ROI for use plotting on the signal. .. GENERATED FROM PYTHON SOURCE LINES 18-36 .. code-block:: Python import pyxem as pxm c = pxm.data.dummy_data.get_cbed_signal() pks = c.template_match_disk(5, subtract_min=False).find_peaks( interactive=False, threshold_abs=0.8, min_distance=6 ) dv = pxm.signals.DiffractionVectors.from_peaks(pks) vectors = dv.get_unique_vectors() roi, texts = vectors.to_roi(radius=5, include_labels=True, sizes=3, facecolor="black") c.plot() for r in roi: r.add_widget(c, axes=(2, 3)) vdfs = c.get_virtual_image(roi) c.add_marker(texts) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_001.png :alt: creating virtual images from vectors :srcset: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_002.png :alt: Signal :srcset: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none [ ] | 0% Completed | 135.67 us [ ] | 0% Completed | 100.44 ms [########################################] | 100% Completed | 200.72 ms [ ] | 0% Completed | 120.91 us [########################################] | 100% Completed | 100.39 ms [ ] | 0% Completed | 115.42 us [########################################] | 100% Completed | 100.37 ms .. GENERATED FROM PYTHON SOURCE LINES 37-39 .. code-block:: Python vdfs.plot() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_003.png :alt: Stack of Integrated intensity Navigator :srcset: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_004.png :alt: Stack of Integrated intensity Signal :srcset: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_004.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 40-41 sphinx_gallery_thumbnail_number = 2 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.833 seconds) .. _sphx_glr_download_examples_virtual_imaging_creating_virtual_images_from_vectors.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: creating_virtual_images_from_vectors.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: creating_virtual_images_from_vectors.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_