Skip to content

Missing functionality - Replace X coordinates with Y values from another signal for calibration #4

@PierreRaybaut

Description

@PierreRaybaut

Missing functionality - Replace X coordinates with Y values from another signal for calibration

Problem Description

Users need to perform signal axis calibration, particularly for spectroscopy workflows where:

  • One signal contains measurement data (e.g., intensity vs pixel index)
  • Another signal contains calibration data (e.g., wavelength values vs pixel index)
  • Goal: Plot measurement intensity vs calibrated wavelength scale

This fundamental operation was missing from Sigima/DataLab, forcing users to:

  • Use external tools for calibration
  • Manually export/import data
  • Attempt to use X-Y mode (which incorrectly applies resampling/interpolation)

Solution Implemented

Added new replace_x_by_other_y(src1, src2) function that:

  • Takes Y values from src2 and uses them as X coordinates for src1's Y values
  • Directly uses Y arrays without interpolation (preserves exact calibration values)
  • Requires both signals to have the same number of points
  • Automatically transfers metadata (X label/unit from src2.ylabel/yunit)
  • Clear error message when signal sizes don't match

Technical Details

Function signature:

def replace_x_by_other_y(src1: SignalObj, src2: SignalObj) -> SignalObj:
    """Create a new signal using Y from src1 and Y from src2 as X coordinates."""

Usage example (wavelength calibration):

# Signal 1: intensity measurements [0, 1, 2, 3, 4] -> [10, 20, 30, 40, 50]
# Signal 2: wavelength calibration [0, 1, 2, 3, 4] -> [400, 450, 500, 550, 600]
# Result: intensity vs wavelength [400, 450, 500, 550, 600] -> [10, 20, 30, 40, 50]

calibrated = sigima.proc.signal.replace_x_by_other_y(intensity, wavelength)

Rationale for Bug Fix Classification

While this adds new functionality, it's classified as a bug fix because:

  1. User-reported critical gap: Real users couldn't perform a fundamental operation expected in the target domain (spectroscopy)
  2. Misleading existing feature: X-Y mode appeared to solve the problem but didn't (applies unwanted interpolation)
  3. Expected functionality missing: Users had reasonable expectation this should exist
  4. Quality issue: Software incomplete for its intended scientific use cases

This justifies inclusion in a maintenance release (1.0.3) rather than waiting for a minor version bump.

Related

  • DataLab Issue #273: Same feature added to GUI
  • Clarifies distinction from X-Y mode (which resamples/interpolates signals)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions