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— Functions for overscan and dark-frame subtraction.
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:
Loads a GONet RAW
jpgfile viaGONetFileRaw.Removes the overscan region.
Splits the image into Bayer planes (e.g.
red,green1,green2,blue).Histogram-matches all non-reference channels to the reference channel (by default
green1), so that their pixel distributions become comparable.Combines the matched channels into a single full-array image using either equal weights (default) or user-specified per-channel weights.
Optionally displays diagnostic histograms and the combined image.
Saves the resulting full-array image as a compressed
.npzfile.
Notes
Since we need the full Bayer array, only GONet RAW
.jpgfiles 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
srcvalues so that its histogram matchesref’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 (
tupleoffloat, optional) – If given as(low, high), bothsrcandrefvalues are clipped to this range before building the histograms.
- Return type:
- Returns:
matched (
numpy.ndarray) – Float32 array with the same shape assrc, histogram-matched toref.
- 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.jpgfile.show (
bool, optional) – IfTrue, show diagnostic histograms and the combined image using matplotlib.outfile (
Path, optional) – Output file name for the compressed.npzfile. IfNone, a default name based ongonet_fileis used.verbose (
bool, optional) – IfTrue, enable more verbose logging.channel_weights (
dict, optional) – Mappingchannel_name -> weightfor combining channels.save_diagnostics (
bool, optional) – IfTrue, 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 (
tupleoffloat, optional) – Optional clipping applied inside histogram matching.
- Return type:
- Returns:
None