magscope.utils
==============

.. py:module:: magscope.utils


Classes
-------

.. autoapisummary::

   magscope.utils.AcquisitionMode
   magscope.utils.PoolVideoFlag
   magscope.utils.Units


Functions
---------

.. autoapisummary::

   magscope.utils.crop_stack_to_rois
   magscope.utils.numpy_type_to_qt_image_type
   magscope.utils.date_timestamp_str
   magscope.utils.register_script_command
   magscope.utils.check_cupy


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

.. py:class:: AcquisitionMode

   Bases: :py:obj:`enum.StrEnum`


   Enum for acquisition modes.

   The UI redesign changed the enum values to match the new display labels. Existing scripts
   that compare or pass raw strings should update old values such as ``"video (full)"`` to
   the new values such as ``"Video (Full)"``. The old member names remain as aliases so
   scripts using ``AcquisitionMode.FULL_VIDEO`` continue to resolve to the new canonical mode.


   .. py:attribute:: TRACK
      :value: 'Track'



   .. py:attribute:: TRACK_AND_VIDEO_ROIS
      :value: 'Track and Video (ROIs)'



   .. py:attribute:: TRACK_AND_VIDEO_FULL
      :value: 'Track and Video (Full)'



   .. py:attribute:: VIDEO_ROIS
      :value: 'Video (ROIs)'



   .. py:attribute:: VIDEO_FULL
      :value: 'Video (Full)'



   .. py:attribute:: TRACK_AND_CROP_VIDEO


   .. py:attribute:: TRACK_AND_FULL_VIDEO


   .. py:attribute:: CROP_VIDEO


   .. py:attribute:: FULL_VIDEO


.. py:function:: crop_stack_to_rois(stack, rois)

.. py:function:: numpy_type_to_qt_image_type(numpy_type)

.. py:function:: date_timestamp_str(timestamp)

.. py:class:: PoolVideoFlag

   Bases: :py:obj:`enum.IntEnum`


   Enum where members are also (and must be) ints


   .. py:attribute:: READY
      :value: 0



   .. py:attribute:: RUNNING
      :value: 1



   .. py:attribute:: FINISHED
      :value: 2



.. py:class:: Units

   .. py:attribute:: m
      :value: 1.0



   .. py:attribute:: cm
      :value: 0.01



   .. py:attribute:: mm
      :value: 0.001



   .. py:attribute:: um
      :value: 1e-06



   .. py:attribute:: nm
      :value: 1e-09



   .. py:attribute:: N
      :value: 1.0



   .. py:attribute:: mN
      :value: 0.001



   .. py:attribute:: uN
      :value: 1e-06



   .. py:attribute:: nN
      :value: 1e-09



   .. py:attribute:: pN
      :value: 1e-12



   .. py:attribute:: fN
      :value: 1e-15



   .. py:attribute:: ms
      :value: 0.001



   .. py:attribute:: us
      :value: 1e-06



   .. py:attribute:: ns
      :value: 1e-09



   .. py:attribute:: ps
      :value: 1e-12



   .. py:attribute:: fs
      :value: 1e-15



.. py:function:: register_script_command(command_type: type[magscope.ipc_commands.Command])

   Decorator marking a method as callable from a MagScope script.

   Each script command must be paired with the IPC :class:`~magscope.ipc_commands.Command`
   that will be dispatched when the script executes that step. The decorator mirrors
   :func:`magscope.ipc_commands.command_handler` by attaching metadata to the wrapped
   function without constraining how it is collected.


.. py:function:: check_cupy() -> bool

   Return ``True`` when the CuPy package is usable.


