Configuration (sigima.config)#

The sigima.config module provides a way to manage configuration options for the sigima library, as well as to handle translations and data paths, and other configuration-related tasks.

It allows users to set and retrieve options that affect the behavior of the library, such as whether to keep results of computations or not. The options are handled as in-memory objects with default values provided, and can be temporarily overridden using a context manager.

Typical usage:

from sigima.config import options

# Get an option
value = options.fft_shift_enabled.get(default=True)

# Set an option
options.fft_shift_enabled.set(False)

# Temporarily override an option
with options.fft_shift_enabled.context(True):
    ...

The following table lists the available options:

Name

Default Value

Description

fft_shift_enabled

True

If True, the FFT operations will apply a shift to the zero frequency component to the center of the spectrum. This is useful for visualizing frequency components in a more intuitive way.

auto_normalize_kernel

False

If True, convolution kernels will be automatically normalized to sum to 1.0 before convolution. This ensures that the output signal or image has the same overall magnitude as the input when using smoothing kernels. Set to False to preserve the mathematical properties of the original kernel.

imageio_formats

[['*.gel', 'Opticks GEL'], ['*.spe', 'Princeton Instruments SPE'], ['*.ndpi', 'Hamamatsu Slide Scanner NDPI'], ['*.rec', 'PCO Camera REC']]

List of supported image I/O formats. Each format is a tuple of (file_extension, description).

The sigima library supports any image format that can be read by the imageio library, provided that the associated plugin(s) are installed (see imageio documentation) and that the output NumPy array data type and shape are supported by sigima.

To add a new file format, you may use the imageio_formats option to specify additional formats. Each entry should be a tuple of (file extension, description).

viz_backend

'auto'

Backend library for visualization (sigima.viz module).

Valid values: "auto", "plotpy", "matplotlib".

  • "auto" (default): Automatically select PlotPy if available, otherwise Matplotlib

  • "plotpy": Use PlotPy for interactive visualizations (requires PlotPy and Qt)

  • "matplotlib": Use Matplotlib for visualizations (simpler, view-only)

This setting can also be overridden using the SIGIMA_VIZ_BACKEND environment variable. Note that Matplotlib backend does not support all features of PlotPy (e.g., create_segment(), create_cursor(), etc. will raise NotImplementedError).

Note

The options are stored in an environment variable in JSON format, allowing for synchronization with external configurations or other processes that may need to read or modify the options. The environment variable name is defined by sigima.config.OptionsContainer.ENV_VAR. This is especially useful for applications such as DataLab (where the sigima library is used as a core component) as computations may be run in separate processes.