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.

plotting.spectra

plotting.spectra

Functions

NameDescription
annotate_metabolitesAnnotate metabolite labels on a plot at specific ppm positions.
plot_fidPlot one or more FIDs against a time axis.
plot_spectraPlot one or more spectra against a chemical-shift (ppm) axis.
plot_spectra_over_timePlot MRS unlocalized spectra over time using a FacetGrid.
set_default_spectra_ax_paramsSet default spectra axis parameters for a given Axes object.
set_default_ticksSet default tick parameters for a given Axes object.

annotate_metabolites

plotting.spectra.annotate_metabolites(ax=None, freqs=None)

Annotate metabolite labels on a plot at specific ppm positions.

Parameters

NameTypeDescriptionDefault
axmatplotlib.axes.AxesThe axes to annotate. Defaults to the current axes.None
freqsdictMapping of metabolite name to ppm position. Defaults to a predefined set of common metabolites (DHO, Glu, Glx, Lac).None

Returns

NameTypeDescription
matplotlib.axes.AxesThe annotated axes.

plot_fid

plotting.spectra.plot_fid(
    data=None,
    time=None,
    fids=None,
    ax=None,
    labels=None,
    show_real=True,
    show_imag=True,
    **kwargs,
)

Plot one or more FIDs against a time axis.

Pass either data (an xr.DataArray with a time dim/coord, e.g. RawMRISeries.fids) or, as a manual fallback, both time (in ms) and fids as plain arrays. This function does no processing itself — build the time axis you want to see on the DataArray/array before calling.

plot_spectra

plotting.spectra.plot_spectra(
    data=None,
    ppm=None,
    spectra=None,
    ax=None,
    labels=None,
    line_kwargs=None,
    **kwargs,
)

Plot one or more spectra against a chemical-shift (ppm) axis.

Pass already-phased data — either data (an xr.DataArray with a chemical_shift dim/coord, e.g. from MRSSeries.phase_avg_spec or .xmr.phase()/.xmr.autophase()) or, as a manual fallback, both ppm and spectra as plain arrays. This function does no phasing itself.

plot_spectra_over_time

plotting.spectra.plot_spectra_over_time(
    df,
    labels=None,
    title='MRS Unlocalized Spectra Over Time',
    **kwargs,
)

Plot MRS unlocalized spectra over time using a FacetGrid.

Parameters

NameTypeDescriptionDefault
dfpandas.DataFrameDataFrame containing the spectra data with columns ["ppm", "Spectra_ID", "Intensity"].required
labelslist of strLabels for the spectra. Defaults to an empty list.None
titlestrFigure title. Defaults to “MRS Unlocalized Spectra Over Time”.'MRS Unlocalized Spectra Over Time'

Returns

NameTypeDescription
seaborn.FacetGridThe resulting FacetGrid.

set_default_spectra_ax_params

plotting.spectra.set_default_spectra_ax_params(ax, **kwargs)

Set default spectra axis parameters for a given Axes object.

set_default_ticks

plotting.spectra.set_default_ticks(ax)

Set default tick parameters for a given Axes object.