anu_ctlab_io ============ .. py:module:: anu_ctlab_io .. autoapi-nested-parse:: python I/O for the ANU CTLab array storage format(s). Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/anu_ctlab_io/netcdf/index /autoapi/anu_ctlab_io/zarr/index Package Contents ---------------- .. py:class:: Dataset(data, *, dimension_names, voxel_unit, voxel_size, datatype = None, history = None) Bases: :py:obj:`AbstractDataset` A :any:`Dataset`, containing the data and metadata read from one of the ANU CTLab file formats. :any:`Dataset`\ s are the primary interface to the :py:mod:`anu_ctlab_io` package, and should generally be constructed by users via the :any:`Dataset.from_path` classmethod. Note that the relevant extra (:any:`netcdf` or :any:`zarr`) must be installed. The initializer of this class should only be used when manually constructing a :any:`Dataset`, which is not the primary usage of this library. .. py:method:: from_path(path, *, filetype = 'auto', parse_history = True, **kwargs) :classmethod: Creates a :any:`Dataset` from the data at the given ``path``. The data at ``path`` must be in one of the ANU mass data storage formats, and the optional extras required for the specific file format must be installed. :param path: The ``path`` to read data from. :rtype: :any:`Dataset` .. py:property:: voxel_size :type: tuple[numpy.float32, numpy.float32, numpy.float32] The voxel size of the data in the dataset's native unit. .. py:method:: voxel_size_with_unit(voxel_unit) Get the voxel size of the data converted to a target unit. :param voxel_unit: The unit to convert the voxel size to. :return: The voxel size as a tuple of three float32 values. :raises ValueError: If unit conversion is requested but the source or target unit is VOXEL. .. py:property:: voxel_unit :type: anu_ctlab_io._voxel_properties.VoxelUnit The unit the data's voxel size is in. .. py:property:: dimension_names :type: tuple[str, Ellipsis] The names of the data's dimensions. Usually ``("z", "y", "x")``. .. py:property:: history :type: dict[Any, Any] | str The history metadata associated with the :any:`Dataset`. If parsing is enabled this will be a nested dict, otherwise it will be a dictionary without any guaranteed structure. .. py:property:: mask_value :type: anu_ctlab_io._datatype.StorageDType | None The mask value being used by the data. .. py:property:: data :type: dask.array.Array The data contained within the :any:`Dataset`. This is a `Dask Array `_. .. py:property:: mask :type: dask.array.Array The masked areas of the :any:`Dataset`, as a boolean array. This has the same dimensions as the data, and will be all-zero if no mask value exists. .. py:property:: masked_data :type: dask.array.Array The data contained within the :any:`Dataset`, as a masked array. This has better performance than manually creating a masked_array using `mask` in the case that the loaded datatype has no mask (i.e., OME-Zarr data), as it creates a masked array with `nomask` in these situations. .. py:class:: DataType(*args, **kwds) Bases: :py:obj:`enum.Enum` An ``Enum`` representing the datatypes produced by MANGO. This is used when parsing metadata to construct a :any:`Dataset`, and generally should not need to be constructed by a user (use the :any:`Dataset.from_path` classmethod instead). When needed, :any:`DataType`\ s should be constructed via either the :any:`infer_from_path` or the :any:`from_basename` classmethods. .. py:attribute:: PROJU16 :value: 'proju16' .. py:attribute:: PROJF32 :value: 'projf32' .. py:attribute:: TOMO_FLOAT :value: 'tomo_float' .. py:attribute:: TOMO :value: 'tomo' .. py:attribute:: FLOAT16 :value: 'float16' .. py:attribute:: FLOAT64 :value: 'float64' .. py:attribute:: SEGMENTED :value: 'segmented' .. py:attribute:: DISTANCE_MAP :value: 'distance_map' .. py:attribute:: LABELS :value: 'labels' .. py:attribute:: RGBA8 :value: 'rgba8' .. py:property:: is_discrete :type: bool Whether the :any:`DataType` is discrete. .. py:property:: dtype :type: numpy.typing.DTypeLike The numpy ``dtype`` appropriate for storing data of the :any:`DataType`. Because of a historical decision in MANGO, the datatype listed in ANU CTLab NetCDFs is not guaranteed to have the correct signed/unsigned type -- for some MANGO datatypes, data recorded in the NetCDF as an integer type is really an unsigned integer stored in an integer. The :any:`dtype` is the real datatype of the data, regardless of whether a loaded NetCDF exhibits this behaviour (trust this value, not the NetCDF header). .. py:property:: mask_value :type: StorageDType | None The mask value of the :any:`DataType`. This value is corrected for signedness if required (see :any:`dtype`\ ). .. py:method:: infer_from_path(path) :classmethod: Create a :any:`DataType` object by inferring it from the path to the data being loaded. Relies on MANGO's standardised file naming. :rtype: :any:`DataType` .. py:method:: from_basename(basename) :classmethod: Create a :any:`DataType` object from it's name as a string. E.g., ``DataType.from_basename("tomo")`` :rtype: :any:`DataType` .. py:type:: StorageDType :canonical: np.uint8 | np.uint16 | np.uint32 | np.uint64 | np.float16 | np.float32 | np.float64 .. py:class:: VoxelUnit(*args, **kwds) Bases: :py:obj:`enum.Enum` The unit of size of a voxel. .. py:attribute:: M :value: 'm' .. py:attribute:: CM :value: 'cm' .. py:attribute:: MM :value: 'mm' .. py:attribute:: UM :value: 'um' .. py:attribute:: NM :value: 'nm' .. py:attribute:: ANGSTROM :value: 'angstrom' .. py:attribute:: VOXEL :value: 'voxel' .. py:method:: from_str(string) :classmethod: Create a VoxelUnit from the string name of the unit. Accepts a wide range of standard representations of each unit, and is case insensitive.