Skip to content

Commit

Permalink
Merge pull request #2908 from LMSC-NTappy/support_hamamatsu_streak
Browse files Browse the repository at this point in the history
Support for Hamamatsu Streak tiff metadata
  • Loading branch information
ericpre committed Apr 25, 2022
2 parents 9394850 + 083c082 commit 6a1a5f2
Show file tree
Hide file tree
Showing 6 changed files with 690 additions and 247 deletions.
39 changes: 34 additions & 5 deletions doc/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -772,17 +772,46 @@ Currently HyperSpy has limited support for reading and saving the TIFF tags.
However, the way that HyperSpy reads and saves the scale and the units of TIFF
files is compatible with ImageJ/Fiji and Gatan Digital Micrograph software.
HyperSpy can also import the scale and the units from TIFF files saved using
FEI, Zeiss SEM and Olympus SIS software.
FEI, Zeiss SEM, Olympus SIS, Jeol SightX and Hamamatsu HPD-TA (streak camera)
software.

Extra loading arguments
^^^^^^^^^^^^^^^^^^^^^^^

- ``force_read_resolution`` (bool, optional): Force read image resolution using
the x_resolution, y_resolution and resolution_unit tags of the TIFF. Beware:
most software don't (properly) use these tags when saving TIFF files. Default
is ``False``.
- ``hamamatsu_streak_axis_type`` (str, optional): decide the type of the
time axis for hamamatsu streak files:

* if ``uniform``, the best-fit linear axis is used, inducing a (small)
linearisation error. Initialise a UniformDataAxis.
* if ``data``, the raw time axis parsed from the metadata is used. Initialise
a DataAxis.
* if ``functional``, the best-fit 3rd-order polynomial axis is used, avoiding
linearisation error. Initialise a FunctionalDataAxis.

By default, ``uniform`` is used but a warning of the linearisation error is issued.
Explicitly passing ``hamamatsu_streak_axis_type='uniform'`` suppresses the warning.
In all cases, the original axis values are stored in the ``original_metadata`` of the
signal object.

.. code-block:: python
>>> # Force read image resolution using the x_resolution, y_resolution and
>>> # the resolution_unit of the TIFF tags. Be aware, that most of the
>>> # software doesn't (properly) use these tags when saving TIFF files.
>>> # the resolution_unit of the TIFF tags.
>>> s = hs.load('file.tif', force_read_resolution=True)
>>> # Load a non-uniform axis from a hamamatsu streak file:
>>> s = hs.load('file.tif', hamamatsu_streak_axis_type='data')
Extra saving arguments
^^^^^^^^^^^^^^^^^^^^^^

HyperSpy can also read and save custom tags through the ``tifffile``
library.
- ``extratags`` (tuple, optional): save custom tags through the
``tifffile`` library. Must conform to a specific convention
(see ``tifffile`` documentation and example below).

.. code-block:: python
Expand Down
2 changes: 2 additions & 0 deletions hyperspy/io_plugins/sur.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,10 @@ def _build_sur_dict(self):
#If the signal is of the type spectrum or hypercard
if self._Object_type in ["_HYPCARD",]:
self._build_hyperspectral_map()
#self._build_hyperspectral_signal_type()
elif self._Object_type in ["_SPECTRUM"]:
self._build_spectrum()
#self._build_spectrum_signal_type()
elif self._Object_type in ["_PROFILE"]:
self._build_general_1D_data()
elif self._Object_type in ["_PROFILESERIE"]:
Expand Down

0 comments on commit 6a1a5f2

Please sign in to comment.