GONet Analysis Utilities

Array-level processing utilities for GONet image data.

Analysis Package

Analysis utility functions for GONet image calibration and preprocessing.

The gonet.analysis_utils package collects higher-level analysis and correction tools built on top of the core GONet data structures. These utilities provide convenience methods for common preprocessing steps such as dark correction, normalization, and background modeling.

Modules

Dark Correction

Dark-signal and overscan correction utilities for GONet images.

The routines in this module operate on GONet image containers via duck typing: objects are expected to expose CHANNELS, get_channel(), and set_channel(). This lets the same correction code work with both GONetFile and GONetFileRaw.

At present the module provides a single overscan subtraction helper used during RAW full-array construction and other preprocessing workflows.

Functions

remove_overscan()

Subtract the mean of a fixed overscan stripe from selected channels, either in-place or into a new image container of the same class.

GONet_Wizard.GONet_utils.src.gonet.analysis_utils.dark_correction.remove_overscan(self, inplace=True, channels=None)[source]

Remove overscan regions from the image data.

This method subtracts the mean value of a predefined overscan region from the specified channels (blue, green, red). By default, the operation is performed on all channels and modifies the current instance in-place. Optionally, a new instance with the overscan-subtracted data can be returned.

Parameters:
  • inplace (bool, optional) – If True (default), modifies the current instance in-place. If False, returns a new instance with the overscan-subtracted data.

  • channels (list of str, optional) – A list of channel names to operate on. Must be a subset of self.CHANNELS. Defaults to all channels (self.CHANNELS).

Returns:

GONetFile or None – If inplace is False, returns a new instance with the overscan-subtracted data. Otherwise, returns None.

Notes

  • The overscan region is defined as the slice of rows from 10 to 20 (exclusive).

  • If inplace is False, the metadata and file type are preserved in the returned instance.

Full Array Construction

Build the Full-Array of a GONet Image

Build a full-array GONet image by histogram matching and combining Bayer channels.

Overview

GONet RAW images store data in a Bayer mosaic. This module:

  1. Loads a GONet RAW jpg file via GONetFileRaw.

  2. Removes the overscan region.

  3. Splits the image into Bayer planes (e.g. red, green1, green2, blue).

  4. Histogram-matches all non-reference channels to the reference channel (by default green1), so that their pixel distributions become comparable.

  5. Combines the matched channels into a single full-array image using either equal weights (default) or user-specified per-channel weights.

  6. Optionally displays diagnostic histograms and the combined image.

  7. Saves the resulting full-array image as a compressed .npz file.

Notes

  • Since we need the full Bayer array, only GONet RAW .jpg files can be used as input.

  • Output full-array is stored as float32 to reduce disk and memory footprint.

GONet_Wizard.GONet_utils.src.gonet.analysis_utils.full_array.hist_match_to_ref(src, ref, n_bins=512, clip=None)[source]

Map src values so that its histogram matches ref’s histogram.

Parameters:
  • src (numpy.ndarray) – Source channel image (1-D or 2-D).

  • ref (numpy.ndarray) – Reference channel image (1-D or 2-D).

  • n_bins (int, optional) – Number of histogram bins to use for computing the CDFs.

  • clip (tuple of float, optional) – If given as (low, high), both src and ref values are clipped to this range before building the histograms.

Return type:

ndarray

Returns:

matched (numpy.ndarray) – Float32 array with the same shape as src, histogram-matched to ref.

GONet_Wizard.GONet_utils.src.gonet.analysis_utils.full_array.build_full_array(gonet_file, show=False, outfile=None, verbose=False, channel_weights=None, *, save_diagnostics=True, hist_bins=100, n_bins_match=512, clip_match=None)[source]

Build a full-array GONet image by histogram matching and averaging channels.

Parameters:
  • gonet_file (Path) – Path to the input GONet RAW .jpg file.

  • show (bool, optional) – If True, show diagnostic histograms and the combined image using matplotlib.

  • outfile (Path, optional) – Output file name for the compressed .npz file. If None, a default name based on gonet_file is used.

  • verbose (bool, optional) – If True, enable more verbose logging.

  • channel_weights (dict, optional) – Mapping channel_name -> weight for combining channels.

  • save_diagnostics (bool, optional) – If True, save per-channel histogram summaries (raw + matched) in the output .npz.

  • hist_bins (int, optional) – Number of bins used for diagnostic histograms.

  • n_bins_match (int, optional) – Number of bins used for histogram matching CDFs.

  • clip_match (tuple of float, optional) – Optional clipping applied inside histogram matching.

Return type:

None

Returns:

None