nireports.assembler.reportlet module

The reporting visualization unit or reportlet.

class nireports.assembler.reportlet.Reportlet(layout, config=None, out_dir=None, bids_filters=None, metadata=None)[source]

Bases: object

A visual report atom (reportlet).

A reportlet has title, description and a list of components with either an HTML fragment or a path to an SVG file, and possibly a caption. This is a factory class to generate Reportlets reusing the layout from a Report object.

Examples

>>> bl.get(subject='01', desc='reconall')[0]._path.as_posix() 
'.../nireports/sub-01/figures/sub-01_desc-reconall_T1w.svg'
>>> len(bl.get(subject='01', space='.*', regex_search=True))
2
>>> r = Reportlet(bl, out_dir=out_figs, config={
...     'title': 'Some Title', 'bids': {'datatype': 'figures', 'desc': 'reconall'},
...     'description': 'Some description'})
>>> r.name
'datatype-figures_desc-reconall'
>>> '<img ' in r.components[0][0]
True
>>> r = Reportlet(bl, out_dir=out_figs, config={
...     'title': 'Some Title', 'bids': {'datatype': 'figures', 'desc': 'reconall'},
...     'description': 'Some description', 'static': False})
>>> r.name
'datatype-figures_desc-reconall'
>>> '<object ' in r.components[0][0]
True
>>> r = Reportlet(bl, out_dir=out_figs, config={
...     'title': 'Some Title', 'bids': {'datatype': 'figures', 'desc': 'summary'},
...     'description': 'Some description'})
>>> '<h3 ' in r.components[0][0]
True
>>> r.components[0][1] is None
True
>>> r = Reportlet(bl, out_dir=out_figs, config={
...     'title': 'Some Title',
...     'bids': {'datatype': 'figures', 'space': '.*', 'regex_search': True},
...     'caption': 'Some description {space}'})
>>> sorted(r.components)[0][1]
'Some description MNI152NLin2009cAsym'
>>> sorted(r.components)[1][1]
'Some description MNI152NLin6Asym'
>>> r = Reportlet(bl, out_dir=out_figs, config={
...     'title': 'Some Title',
...     'bids': {'datatype': 'fmap', 'space': '.*', 'regex_search': True},
...     'caption': 'Some description {space}'})
>>> r.is_empty()
True
components

A list of visual elements for composite reportlets.

description

This reportlet’s longer description.

is_empty()[source]

Determine whether the reportlet has no components.

name

A unique name for the reportlet (used to create HTML anchors).

subtitle

This reportlet’s subtitle.

title

This reportlet’s title.