Reporting#

class miblab.Report(reportpath, title='MIBLAB report', subtitle='Subtitle', subject='Subject', author='miblab.org', affiliation='https://miblab.org', contact='Steven Sourbron', institute='University of Sheffield', department='Section of Medical Imaging and Technologies', email='s.sourbron@sheffield.ac.uk')[source]#

Bases: Document

Generate pdf reports in miblab style.

Parameters:
  • reportpath (str) – Path to the folder where the report should be saved.

  • title (str) – The title of the report.

  • subtitle (str) – The subtitle of the report.

  • subject (str) – The subject of the report.

  • author (str) – The author of the report.

  • affiliation (str) – The affiliation of the author.

  • contact (str) – The contact person for the report.

  • institute (str) – The institute of the author.

  • department (str) – The department of the author.

  • email (str) – The email of the author.

Example

from miblab import Report

# Where to save the report
path = 'path/to/report/folder'

# Setup the report
doc = Report(path, title='My Report', author='Me')

# Add a chapter
doc.chapter('Chapter 1')

# Add a section
doc.section('Section 1')

# Start a new page
doc.clearpage()

# Add a subsection
doc.subsection('Section 1')

# Add a figure
doc.figure('figure.png', caption='This is a figure.')

# Add a table
doc.table('table.csv', caption='This is a table.')

# Build the pdf report
doc.build(doc)

Note

miblab.Report inherits from pylatex.Document, so can be used in the same way as a pylatex.Document for full customization options.

build(filename='report')[source]#

Create the report.

Parameters:
  • (str (filename) – The name of the report. Defaults to ‘report

  • optional) (str) – The name of the report. Defaults to ‘report

Raises:

NotImplementedError – If miblab is not installed.

chapter(title)[source]#

Add a chapter to the report.

Parameters:

title (str) – Chapter title.

clearpage()[source]#

Continue on a new page.

figure(file, width='6in', caption=None)[source]#

Add a figure to the report.

Parameters:
  • file (str) – Path to the figure file.

  • width (str, optional) – Figure width. Defaults to ‘6in’.

  • caption (str, optional) – Caption for the figure. Defaults to None.

section(title, clearpage=False)[source]#

Add a section to the report.

Parameters:
  • title (str) – Chapter title.

  • clearpage (bool, optional) – Start section on a new page

subsection(title, clearpage=False)[source]#

Add a subsection to the report.

Parameters:
  • title (str) – Chapter title.

  • clearpage (bool, optional) – Start section on a new page

table(file, cwidth=None, caption=None)[source]#

Add a table to the report.

The table is created from a csv file. The first row is used as the header.

Parameters:
  • file (str) – Path to the csv file.

  • cwidth (str, optional) – Column width. Defaults to None (automaticaly chosen).

  • caption (str, optional) – Caption for the table. Defaults to None.