API

PipelineQC.reportlets.assemble(*, out_file, in_files, title, prev=None, next_=None, relative_dir=None)

combine multiple html files into one file

Parameters:
  • out_file (path-like object) – output html file
  • in_files (list of path-like objects) – list of input files to include
  • title (str) – title of html page
  • prev (path-like object) – Name of previous qc page for linking
  • next (path-like object) – Name of next qc page for linking
  • relative_dir (path-like object) – Create links to filenames relative to this directory
PipelineQC.reportlets.compare(*, name1, image1, name2, image2, out_file, relative_dir=None, slice_to_image2=False, nslices=7, max_intensity_fraction_image1=0.99, max_intensity_fraction_image2=0.99, description='', **kwargs)

Write an html file to out_file comparing image1 with image2 with nslices slices in all three axial planes

Parameters:
  • name1 (str) – Name describing image1
  • image1 (path-like object or None) – Image file name to show (readable by nibabel)
  • name2 (str) – Name describing image2
  • image2 (path-like object or None) – Image file name to show (readable by nibabel)
  • out_file (path-like object) – File name
  • relative_dir (path-like object) – Create links to filenames relative to this directory
  • slice_to_image2 (bool) – Calculate slices based on non-zero extent of image2
  • nslices (int) – Number of slices to show in each plane
  • description (str) – Description of reportlet
Max_intensity_fraction_image1:
 

see imshowfig()

Max_intensity_fraction_image2:
 

see imshowfig()

keyword arguments are passed to imshowfig

PipelineQC.reportlets.contours(*, name, image, labelimage, out_file, relative_dir=None, slice_to_label=False, nslices=7, description='', threshold_above_zero=False, **kwargs)

Write an html file to out_file showing the image with nslices slices in all three axial planes. Include contour lines outlining the areas defined by labels.

Parameters:
  • name (str) – Name describing image
  • image (path-like object or None) – Image file name to show (readable by nibabel)
  • labelimage (path-like object or None) – Label file name to draw contours from (readable by nibabel)
  • out_file (path-like object) – File name
  • relative_dir (path-like object) – Create links to filenames relative to this directory
  • slice_to_label (bool) – Calculate slices based on non-zero extent of labelimage
  • nslices (int) – Number of slices to show in each plane
  • description (str) – Description of reportlet
  • threshold_above_zero (bool) – If true, threshold the image with >0 and draw a contour at 0.5

keyword arguments are passed to imshowfig

PipelineQC.reportlets.crash(*, name, crashfiles, out_file, relative_dir=None)

Write an html file to out_file with crashfile information.

Parameters:
  • name (str) – Name describing the reportlet
  • crashfiles (list) – Files of a type readable by nipype.utils.filemanip.loadcrash or a txt file. An empty list indicates no crash files, and therefore success.
  • out_file (path-like object) – File name
  • relative_dir (path-like object) – Create links to filenames relative to this directory
PipelineQC.reportlets.distributions(*, name, distsfile, out_file, labelfile, relative_dir=None, description='')

Write an html file to out_file showing the distributions defined in distsfile.

Parameters:
  • name (str) – Name describing distsfile
  • distsfile (path-like object or None) – Distribution file name. Must be a TSV file with two columns “value”, and “index”. “value” is a point in distribution indexed by “index”.
  • out_file (path-like object) – File name
  • labelfile (path-like object or None) – TSV file containing “index” and “name” columns. Used to label distributions. (“index” corresponds to the second column in distsfile)
  • relative_dir (path-like object) – Create links to filenames relative to this directory
  • description (str) – Description of reportlet
PipelineQC.reportlets.imshowfig(*, niimg, nslices=7, image_width=1.5, image_height=1.5, maxcols=8, contour_width=1.5, nilabel=None, separate_figs=False, reference=None, all_slice_locations=None, max_intensity_fraction=0.99, labeldisplay='contour', affine_absolute_tolerance=0.001, affine_relative_tolerance=1e-05, transparency=0.5, contour_levels=None)

Create a figure (or nested list of figures) from imgfile

Parameters:
  • niimg (nibabel.Nifti1Image) – image
  • nslices (int) – The number of slices per view
  • image_width (float) – The width of each axes/image (in.)
  • image_height (float) – The width of each axes/image (in.)
  • maxcols (int) – The maximum number of columns (only when spearate_figs is False)
  • contour_width (float) – The width of contour lines (pts.)
  • nilabel (nibabel.Nifti1Image) – Image of labels readable by nibabel
  • separate_figs (bool) – Whether to create separate figures for each image
  • reference (nibabel.Nifti1Image) – Resample niimg to this reference image
  • all_slice_locations (list of list of int) – where to slice each axis
  • max_intensity_fraction (float) –

    The intensity display range is 0, max where max is calculated as:

    vals = np.sort(niimg.get_fdata()).ravel()
    vals = vals[vals > 0]
    max = vals[int(len(vals) * max_intensity_fraction)]
    
  • labeldisplay (str) – How to display nilabel. Either contour, overlay, probmap, or contour_nonzero
Name affine_absolute_tolerance:
 

pass to numpy.allclose as atol

Name affine_relative_tolerance:
 

pass to numpy.allclose as rtol

Name transparency:
 

Transparency over overlay

Name contour_levels:
 

The levels at which to draw the contours.

Returns:

matplotlib.figure.Figure or a list of lists of matplotlib.figure.Figure

PipelineQC.reportlets.index(*, out_file, in_files, relative_dir=None)

Construct an html file linking all to other files

Parameters:
  • out_file (path-like object) – output html file with links
  • in_file (list of path-like object) – list of html files to link to from out_file
  • relative_dir (path-like object) – Create links to filenames relative to this directory
PipelineQC.reportlets.rating(*, name, widgets, out_file)

Write an html file to out_file descripting a rating tool

Parameters:
  • name (str) – Name descripting the reportlet
  • widgets (list) – List of dictionaries describing the different widgets
  • out_file (path-like object) – File name
Example:
widgets = [{'type': 'radio',
            'name': 'Overall',
            'options': [{'name': 'Poor', 'value': 1},
                        {'name': 'Good', 'value': 2},
                        {'name': 'Excellent', 'value': 3}]},
           {'type': 'checkbox',
            'name': 'Notes',
            'fields': ['Poor registration',
                       'Poor segmentation',
                       'Poor initial T1 quality']},
           {'type': 'text',
            'name': 'Other'}]
rating('Rating', widgets, 'out.html')
PipelineQC.reportlets.single(*, name, image, out_file, relative_dir=None, description='', **kwargs)

Write an html file to out_file showing the image with nslices slices in all three axial planes

Parameters:
  • name (str) – Name describing image
  • image (path-like object or None) – Image file name to show (readable by nibabel)
  • out_file (path-like object) – File name
  • relative_dir (path-like object) – Create links to filenames relative to this directory
  • description (str) – Description of reportlet

keyword arguments are passed to imshowfig