goatpy.landmark_alignment
=========================

.. py:module:: goatpy.landmark_alignment


Classes
-------

.. autoapisummary::

   goatpy.landmark_alignment.LandmarkAlignmentWidget


Functions
---------

.. autoapisummary::

   goatpy.landmark_alignment.postpone_transformation
   goatpy.landmark_alignment.align_image_using_landmarks
   goatpy.landmark_alignment.launch_landmark_gui


Module Contents
---------------

.. py:function:: postpone_transformation(sdata: spatialdata.SpatialData, transformation: spatialdata.transformations.BaseTransformation, source_coordinate_system: str, target_coordinate_system: str)

.. py:function:: align_image_using_landmarks(maldi_sd: spatialdata.SpatialData, he_sd: spatialdata.SpatialData, maldi_landmark_key: str = 'maldi_landmarks', he_landmark_key: str = 'he_landmarks', maldi_image_key: str = 'optical_image', he_image_key: str = 'he_image') -> spatialdata.SpatialData

   Align two SpatialData objects using landmarks.

   Landmarks saved by the GUI are always stored at full (scale0) resolution,
   regardless of which scale level was used for display. The scale correction
   is applied automatically inside the GUI's save_landmarks() method.

   :param maldi_sd: The reference SpatialData object.
   :type maldi_sd: SpatialData
   :param he_sd: The moving SpatialData object to be aligned to the reference (H&E).
   :type he_sd: SpatialData
   :param maldi_landmark_key: Key in maldi_sd.points for the reference landmarks.
   :type maldi_landmark_key: str
   :param he_landmark_key: Key in he_sd.points for the moving landmarks.
   :type he_landmark_key: str
   :param maldi_image_key: Key for the reference image in maldi_sd.images.
   :type maldi_image_key: str
   :param he_image_key: Key for the H&E image in he_sd.images.
   :type he_image_key: str

   :returns: **maldi_sd** -- The reference SpatialData with the H&E image merged in under the 'aligned'
             coordinate system.
   :rtype: SpatialData


.. py:class:: LandmarkAlignmentWidget(maldi_sd: spatialdata.SpatialData, he_sd: spatialdata.SpatialData, maldi_viewer: napari.Viewer = None, he_viewer: napari.Viewer = None, combined_viewer: napari.Viewer = None, maldi_image_key: str = 'optical_image', he_image_key: str = 'he_image', split_view: bool = False, maldi_scale_level: str = 'scale0', he_scale_level: str = 'scale0')

   Bases: :py:obj:`qtpy.QtWidgets.QWidget`


   Widget for selecting corresponding landmarks in two images.


   .. py:attribute:: maldi_sd


   .. py:attribute:: he_sd


   .. py:attribute:: maldi_image_key
      :value: 'optical_image'



   .. py:attribute:: he_image_key
      :value: 'he_image'



   .. py:attribute:: split_view
      :value: False



   .. py:attribute:: maldi_scale_level
      :value: 'scale0'



   .. py:attribute:: he_scale_level
      :value: 'scale0'



   .. py:attribute:: maldi_scale_factor
      :value: 1.0



   .. py:attribute:: he_scale_factor
      :value: 1.0



   .. py:attribute:: maldi_landmarks
      :value: []



   .. py:attribute:: he_landmarks
      :value: []



   .. py:attribute:: active_dataset
      :value: 'maldi'



   .. py:method:: init_ui()


   .. py:method:: setup_layers()


   .. py:method:: set_active_dataset(dataset: str)


   .. py:method:: on_click_combined(layer, event)


   .. py:method:: on_click_split(viewer, layer, event)


   .. py:method:: update_status()


   .. py:method:: undo_last()


   .. py:method:: clear_all()


   .. py:method:: save_landmarks()


.. py:function:: launch_landmark_gui(maldi_sd: spatialdata.SpatialData, he_sd: spatialdata.SpatialData, maldi_image_key: str = 'optical_image', he_image_key: str = 'he_image', split_view: bool = False, maldi_scale_level: str = None, he_scale_level: str = 'scale0')

   Launch the landmark alignment GUI.

   :param maldi_sd: MALDI spatial data object.
   :type maldi_sd: SpatialData
   :param he_sd: H&E spatial data object.
   :type he_sd: SpatialData
   :param maldi_image_key: Key for MALDI image in maldi_sd.images.
   :type maldi_image_key: str
   :param he_image_key: Key for H&E image in he_sd.images.
   :type he_image_key: str
   :param split_view: If True, open each image in its own napari window.
   :type split_view: bool
   :param maldi_scale_level: Which multiscale level to load for MALDI, e.g. 'scale0', 'scale1', 'scale2'.
                             If None, the available levels are printed and you are prompted to choose.
   :type maldi_scale_level: str or None
   :param he_scale_level: Which multiscale level to load for H&E.
                          If None, the available levels are printed and you are prompted to choose.
   :type he_scale_level: str or None

   :rtype: (viewer, widget) or (main_viewer, maldi_viewer, he_viewer, widget)


