xcp_d.utils.plotting module
Plotting tools.
- class xcp_d.utils.plotting.FMRIPlot(func_file, mask_file=None, data=None, confound_file=None, seg_file=None, TR=None, usecols=None, units=None, vlines=None, spikes_files=None)[source]
Bases:
object
Generates the fMRI Summary Plot.
- Parameters:
func_file
mask_file
data
confound_file
seg_file
TR (
float
) – Repetition time of the BOLD run, in seconds.usecols
units
vlines
spikes_files
- TR
- confounds
- func_file
- mask_data
- seg_data
- spikes
- xcp_d.utils.plotting.plot_alff_reho_surface(output_path, filename, name_source)[source]
Plot ReHo and ALFF for ciftis on surface.
NOTE: This is a Node function.
- xcp_d.utils.plotting.plot_alff_reho_volumetric(output_path, filename, name_source)[source]
Plot ReHo and ALFF mosaics for niftis.
NOTE: This is a Node function.
- xcp_d.utils.plotting.plot_carpet(*, func, atlaslabels, TR, standardize, temporal_mask=None, size=(950, 800), labelsize=30, subplot=None, lut=None, colorbar=False, output_file=None)[source]
Plot an image representation of voxel intensities across time.
This is also known as the “carpet plot” or “Power plot”. See Jonathan Power Neuroimage 2017 Jul 1; 154:150-158.
- Parameters:
func (
str
) – Path to NIfTI or CIFTI BOLD imageatlaslabels (numpy.ndarray, optional) – A 3D array of integer labels from an atlas, resampled into
img
space. Required iffunc
is a NIfTI image. Unused iffunc
is a CIFTI.standardize (bool, optional) – Detrend and standardize the data prior to plotting.
size (tuple, optional) – Size of figure.
labelsize (int, optional)
subplot (matplotlib Subplot, optional) – Subplot to plot figure on.
output_file (
str
or None, optional) – The name of an image file to export the plot to. Valid extensions are .png, .pdf, .svg. If output_file is not None, the plot is saved to a file, and the display is closed.legend (bool) – Whether to render the average functional series with
atlaslabels
as overlay.TR (float, optional) – Specify the TR, if specified it uses this value. If left as None, # of frames is plotted instead of time.
lut (numpy.ndarray, optional) – Look up table for segmentations
colorbar (bool, optional) – Default is False.
- xcp_d.utils.plotting.plot_confounds(time_series, grid_spec_ts, gs_dist=None, name=None, units=None, TR=None, hide_x=True, color='b', cutoff=None, ylims=None)[source]
Create a time series plot for confounds.
Adapted from niworkflows.
- Parameters:
time_series (numpy.ndarray) – Time series to plot in the figure.
grid_spec_ts (GridSpec) – The GridSpec object in which the time series plot will be stored.
name – file name
units – time_series unit
TR (float or None, optional) – Repetition time for the time series. Default is None.
- Returns:
time_series_axis
grid_specification
- xcp_d.utils.plotting.plot_design_matrix(design_matrix, temporal_mask=None)[source]
Plot design matrix TSV with Nilearn.
NOTE: This is a Node function.
- xcp_d.utils.plotting.plot_dvars_es(time_series, ax, run_index=None)[source]
Create DVARS plot for the executive summary.
- xcp_d.utils.plotting.plot_fmri_es(*, preprocessed_bold, denoised_interpolated_bold, TR, filtered_motion, temporal_mask, preprocessed_figure, denoised_figure, standardize, temporary_file_dir, mask=None, seg_data=None, run_index=None)[source]
Generate carpet plot with DVARS, FD, and WB for the executive summary.
- Parameters:
preprocessed_bold (
str
) – Preprocessed BOLD file, dummy scan removal.denoised_interpolated_bold (
str
) – Path to the censored, denoised, interpolated, and filtered BOLD file. This file is the result of denoising the censored preprocessed BOLD data, followed by cubic spline interpolation and band-pass filtering.This output should not be used for analysis. It is primarily for DCAN QC plots.
TR (
float
) – Repetition time of the BOLD run, in seconds.filtered_motion (
str
) – Framewise displacement timeseries, potentially after bandstop or low-pass filtering. This is a TSV file with one column: ‘framewise_displacement’.temporal_mask (
str
) – Temporal mask; all values abovefd_thresh
set to 1. This is a TSV file with one column: ‘framewise_displacement’. Only non-outlier (low-motion) volumes in the temporal mask will be used to scale the carpet plot.preprocessed_figure (
str
) – output file svg before processingdenoised_figure (
str
) – output file svg after processingstandardize (
bool
) – Whether to standardize the data or not. If False, then the preferred DCAN version of the plot will be generated, where the BOLD data are not rescaled, and the carpet plot has color limits from the 2.5th percentile to the 97.5th percentile. If True, then the BOLD data will be z-scored and the color limits will be -2 and 2.temporary_file_dir (
str
) – Path in which to store temporary files.mask (
str
, optional) – Brain mask file. Used only when the pre- and post-processed BOLD data are NIFTIs.seg_data (
str
, optional) – Three-tissue segmentation file. This is only used for NIFTI inputs. With CIFTI inputs, the tissue types are inferred directly from the CIFTI file.run_index (None or array_like, optional) – An index indicating splits between runs, for concatenated data. If not None, this should be an array/list of integers, indicating the volumes.
- xcp_d.utils.plotting.plot_framewise_displacement_es(time_series, ax, TR, run_index=None)[source]
Create framewise displacement plot for the executive summary.
- xcp_d.utils.plotting.plot_global_signal_es(time_series, ax, run_index=None)[source]
Create global signal plot for the executive summary.
- xcp_d.utils.plotting.surf_data_from_cifti(data, axis, surf_name)[source]
From https://neurostars.org/t/separate-cifti-by-structure-in-python/17301/2.
https://nbviewer.org/github/neurohackademy/nh2020-curriculum/blob/master/ we-nibabel-markiewicz/NiBabel.ipynb