fix(lcms): correct a UV/VIS axis that arrives in seconds behind a MINUTES label - #326
Open
PiTrem wants to merge 1 commit into
Open
fix(lcms): correct a UV/VIS axis that arrives in seconds behind a MINUTES label#326PiTrem wants to merge 1 commit into
PiTrem wants to merge 1 commit into
Conversation
…UTES label An LC/MS dataset rendered its UV/VIS trace across 600 "minutes" while its TIC covered 10. Both describe the same injection, so one of them was wrong: 599.825 seconds is 9.997 minutes, matching the TIC's 9.9994 to three decimals. chemotion-converter-app 1.9.3 emits that UV/VIS axis in seconds while labelling it ##XUNITS=MINUTES, and the ##UNITS X slot agrees, so nothing inside the file contradicts the label. chem.js's seconds-to-minutes pass is vetoed by the explicit MINUTES, and its magnitude check - which would have caught a 600-long axis - never runs. No per-file heuristic can catch this, because the file is internally consistent and simply wrong. The sibling TIC is independent evidence. Reconcile the group's time axes before the curves are dispatched: when a UV/VIS span is 30-120x its TIC's, that is a unit mismatch rather than a longer run, so rescale it. Healthy exports from the same instrument sit near 1 (a second dataset here measures 19.96 against 15.98, a ratio of 1.25), so the window is far from any plausible true value. Only the UV/VIS is adjusted, and only against a TIC. A TIC that is itself in seconds is chem.js's job at parse time, where the file's own units still say so; the m/z entity is never touched, since its x is m/z rather than time. Applied in layer_init before setAllCurves rather than inside a reducer, because reducer_curve and reducer_hplc_ms both consume that one action's payload and must see the same corrected entities. Scaling covers every x-bearing field a curve carries - data blocks, peaks, integrations and the cached extrema - so a curve corrected here is indistinguishable from one that arrived correct, and the xUnit is left agreeing with the data. Verified against both real converter outputs: the mislabelled dataset's UV/VIS goes from 0..599.825 to 0..9.997 beside its 0.005..9.999 TIC, and the consistent dataset is returned untouched, by reference. The converter remains the root cause and is worth fixing there too; this keeps already-converted datasets rendering correctly meanwhile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An LC/MS dataset renders its UV/VIS trace across 600 "minutes" while its TIC covers 10. Both describe the same injection, so one is wrong.
Measured across two real converter outputs:
MINUTESMINUTESMINUTESMINUTES599.825 s ÷ 60 = 9.997 min, matching that TIC's 9.9994 to three decimals. The UV/VIS is in seconds.
Since #323 gives the two panes a shared x-domain, the mismatch is now plainly visible: both span 0–600 and the TIC's real 10 minutes is squashed into the leftmost 1/60.
Why nothing catches it today
chemotion-converter-app1.9.3 emits the UV/VIS axis in seconds while labelling it##XUNITS=MINUTES— and the##UNITSX slot agrees. The file is internally consistent and simply wrong.chem.js's seconds-to-minutes pass is therefore vetoed by the explicitMINUTES, and themaxAbsX > 60magnitude check that would have caught a 600-long axis sits behind that veto and never runs. No per-file heuristic can fix this — including the "parse##UNITSby##SYMBOLslot" work discussed elsewhere, since that slot also saysMINUTES.Approach
The sibling TIC is independent evidence. Reconcile the group's time axes before the curves are dispatched: a UV/VIS span 30–120× its TIC's is a unit mismatch, not a longer run. Healthy exports sit near 1, so the window is far from any plausible true ratio.
Deliberately narrow:
chem.js's job at parse time, where the file's own units still say so.Applied in
layer_initbeforesetAllCurvesrather than inside a reducer, becausereducer_curveandreducer_hplc_msboth consume that one action's payload and must see the same corrected entities.Scaling covers every x-bearing field a curve carries — data blocks, peaks, integrations, cached extrema — mirroring what
chem.jsalready scales when it converts at parse time, so a curve corrected here is indistinguishable from one that arrived correct. ThexUnitis left agreeing with the data.Scope
The converter is the root cause and is worth fixing there too — this keeps already-converted datasets rendering correctly meanwhile, and catches future mislabelling.
Independent of #323, which is about TIC normalization and pane alignment.
Test plan