darsia.presets.workflows.rig.Rig#
- class Rig[source]#
Bases:
objectRig object for CO2 analysis.
Methods
load(folder[, corrections_config])Load rig object from file.
load_corrections(folder[, corrections_config])Load persisted corrections from disk.
load_experiment(experiment)Load experiment and associated protocols.
mass_analysis(img)Mass analysis of the image.
read(source, *[, date, native])Read an image, given as a file or as the bytes of a file, and apply the corrections of the rig.
read_field(path, *[, on_photo])Read a field of the rig (labels, facies, depth, porosity, ...) onto the grid of the baseline.
regions(name)Regions to group pixels by, on the grid of the labels.
save(folder)Save rig object to file.
setup(experiment, baseline_path, ...[, ...])Fast setup.
setup_color_corrections([...])Setup label-dependent color corrections after labels are available.
setup_depth(path[, log])Setup depth map for the rig object.
setup_facies(path[, apply_corrections, log, ...])Setup facies.
setup_facies_props([props_path, porosity, ...])Define facies properties like porosity.
Setup geometry for volumetric integration of images.
setup_illumination_correction(config[, log, ...])Setup and return illumination correction.
setup_labels(path[, apply_corrections, log])Setup labels for the rig object.
setup_mass_analysis(atmospheric_pressure, ...)Setup and return patchwise illumination correction.
setup_reading(baseline_path, experiment[, ...])setup_shape_corrections(pre_baseline[, ...])Setup shape corrections that do not depend on labels/porosity.
threshold_analysis(mass_analysis_result)Threshold analysis of the mass analysis result.
update(path)Update the state of the rig based on the image path.
Attributes
Combined correction workflow in execution order.
- classmethod load(folder, corrections_config=None)[source]#
Load rig object from file.
Mimick the save method.
- load_corrections(folder, corrections_config=None)[source]#
Load persisted corrections from disk.
Supports both split-format files (shape_correction_*, color_correction_*) and legacy mixed-format files (correction_*).
- load_experiment(experiment)[source]#
Load experiment and associated protocols.
This gives images read from files their date (read) and is required to compute the injected mass correctly.
- Parameters:
- experiment
darsia.ProtocolledExperiment Experiment object containing imaging, injection, and pressure/temperature protocols.
- experiment
- read(source, *, date=None, native=False)[source]#
Read an image, given as a file or as the bytes of a file, and apply the corrections of the rig.
The date of the image is, in this order: the given date; for a file, the date of the imaging protocol if an experiment is loaded (see load_experiment; a file missing from the protocol raises); otherwise none. The time of the image counts from the start of the loaded experiment (the first injection); without an experiment, from the date of the baseline. Without a date or such a reference, the image has no time. Analyses which need the date or the time check for it themselves.
- Parameters:
- source
Pathorbytes Image file, or the bytes of an image file (e.g. received over a network).
- date
datetime,optional Date of the image, instead of the one of the imaging protocol.
- nativebool
Keep the data type resulting from the corrections (the integers of the file without a type correction) instead of converting to float in the end, see darsia.imread_from_optical. Saves memory when many images are held; the user of the image has to support the type (Image.as_float).
- source
- Returns:
darsia.ImageImage with the corrections of the rig applied.
- read_field(path, *, on_photo=False)[source]#
Read a field of the rig (labels, facies, depth, porosity, …) onto the grid of the baseline.
- Parameters:
- path
Path File of the field.
- on_photobool
Whether the field was drawn on the uncorrected baseline photo (e.g. labels from the labeling step). Then the shape corrections for fields follow: nearest neighbor resize, curvature correction, final nearest neighbor resize. Drift and type corrections do not apply to fields drawn on the baseline photo itself. Otherwise (default, e.g. saved rigs) the field lies on the corrected baseline and is transferred to its grid (darsia.transfer): center sampling for integer fields, area averaging for float fields; the identity on the grid of the baseline.
- path
- Returns:
darsia.ImageThe field on the grid of the baseline.
- Raises:
ValueErrorIf a field on the corrected baseline covers another domain than the baseline.
- regions(name)[source]#
Regions to group pixels by, on the grid of the labels.
- Parameters:
- name
RegionName “labels” (segments), “facies” (groups of labels; the labels without a facies file) or “global” (one region 0, the whole image).
- name
- Returns:
darsia.ImageThe labels or facies (not copies; not to be modified), or a new zero image.
- setup(experiment, baseline_path, depth_map_path, labels_path, facies_path=None, facies_props_path=None, corrections_config=None, roi_registry=None, image_porosity_config=None, log=None, show_plot=False, dimensions=None)[source]#
Fast setup.
dimensions is the physical size (height, width) of the rig ([rig]); without it, and without a crop correction setting the size, images get the size 1 x 1.
- setup_color_corrections(corrections_config=None, roi_registry=None, log=None, show_plot=False, image_porosity_config=None)[source]#
Setup label-dependent color corrections after labels are available.
Execution order is fixed: 1) illumination, 2) relative color, 3) color correction. Relative color can either be loaded from a precomputed correction file or calibrated from configured images (interactive mode only).
With [corrections.illumination] mask = “boolean_porosity”, the illumination correction is fitted on the boolean image porosity of the current baseline ([image_porosity] method > tol), computed here and not kept; the stored image porosity is a setup step of its own, after the rig.
- setup_facies(path, apply_corrections=False, log=None, show_plot=False)[source]#
Setup facies.
This method loads facies from a specified path and applies corrections if needed.
- setup_facies_props(props_path=None, porosity=None, permeability=None)[source]#
Define facies properties like porosity.
- setup_illumination_correction(config, log=None, show_plot=False, image_porosity_config=None)[source]#
Setup and return illumination correction.
- Parameters:
- config
IlluminationCorrectionConfig|None Configuration for the illumination correction. If provided, it will set up the illumination correction based on this configuration.
- log
Path|None Path to the log folder where diagnostic plots will be saved.
- show_plotbool
Whether to show diagnostic plots during setup (default: False).
- image_porosity_config
ImagePorosityConfig|None [image_porosity]: with config.mask = “boolean_porosity”, the correction is fitted on the boolean image porosity of the current baseline (method > tol, before cutoff and boundary band), computed here and not kept. None means the defaults.
- config
Notes
Illumination calibration in Rig intentionally uses the shape-corrected baseline as setup input.
- setup_labels(path, apply_corrections=False, log=None)[source]#
Setup labels for the rig object.
This method loads labels from a specified path and applies corrections if needed.
- setup_patchwise_illumination_correction(config, show_plot=False)[source]#
Setup and return patchwise illumination correction.
- Parameters:
- config
PatchwiseIlluminationCorrectionConfig|None Configuration for the patchwise illumination correction. If provided, it will set up the correction based on this configuration.
- config
Notes
Patchwise illumination calibration uses the labels image to enable per-label reference color computation within each patch, ensuring heterogeneous regions contribute equally by material.
- setup_shape_corrections(pre_baseline, corrections_config=None, roi_registry=None)[source]#
Setup shape corrections that do not depend on labels/porosity.
- update(path)[source]#
Update the state of the rig based on the image path.
This method updates the current date, time, pressure, and temperature of the rig object based on the provided image path.
- Parameters:
- path
Path Path to the image file.
- path
- property corrections#
Combined correction workflow in execution order.