deepanshs / mrsimulator

A fast solid-state NMR spectrum simulation and analysis library.
https://mrsimulator.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
34 stars 13 forks source link

CSDM origin offset and reference issue #269

Closed deepanshs closed 10 months ago

deepanshs commented 1 year ago

Equations

The CSDM LinearDimension defines coordinates as coordinates = $\Delta x(J_k - Z_k) + b_k$, where $J_k = [0, 1, ... N_k -1]$. When complex_fft=False, $Z_k$ = 0. When complex fft=True, $Z_k = N_k/2$ for even $N_k$ else $(N_k-1)/2$

For NMR datasets, here are two cases---when origin_offset is defined at the receiver frequency, and origin_offset is defined at the reference frequency.

originoffset $= w\text{RF}$ originoffset $= w\text{ref}$
complex_fft = True $w\text{ref} = w\text{RF} - b$ $w\text{RF} = w\text{ref} + b$
complex_fft = False, $N$ is odd $w\text{ref} = w\text{RF} - (b + \frac{N-1}{2} \Delta x)$ $w\text{RF} = w\text{ref} + (b + \frac{N-1}{2} \Delta x)$
complex_fft = False, $N$ is even, $\Delta x$ > 0 $w\text{ref} = w\text{RF} - (b + \frac{N}{2} \Delta x)$ $w\text{RF} = w\text{ref} + (b + \frac{N}{2} \Delta x)$
complex_fft = False, $N$ is even, $\Delta x$ < 0 $w\text{ref} = w\text{RF} - (b + (\frac{N}{2} - 1) \Delta x)$ $w\text{RF} = w\text{ref} + (b + (\frac{N}{2} - 1) \Delta x)$

The conversion from Hz -> ppm is coordinates / ${w_\text{ref}}$. The difference is that when originoffset is ${w\text{RF}}$, the value of ${w_\text{ref}}$ depends on how the LinearDimension is defined.


What happens to the origin offset for a data subset?


Cases

1 When dataset is the full spectrum

property originoffset $= w\text{ref}$ originoffset $= w\text{RF}$
always known $w_\text{ref}$ $w_\text{RF}$
can be derived $w_\text{RF}$ $w_\text{ref}$
information loss - -
absolute_coordinates
coordinates
ppm_scale (using above equations)

2 Subset of the full spectrum (keeping the origin_offset the same as the original dataset)

property originoffset $= w\text{ref}$ originoffset $= w\text{RF}$
always known $w_\text{ref}$ $w_\text{RF}$
can be derived - -
information loss $w_\text{RF}$ $w_\text{ref}$
absolute_coordinates
coordinates
ppm_scale (using above equations)

3 Subset of the full spectrum (updating the origin_offset to maintain the same ppm scale)

property originoffset $= w\text{ref}$ originoffset $= w'\text{RF}$
always known $w_\text{ref}$ $w'_\text{RF}$
can be derived - -
information loss $w_\text{RF}$ $w_\text{RF}$
absolute_coordinates
coordinates
ppm_scale (using above equations)

Scenarios

Test file scenario-1.zip Summary origin_offset is always $w\text{RF}$. The coordinates in Hz are known. Since there is no evidence if the csdm object is a complete or a subset, $w\text{ref}$ and therefore the coordinates in ppm are presumed incorrect.

Test file scenario-2.zip Summary origin_offset is always $w\text{ref}$. The coordinates in Hz and ppm are always known. Since there is no evidence if the csdm object is a complete or a subset, the $w\text{RF}$ is presumed incorrect.

pjgrandinetti commented 1 year ago

The assumption that the carrier frequency is at the center of the spectrum is the only way to encode both wRF and wref into o and b.

pjgrandinetti commented 1 year ago

Correct absolute coordinates require $\Delta oo = - \Delta b$. This appears to be true regardless of the complex_fft flag state.