Writing methods reports with pybids.reportsΒΆ

This tutorial

%load_ext autoreload
%autoreload 2

from bids import BIDSLayout
from bids.reports import BIDSReport
from bids.tests import get_test_data_path
import os
dataset = "synthetic"

# Here we're using an example BIDS dataset that's bundled with the pybids tests
data_path = os.path.join(get_test_data_path(), dataset)

# Load the BIDS dataset
layout = BIDSLayout(data_path)
# Initialize a report for the dataset
report = BIDSReport(layout)
# Method generate returns a Counter of unique descriptions across subjects
descriptions = report.generate()
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-01_ses-01_magnitude1.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-01_ses-01_magnitude2.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/layout/models.py:229: UserWarning: Accessing entities as attributes is deprecated as of 0.7. Please use the .entities dictionary instead (i.e., .entities['run'] instead of .run.
  warnings.warn("Accessing entities as attributes is deprecated as "
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-02_ses-01_magnitude1.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-02_ses-01_magnitude2.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-03_ses-01_magnitude1.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-03_ses-01_magnitude2.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-04_ses-01_magnitude1.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-04_ses-01_magnitude2.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-05_ses-01_magnitude1.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/reports/parsing.py:386: UserWarning: sub-05_ses-01_magnitude2.nii.gz not yet supported.
  warnings.warn(group[0].filename + " not yet supported.")
Number of patterns detected: 1
Remember to double-check everything and to replace <deg> with a degree symbol.
# For datasets containing a single study design, all but the most common
# description most likely reflect random missing data.
pub_description = descriptions.most_common()[0][0]
print(pub_description)
In session 01, MR data were acquired using a UNKNOWN-Tesla MANUFACTURER MODEL MRI scanner.
	One run of T1-weighted   single-echo structural MRI data were collected (256 slices; repetition time, TR=2500ms; echo time, TE=2.9ms; flip angle, FA=8<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm).
	One run of T1-weighted   single-echo structural MRI data were collected (256 slices; repetition time, TR=2500ms; echo time, TE=2.9ms; flip angle, FA=8<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm).
	One run of   diffusion-weighted (dMRI) data were collected (repetition time, TR=8400ms; echo time, TE=90ms; flip angle, FA=90<deg>; field of view, FOV=128x128mm; voxel size=2x2x2mm; matrix size=64x64; b-values of 0 and 1000 acquired; 64 diffusion directions).
	A   field map (phase encoding: anterior to posterior; 256 slices; repetition time, TR=400ms; echo time 1 / 2, TE1/2=5190007.65ms; flip angle, FA=60.0<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm) was acquired for the first and second runs of the N-Back BOLD scan.
	Two runs of N-Back   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	Two runs of N-Back   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of Rest   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of Rest   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of T1-weighted   single-echo structural MRI data were collected (256 slices; repetition time, TR=2500ms; echo time, TE=2.9ms; flip angle, FA=8<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm).
	One run of T1-weighted   single-echo structural MRI data were collected (256 slices; repetition time, TR=2500ms; echo time, TE=2.9ms; flip angle, FA=8<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm).
	Two runs of N-Back   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	Two runs of N-Back   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of Rest   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of Rest   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	In session 02, MR data were acquired using a UNKNOWN-Tesla MANUFACTURER MODEL MRI scanner.
	One run of T1-weighted   single-echo structural MRI data were collected (256 slices; repetition time, TR=2500ms; echo time, TE=2.9ms; flip angle, FA=8<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm).
	One run of T1-weighted   single-echo structural MRI data were collected (256 slices; repetition time, TR=2500ms; echo time, TE=2.9ms; flip angle, FA=8<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm).
	One run of   diffusion-weighted (dMRI) data were collected (repetition time, TR=8400ms; echo time, TE=90ms; flip angle, FA=90<deg>; field of view, FOV=128x128mm; voxel size=2x2x2mm; matrix size=64x64; b-values of 0 and 1000 acquired; 64 diffusion directions).
	A   field map (phase encoding: anterior to posterior; 256 slices; repetition time, TR=400ms; echo time 1 / 2, TE1/2=5190007.65ms; flip angle, FA=60.0<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm) was acquired for the first and second runs of the N-Back BOLD scan.
	Two runs of N-Back   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	Two runs of N-Back   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of Rest   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of Rest   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of T1-weighted   single-echo structural MRI data were collected (256 slices; repetition time, TR=2500ms; echo time, TE=2.9ms; flip angle, FA=8<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm).
	One run of T1-weighted   single-echo structural MRI data were collected (256 slices; repetition time, TR=2500ms; echo time, TE=2.9ms; flip angle, FA=8<deg>; field of view, FOV=256x256mm; matrix size=256x256; voxel size=1x1x1mm).
	Two runs of N-Back   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	Two runs of N-Back   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of Rest   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.
	One run of Rest   single-echo fMRI data were collected (64 slices; repetition time, TR=2500ms; echo time, TE=30ms; flip angle, FA=UNKNOWN<deg>; field of view, FOV=128x128mm; matrix size=64x64; voxel size=2x2x2mm). Run duration was 2:40 minutes, during which 64 volumes were acquired.

Dicoms were converted to NIfTI-1 format. This section was (in part) generated automatically using pybids (0.16.4).