Per-Volume fMRI Phase#

Visualize the mean gastric phase per fMRI volume using plot_volume_phase. This is the core quantity used in gastric-brain coupling analyses. Cut regions at the start and end (to remove filter transients) are highlighted.

import matplotlib.pyplot as plt

import gastropy as gp
from gastropy.neuro.fmri import create_volume_windows, phase_per_volume

plt.rcParams["figure.dpi"] = 100
plt.rcParams["figure.facecolor"] = "white"
# Load fMRI-concurrent EGG
fmri = gp.load_fmri_egg(session="0001")
signal = fmri["signal"]
sfreq = fmri["sfreq"]
tr = fmri["tr"]
trigger_times = fmri["trigger_times"]

# Select best channel and process
best_idx, _, _, _ = gp.select_best_channel(signal, sfreq)
filtered, _ = gp.apply_bandpass(signal[best_idx], sfreq, low_hz=gp.NORMOGASTRIA.f_lo, high_hz=gp.NORMOGASTRIA.f_hi)
phase, analytic = gp.instantaneous_phase(filtered)

# Create volume windows and extract phase
n_volumes = len(trigger_times)
windows = create_volume_windows(trigger_times, tr, n_volumes)
vol_phase = phase_per_volume(analytic, windows)
print(f"{n_volumes} volumes, TR={tr} s")
420 volumes, TR=1.856 s

Basic Volume Phase Plot#

fig, ax = gp.plot_volume_phase(vol_phase, tr=tr)
plt.show()
../_images/33524a247a9e94ac008b88d7fdf4227b8a86fe495dbb8e5d6213255f5dca38f4.png

With Cut Regions#

Highlight the first and last 21 volumes that would typically be discarded to remove filter edge transients.

fig, ax = gp.plot_volume_phase(vol_phase, tr=tr, cut_start=21, cut_end=21)
plt.show()
../_images/c793be8fde3400f83740a6acf3ef1e8ed3cd0f4d7175aaaa7c21fd4828a3c852.png

Volume Index X-Axis#

Omit tr to use volume index instead of time on the x-axis.

fig, ax = gp.plot_volume_phase(vol_phase, cut_start=21, cut_end=21)
plt.show()
../_images/53707b98964cece3c15daca62f4314d0e0b4aa9e64dbd365e31559d161b9ec04.png

See also: fMRI-EGG Pipeline, Comprehensive Figure