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.

Visualizing Dynamic AMARES Fits

Following the quantification of spectra using time-domain fitting (Quick Start: Fitting a Spectrum for the call itself, AMARES Fitting in Depth for what it returns), the next critical step is interpreting the results.

When analyzing a 1D array of spectra—such as a dynamic time-series (fMRS), an echo-time series (relaxation mapping), or a 1D spatial CSI slice—researchers generally need to quickly answer two questions:

  1. The Kinetics: How do the metabolite concentrations change across the dimension?

  2. The Reliability: Did subject motion, shim drift, or hardware artifacts ruin the fit during specific repetitions?

To streamline this, xmris provides two dedicated visual accessors for Datasets: .xmr.plot.trajectory() and .xmr.plot.qc_grid().

Let’s generate a synthetic dynamic MRS dataset to see these tools in action.

1. Simulating a Dynamic Exercise Paradigm

We will simulate 60 consecutive repetitions representing a dynamic muscle exercise paradigm.

To make it realistic, we will simulate a “subject motion event” at repetition 15 and repetition 45 by injecting massive noise. This should trigger high uncertainty in our mathematical fit for those specific time points.

Source
<Figure size 750x300 with 1 Axes>

2. Fitting the Time Series

We fit the dynamic series using the parallel batch processor.

3. Plotting Trajectories with Confidence Bands

The .xmr.plot.trajectory() tool plots the extracted amplitudes over the dimension.

Crucially, it translates the mathematical CRLB percentage into an absolute error, drawing a shaded confidence interval behind the curve. When the fit degrades, the shaded region expands, visually communicating the exact level of uncertainty to the reader.

The band is the %CRLB read as an absolute error — amplitude * (%CRLB / 100) — so it widens exactly where the fit stops being able to pin the amplitude down. What a CRLB is, and why >20% is a flag to inspect rather than a threshold to discard covers the statistics behind it.

<Figure size 1200x600 with 1 Axes>

Look at the spikes around repetition time 30s (index 15) and 90s (index 45)! The shaded bands immediately draw attention to the uncertainty caused by the noise spikes. The default PlotTrajectoryConfig also highlights the exact points where the CRLB exceeded 20% by rendering them as hollow circles.

4. The Spectral Quality Control Grid

While the trajectory plot confirms the kinetics, it is recommended to visually inspect the raw spectra to ensure the mathematical model didn’t fail catastrophically (e.g., fitting noise instead of a peak).

xmris provides .xmr.plot.qc_grid(). Because trying to plot 60 spectra on top of each other in a waterfall plot is visually overwhelming, the qc_grid automatically generates a clean multi-panel overview.

<Figure size 5250x2250 with 60 Axes>

The QC grid successfully sampled 10 scans evenly across our experiment. It overlays the raw data in black and the mathematical fit in red, with the residual offset in green below.

<Figure size 1575x375 with 3 Axes>