Skip to content

Methods reporting

AlmKanal can automatically generate draft Methods text from the processing history saved after running a pipeline. The public interface for this is preprocessing_report, which uses Jinja templates to describe the preprocessing steps.

Example

After running a pipeline and saving its processing history:

from almkanal import preprocessing_report

pipeline.generate_json("history.json")

methods_path = preprocessing_report(
    files=["history.json"],
    out_path="methods.md",
)

The example writes the generated text to methods.md. Other output formats, such as Word documents or PDFs, require Pandoc (and, for PDF, a suitable PDF engine).

Custom Jinja templates

You can also use your own Jinja templates to customize the generated descriptions:

methods_path = preprocessing_report(
    files=["history.json"],
    out_path="methods.md",
    template_dir="my_templates",
)

See Custom Methods templates for instructions on creating and using your own templates.

Note

Automatically generated Methods text should always be reviewed before use in a publication. Processing performed before the data entered AlmKanal needs to be documented separately.

API reference

almkanal.report.exporting.preprocessing_report(files, out_path, *, to=None, template_dir=None, master_template='methods_master.j2', step_packages=('almkanal.report.stepspecs',), metadata=None, extra_args=None, pandoc_path=None)

Render Methods text from preprocessing JSON files and convert it with Pandoc.

Examples: render_methods_via_pandoc(files, "methods.docx", to="docx") render_methods_via_pandoc(files, "methods.pdf", to="pdf", extra_args=["--pdf-engine=xelatex"]) render_methods_via_pandoc(files, "methods.html") # 'to' inferred from suffix

Returns: The output Path.