bids.reports.utils

Generate publication-quality data acquisition methods section from BIDS dataset.

Utilities to generate the MRI data acquisition portion of a methods section from a BIDS dataset.

Functions

get_seqstr(config, metadata) Extract and reformat imaging sequence(s) and variant(s) into pretty strings.
get_sizestr(img) Extract and reformat voxel size, matrix size, field of view, and number of slices into pretty strings.
get_slice_info(slice_times) Extract slice order from slice timing info.
list_to_str(lst) Turn a list into a comma- and/or and-separated string.
num_to_str(num) Convert an int or float to a nice string.
reminder() Remind users about things they need to do after generating the report.
remove_duplicates(seq) Return unique elements from list while preserving order.
get_seqstr(config, metadata)[source]

Extract and reformat imaging sequence(s) and variant(s) into pretty strings.

Parameters:
  • config (dict) – A dictionary with relevant information regarding sequences, sequence variants, phase encoding directions, and task names.
  • metadata (dict) – The metadata for the scan.
Returns:

  • seqs (str) – Sequence names.
  • variants (str) – Sequence variant names.

get_sizestr(img)[source]

Extract and reformat voxel size, matrix size, field of view, and number of slices into pretty strings.

Parameters:img (nibabel.Nifti1Image) – Image from scan from which to derive parameters.
Returns:
  • n_slices (int) – Number of slices.
  • voxel_size (str) – Voxel size string (e.g., ‘2x2x2’)
  • matrix_size (str) – Matrix size string (e.g., ‘128x128’)
  • fov (str) – Field of view string (e.g., ‘256x256’)
get_slice_info(slice_times)[source]

Extract slice order from slice timing info.

TODO: Be more specific with slice orders. Currently anything where there’s some kind of skipping is interpreted as interleaved of some kind.

Parameters:slice_times (array-like) – A list of slice times in seconds or milliseconds or whatever.
Returns:slice_order_name – The name of the slice order sequence.
Return type:str
list_to_str(lst)[source]

Turn a list into a comma- and/or and-separated string.

Parameters:lst (list) – A list of strings to join into a single string.
Returns:str_ – A string with commas and/or ands separating th elements from lst.
Return type:str
num_to_str(num)[source]

Convert an int or float to a nice string. E.g.,

21 -> ‘21’ 2.500 -> ‘2.5’ 3. -> ‘3’
reminder()[source]

Remind users about things they need to do after generating the report.

remove_duplicates(seq)[source]

Return unique elements from list while preserving order. From https://stackoverflow.com/a/480227/2589328