Skip to content

Commit

Permalink
fix: shift spectrum 2D (#2744)
Browse files Browse the repository at this point in the history
* chore: remove unused dependency

* fix: twice shift [X|Y]

* chore: shift spectra to match 1D and COSY

* chore: fix eslint
  • Loading branch information
jobo322 authored Nov 9, 2023
1 parent 64d89b9 commit bd77ab4
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 49 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"immer": "^10.0.3",
"jszip": "^3.10.1",
"lodash": "^4.17.21",
"ml-airpls": "^1.0.2",
"ml-array-max": "^1.2.4",
"ml-array-mean": "^1.1.6",
"ml-array-median": "^1.1.6",
Expand Down
120 changes: 85 additions & 35 deletions public/data/oxfordInstruments/oxfordCosy.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@
},
"filters": [
{
"id": "a10b030f-a565-42a4-84b1-b9e9087a3ec9",
"name": "blpDimension1",
"label": "Backward-LP Dimension 1",
"value": {},
"flag": true,
"isDeleteAllow": true
"value": {
"nbCoefficients": 15,
"nbPoints": -2,
"nbInputs": 1024
},
"isDeleteAllow": true,
"flag": true
},
{
"id": "0b030fa5-6552-4484-b1b9-e9087a3ec927",
"name": "apodizationDimension1",
"label": "Apodization on Dimension 1",
"value": {
Expand All @@ -39,34 +45,43 @@
}
}
]
},
"apply": true
}
},
"flag": true,
"isDeleteAllow": true
"isDeleteAllow": true,
"flag": true
},
{
"name": "fftDimension1",
"label": "FFT Dimension 1",
"id": "030fa565-52a4-44b1-b9e9-087a3ec92779",
"name": "zeroFillingDimension1",
"label": "Zero filling on Dimension 1",
"value": {
"phaseCorrection": {
"mode": "mc"
},
"zeroFilling": {
"nbPoints": 2048
}
"nbPoints": 2048
},
"flag": true,
"isDeleteAllow": true
"isDeleteAllow": true,
"flag": true
},
{
"name": "flpDimension2",
"label": "Forward-LP Dimension 2",
"id": "0fa56552-a484-41b9-a908-7a3ec9277962",
"name": "fftDimension1",
"label": "FFT Dimension 1",
"value": {},
"flag": true,
"isDeleteAllow": true
"isDeleteAllow": true,
"flag": true
},
{
"id": "a56552a4-84b1-49e9-887a-3ec927796285",
"name": "flpDimension2",
"label": "Fordward-LP Dimension 2",
"value": {
"nbCoefficients": 15,
"nbPoints": 0,
"nbInputs": 113
},
"isDeleteAllow": true,
"flag": true
},
{
"id": "6552a484-b1b9-4908-ba3e-c9277962857d",
"name": "apodizationDimension2",
"label": "Apodization on Dimension 2",
"value": {
Expand All @@ -82,30 +97,54 @@
}
}
]
},
"apply": true
}
},
"flag": true,
"isDeleteAllow": true
"isDeleteAllow": true,
"flag": true
},
{
"id": "52a484b1-b9e9-487a-bec9-277962857d88",
"name": "zeroFillingDimension2",
"label": "Zero filling on Dimension 2",
"value": {
"nbPoints": 2048
},
"isDeleteAllow": true,
"flag": true
},
{
"id": "84b1b9e9-087a-4ec9-a779-62857d888202",
"name": "fftDimension2",
"label": "FFT Dimension 2",
"value": {},
"isDeleteAllow": true,
"flag": true
},
{
"id": "a484b1b9-e908-4a3e-8927-7962857d8882",
"name": "symmetrizeCosyLike",
"label": "symmetrize COSY-like",
"value": {},
"isDeleteAllow": true,
"flag": true
},
{
"name": "shift2DX",
"label": "Shift 2D X",
"value": {
"phaseCorrection": {
"mode": "mc"
},
"zeroFilling": {
"nbPoints": 2048
}
"shift": 0.07471201832594754
},
"id": "c788ea09-165e-49ba-afba-1e2e362f7eb5",
"flag": true,
"isDeleteAllow": true
},
{
"name": "symmetrizeCosyLike",
"label": "symmetrize COSY-like",
"value": {},
"name": "shift2DY",
"label": "Shift 2D Y",
"value": {
"shift": 0.06849902778751127
},
"id": "09165ee9-ba6f-4a1e-ae36-2f7eb5385f7f",
"flag": true,
"isDeleteAllow": true
}
Expand Down Expand Up @@ -158,11 +197,22 @@
"name": "phaseCorrection",
"label": "Phase correction",
"value": {
"ph0": -126,
"ph0": -128.9,
"ph1": 0,
"absolute": false
},
"flag": true,
"isDeleteAllow": true,
"id": "6ae7ba0d-db09-486c-9cbf-2ac7e57dbc3d"
},
{
"name": "shiftX",
"label": "Shift X",
"value": {
"shift": -0.10005791743496187
},
"id": "f86c9cbf-2ac7-457d-bc3d-9465b326c07b",
"flag": true,
"isDeleteAllow": true
}
]
Expand Down
13 changes: 12 additions & 1 deletion public/data/oxfordInstruments/oxfordInstruments.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,22 @@
"name": "phaseCorrection",
"label": "Phase correction",
"value": {
"ph0": -126,
"ph0": -128.9,
"ph1": 0,
"absolute": false
},
"flag": true,
"isDeleteAllow": true,
"id": "6ae7ba0d-db09-486c-9cbf-2ac7e57dbc3d"
},
{
"name": "shiftX",
"label": "Shift X",
"value": {
"shift": -0.10005791743496187
},
"id": "f86c9cbf-2ac7-457d-bc3d-9465b326c07b",
"flag": true,
"isDeleteAllow": true
}
]
Expand Down
12 changes: 2 additions & 10 deletions src/component/2d/ft/Contours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import get from 'lodash/get';
import { Spectrum2D } from 'nmr-load-save';
import { memo, useMemo, useRef } from 'react';

import { getShift } from '../../../data/data2d/Spectrum2D';
import {
drawContours,
getDefaultContoursLevel,
Expand Down Expand Up @@ -36,22 +35,15 @@ function usePath(
) {
const scaleX = useScale2DX();
const scaleY = useScale2DY();
const shift = getShift(spectrum);

const pathBuilder = new PathBuilder();
for (const element of contours) {
if (element.lines) {
const lines = element.lines;
if (lines.length < 1e6) {
for (let i = 0; i < lines.length; i += 4) {
pathBuilder.moveTo(
scaleX(lines[i] + shift.x),
scaleY(lines[i + 1] + shift.y),
);
pathBuilder.lineTo(
scaleX(lines[i + 2] + shift.x),
scaleY(lines[i + 3] + shift.y),
);
pathBuilder.moveTo(scaleX(lines[i]), scaleY(lines[i + 1]));
pathBuilder.lineTo(scaleX(lines[i + 2]), scaleY(lines[i + 3]));
}
}
}
Expand Down

0 comments on commit bd77ab4

Please sign in to comment.