Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Interactive Spectrum Phasing

While automated phasing algorithms (like ACME) are incredibly powerful, heavily distorted baselines, massive solvent peaks, or extreme noise can sometimes trick the optimizer. In these cases, falling back to manual phase correction is necessary.

As discussed in the Phase Correction Pipeline documentation, applying a phase correction mathematically is straightforward. However, guessing the exact p0p_0 and p1p_1 angles blindly is nearly impossible.

To solve this, xmris provides an interactive, browser-based AnyWidget that allows you to click and drag to fix the phase in real-time, and then generates the exact Python code needed to reproduce your manual adjustments.

1. Generating Unphased Data

Let’s generate the same ruined synthetic spectrum we used in the pipeline documentation.

Source

2. Launching the Widget

You can launch the interactive viewer directly from the xmris package. Pass your complex-valued 1D frequency-domain DataArray to the phase_spectrum function.

The widget will automatically detect your spectral dimension (e.g., frequency, ppm), set up the coordinates, and calculate the optimal pivot point based on the maximum signal magnitude.

Loading...

Using the Widget

Once the widget is rendered in your notebook, you can interact with it using the following controls:

3. Extracting the Parameters

Interactive widgets are great for exploration, but they are generally bad for reproducible science if the parameters stay trapped in the UI.

When you have achieved the desired phase, click the Close button in the widget control bar. The canvas will unmount, and the widget will generate a strict, reproducible code snippet reflecting your final parameters.

Note: Screenshot only

Screenshot of the widget (part 2)

Click the Copy Code button, and paste it into the next cell in your notebook:

<Figure size 1200x450 with 1 Axes>

Because the pivot value is explicitly hardcoded into the generated snippet, your manual p1p_1 adjustment is guaranteed to produce the exact same mathematical output even if the array is later cropped, padded, or resampled!