Skip to content

KomaMRIPlots ​

Plots display directly in Pluto without an extra wrapper or plotting dependency. Reruns preserve valid zoom, camera and legend selections. Nonadaptive plots keep their PlotlyBase.Plot return type and Plotly mutation/export APIs.

Adaptive plots require live Julia in REPL, Pluto, Jupyter, Quarto, and KomaUI. Nonadaptive figures work offline unless adaptive_navigator=true adds a live sequence panel to k-space. For Quarto live views, keep the Julia worker running with execute.daemon.

Plotting Phantom ​

KomaMRIPlots.plot_phantom_map Function
julia
p = plot_phantom_map(obj::Phantom, key::Symbol; kwargs...)

Plots a phantom map for a specific spin parameter given by key.

Arguments

  • obj: (::Phantom) Phantom struct

  • key: (::Symbol, opts: [:ρ, :T1, :T2, :T2s, :x, :y, :z, :speed, :vx, :vy, :vz]) symbol for displaying different parameters of the phantom spins (:speed and signed velocity components use frame-to-frame displacement in cm/s; components use blue/white/red for negative/zero/positive with fixed symmetric limits. Exiting spins flash magenta before a reset and cyan upon re-entry; reset jumps are excluded from the velocity scale).

Keywords — both modes

  • adaptive=false: return a self-contained PlotlyBase.Plot; true returns a live SpatialPlot, requiring Julia for zoom, camera and time updates.

  • height: (::Integer, =700) plot height

  • width: (::Integer, =nothing) plot width

  • darkmode: (::Bool, =false) boolean to indicate whether to display darkmode style

  • view_2d: use a 2D scatter plot; defaults to true for fewer than three spatial dimensions

  • colorbar: (::Bool, =true) boolean to indicate whether to display a colorbar

  • time_samples=0: add an evenly spaced time grid to the native motion timepoints; duplicates are removed, and native timepoints are never discarded. Static phantoms have one frame. Nonadaptive plots embed every resulting frame.

Keywords — only adaptive=false

  • max_spins: cap the embedded spin subset; defaults to 20,000 when omitted. Passing it with adaptive=true throws ArgumentError.

Returns

  • p: PlotlyBase.Plot when adaptive=false, otherwise SpatialPlot

References

Colormaps from https://github.com/markgriswold/MRFColormaps Towards Unified Colormaps for Quantitative MRF Data, Mark Griswold, et al. (2018).

Examples

julia
julia> obj2D, obj3D = brain_phantom2D(), brain_phantom3D();

julia> plot_phantom_map(obj2D, :ρ)

julia> plot_phantom_map(obj3D, :ρ)
source
KomaMRIPlots.SpatialPlot Type
julia
SpatialPlot

Live Plotly spatial viewer returned by plot_phantom_map(...; adaptive=true) and plot_coil_sens(...; adaptive=true) and plot_kspace(...; adaptive=true). Zooming, rotating and changing time or coil fetch detail from Julia; keep the Julia session running, including in notebooks. The default adaptive=false remains a self-contained PlotlyBase.Plot.

Phantom sampling retains original spin IDs and property values. Two-dimensional views retain screen-cell extrema; 3D views sample throughout spatial voxels. All spins remain available on zoom. Only spins inside the viewport consume its sampling budget, including during motion previews. max_spins is only accepted with adaptive=false. Keyword availability is documented on each plot_* function. Motion bounds are scanned once, one frame at a time, to keep axes fixed. The coordinate cache retains only two frames. Camera and color limits remain unchanged when selecting a time. Dragging or playing motion uses a stable spin preview; stopping restores spatial detail. The final frame shows the recorded endpoint; playback wrapping is not a flow-reset event.

Coil maps refine a grid down to spacing, evaluating get_sens only at selected positions. Their magnitude scale uses a model-wide bound shared by all coils. An in-plot indicator marks reduced spatial detail, not missing simulation data.

source
KomaMRIPlots.plot_phantom Function
julia
plot_phantom(obj; key=:ρ, adaptive=false, kwargs...)

Plot intrinsic phantom properties and motion-derived speed/velocity in one viewer. Property buttons share spin coordinates, camera and the time slider. kwargs are the display options of plot_phantom_map. Velocities are in cm/s; magenta and cyan mark exit and re-entry, excluding reset jumps from velocity estimates.

The default is a self-contained Plotly plot. With adaptive=true, Julia supplies visible spins on demand and playback loops over the interval in five seconds, skipping display frames when necessary; every time step remains selectable.

Keywords — both modes

  • key=:ρ: initially selected property.

  • time_samples=0: add an evenly spaced time grid to the native motion timepoints; duplicates are removed, and native timepoints are never discarded. Static phantoms have one frame. Nonadaptive plots embed every resulting frame.

  • view_2d: defaults to true for phantoms with fewer than three spatial dimensions.

  • height, width, darkmode, colorbar, and color limits: see plot_phantom_map.

Keywords — only adaptive=false

  • max_spins: cap the embedded spin subset; defaults to 20,000 when omitted. Passing it with adaptive=true throws ArgumentError; live sampling uses the viewport.
source
KomaMRIPlots.plot_phantom_slice Function
julia
plot_phantom_slice(obj; thickness=5e-3, center=nothing, key=:ρ, adaptive=false, kwargs...)

Show linked axial (x–y), sagittal (z–y), and coronal (x–z) spin projections. Coronal and axial reverse x. thickness and the three-component center are in metres. The default center uses spins nearest the middle of each coordinate range. Scroll a panel or use its position slider to move its slab; click a spin to position the linked edge ticks. Slabs are fixed in space and use current spin positions during motion.

Property and time controls are shared. adaptive=true filters slabs before viewport sampling and requires live Julia. The default returns a self-contained PlotlyBase.Plot, embedding all spins and motion frames so every slab remains available offline. max_spins optionally caps that embedded set; it is not accepted with adaptive=true. Other display keywords match plot_phantom.

source

Plotting receive sensitivities ​

KomaMRIPlots.plot_coil_sens Function
julia
plot_coil_sens(sys; fov=nothing, spacing=0.01, height=700, width=nothing,
    darkmode=false, adaptive=false)

Plot receive-coil sensitivities without a phantom. Coordinates and spacing are in metres; axes are displayed in centimetres. The sampling grid is centred in the receiver's bounds and spaced by spacing, independently of its field of view.

fov=(Lx, Ly, Lz) overrides the displayed extent in metres, centred on the model's bounds; a zero extent selects a plane. When omitted, get_coil_sens_fov provides the extent. The override does not change the receiver or its sensitivities; arbitrary maps return zero outside their sampled support.

Uniform sensitivities use a 256 mm box. Birdcage sensitivities use the cylinder's half-length L and 90% of its radius, avoiding the ideal-wire singularities. Sampled sensitivities use their stored coordinate bounds. Planar maps are plotted in their plane; volumetric maps use a 3D point cloud with equal spatial scales.

The self-contained plot has a coil selector above it (only for multiple coils) and Magnitude/Phase buttons below. Magnitude uses a grayscale range shared by all coils; phase uses a cyclic scale over [-π, π]. Values come directly from get_sens, without spin-density weighting or per-coil normalization.

With adaptive=true, return a live SpatialPlot: refine the visible grid on zoom or camera changes, down to spacing, without constructing the finest full volume. Coil and component controls fetch only the selected data. Julia must remain running; the default plot is self-contained.

Keywords — both modes

All keywords in the signature apply to both modes. spacing is the embedded grid spacing with adaptive=false, and the finest grid spacing with adaptive=true. fov, height, width, and darkmode retain the same meaning in either mode.

source
KomaMRIPlots.get_coil_sens_fov Function
julia
get_coil_sens_fov(receiver)

Return the default plotting extent (Lx, Ly, Lz) in metres for a receive model. Uniform sensitivities use a 256 mm cube, Birdcage uses its diameter and full length, and arbitrary sensitivities use their sampled coordinate spans. A zero span denotes a plane. This is a display extent, not a physical sensitivity cutoff.

source

Plotting Sequence ​

Sequence-like plots and plot_signal return a regular PlotlyBase.Plot by default. Set adaptive=true to fetch detailed samples on zoom or pan. This live mode requires the Julia session to remain running; KomaUI enables it automatically.

julia
plot_seq(seq)                  # Regular Plotly figure
plot_seq(seq; adaptive=true)   # Live adaptive viewer
KomaMRIPlots.TimePlot Type
julia
TimePlot

A Plotly time-series viewer that obtains visible samples from Julia on zoom or pan. Display it directly in Pluto, IJulia/Jupyter, or a browser, or embed it in a Bonito app. The Julia session must remain running for new detail. Created with adaptive=true; the default adaptive=false returns a regular PlotlyBase.Plot. Keyword availability is documented on each plot_* function; nonadaptive-only keywords cannot be passed with adaptive=true.

source
KomaMRIPlots.plot_seq Function
julia
plot_seq(seq; adaptive=false, physio=NoPhysioSignal(), slider=false, kwargs...)

Plot sequence waveforms as a regular PlotlyBase.Plot. Set adaptive=true for a live TimePlot that fetches detail from Julia on zoom or pan. The Julia session must remain running; an indicator marks reduced samples.

Keywords — both modes

  • width=nothing, height=nothing: plot dimensions in pixels.

  • slider=false, darkmode=false, title="": display controls.

  • range=[]: initial time range in milliseconds.

  • physio=NoPhysioSignal(): resolve triggers and display physiology.

Keywords — only adaptive=false

  • gl=false: use WebGL traces.

  • show_seq_blocks=false: label sequence block boundaries.

  • show_adc=false: show individual ADC sample markers.

  • max_rf_samples=100: cap embedded RF samples per event.

  • freq_in_phase=false: fold RF frequency modulation into the displayed phase.

  • show_rf_frame=false: display the RF rotating-frame phase.

  • xaxis="x", yaxis="y", showlegend=true: trace layout controls.

Passing nonadaptive-only keywords with adaptive=true throws ArgumentError. Adaptive RF samples are uncapped; vertical ADC ticks appear automatically when sufficiently separated. Trigger timing and labels use the full resolved sequence. Multiple RF channels currently use full trace construction before adaptive sampling.

source
KomaMRIPlots.plot_kspace Function
julia
p = plot_kspace(seq::Sequence; width=nothing, height=nothing, darkmode=false, view_2d=false, adaptive=false, adaptive_navigator=false, physio=NoPhysioSignal())

Plots the k-space of a Sequence struct.

Arguments

  • seq: (::Sequence) Sequence struct

Keywords

  • width: (::Integer, =nothing) plot width

  • height: (::Integer, =nothing) plot height

  • darkmode: (::Bool, =false) boolean to indicate whether to display darkmode style

  • view_2d: (::Bool, =false) boolean to indicate whether to use a 2D kx/ky plot

  • physio=NoPhysioSignal(): physiological signal used to resolve trigger waits and ADC times

  • adaptive=false: use an experimental live SpatialPlot when true. Julia retains the full trajectory; zoom/rotation fetch bounded sets of original segments and ADCs.

  • adaptive_navigator=false: show a compact adaptive sequence navigator when true, without a legend or secondary slider. Zoom its time axis to filter k-space after dragging stops; colors retain their global ADC sample count. The sequence navigator requires a running Julia session in both k-space modes.

Returns

  • p: PlotlyBase.Plot with adaptive=false, or live SpatialPlot otherwise. Adaptive updates require the Julia session to remain running.

Examples

julia
julia> seq_file = joinpath(dirname(pathof(KomaMRI)), "../examples/1.sequences/spiral.seq")

julia> seq = read_seq(seq_file)

julia> plot_kspace(seq)
source
KomaMRIPlots.plot_M0 Function
julia
plot_M0(seq; adaptive=false, physio=NoPhysioSignal(), kwargs...)

Plot the zero-order gradient moment. Return a self-contained PlotlyBase.Plot, or a live TimePlot with adaptive=true.

Keywords — both modes

width=nothing, height=nothing, slider=false, show_seq_blocks=false, darkmode=false, range=[] (milliseconds), title="", and physio=NoPhysioSignal(). Both modes construct the full moment arrays; adaptive mode limits displayed samples. There are no nonadaptive-only keywords.

source
KomaMRIPlots.plot_M1 Function
julia
plot_M1(seq; adaptive=false, physio=NoPhysioSignal(), kwargs...)

Plot the first-order gradient moment. Keywords and mode behavior match plot_M0. All plotting keywords apply in both modes.

source
KomaMRIPlots.plot_M2 Function
julia
plot_M2(seq; adaptive=false, physio=NoPhysioSignal(), kwargs...)

Plot the second-order gradient moment. Keywords and mode behavior match plot_M0. All plotting keywords apply in both modes.

source
KomaMRIPlots.plot_eddy_currents Function
julia
plot_eddy_currents(seq, λ; adaptive=false, physio=NoPhysioSignal(), kwargs...)

Plot eddy currents with time constants λ in seconds and weights α=ones(size(λ)). Other keywords and mode behavior match plot_M0. All plotting keywords, including α, apply in both modes.

source
KomaMRIPlots.plot_slew_rate Function
julia
plot_slew_rate(seq; adaptive=false, physio=NoPhysioSignal(), kwargs...)

Plot gradient slew rate. Keywords and mode behavior match plot_M0. All plotting keywords apply in both modes.

source
KomaMRIPlots.plot_seqd Function
julia
plot_seqd(seq; adaptive=false, physio=NoPhysioSignal(), kwargs...)

Plot discretized waveforms as a self-contained PlotlyBase.Plot, or a live TimePlot with adaptive=true.

Keywords — both modes

sampling_rule=MaxStepSizeRule(1e-3, 5e-5), show_rf_frame=true, freq_in_phase=false, and physio=NoPhysioSignal(). sampling_rule controls the underlying discretization, not viewport downsampling. Both modes construct the full sampled arrays. There are no nonadaptive-only keywords.

source

Plotting RawAcquisitionData ​

KomaMRIPlots.plot_signal Function
julia
plot_signal(raw; adaptive=false, kwargs...)

Plot raw signals with coil selection as a self-contained PlotlyBase.Plot, or a live TimePlot with adaptive=true.

Keywords — both modes

width=nothing, height=nothing, slider=false, show_sim_blocks=false, darkmode=false, range=[] (milliseconds), and gl=false. Both modes construct the full signal arrays. There are no nonadaptive-only keywords.

source

Plotting images ​

KomaMRIPlots.plot_image Function
julia
p = plot_image(image; height, width, zmin, zmax, darkmode, title)

Plot real image values directly. Volumes show linked x–y, z–y and x–z planes. Complex images initially show magnitude and include Magnitude/Phase buttons below the plot. Single-column images are shown as line profiles.

Arguments

  • image: a real or complex image matrix or volume

Keywords

  • width: (::Integer, =nothing) plot width

  • height: (::Integer, =nothing) plot height

  • zmin, zmax: color limits; for complex images these apply to magnitude only

  • colorscale: (="Greys") color scale for real values or magnitude; phase uses a cyclic scale over [-π, π] radians

  • darkmode: (::Bool, =false) boolean to indicate whether to display darkmode style

  • title: (::String, ="") plot title

  • spacing=(1,1,1): voxel spacing for volumes; axes display voxel indices

Middle-button drag adjusts window width horizontally and level vertically. Double-click resets window and zoom; phase keeps its fixed scale.

Returns

  • p: (::PlotlyBase.Plot) plot of the image matrix
source

Others ​

KomaMRIPlots.plot_dict Function
julia
str = plot_dict(dict::Dict)

Generates an HTML table based on the dictionary dict.

Arguments

  • dict: (::Dict) dictionary

Returns

  • str: (::String) dictionary as an HTML table
source
KomaMRIPlots.savefig Function

Save a Plotly figure, starting Kaleido when needed.

source