nirspipe.qc.figures.common.provenance_figure

nirspipe.qc.figures.common.provenance_figure#

Provenance flow diagram: which file each output came from, and via which step.

Module Contents#

Functions#

provenance_figure

Layered left-to-right DAG of the run’s outputs. Returns a matplotlib Figure.

provenance_title

write_provenance

Render the graph for nirs_dir into out_dir as a PNG and its mermaid source.

API#

nirspipe.qc.figures.common.provenance_figure.provenance_figure(nodes: dict[str, nirspipe.qc.common.provenance.Node], title: str | None = None)#

Layered left-to-right DAG of the run’s outputs. Returns a matplotlib Figure.

Nodes are placed by depth (longest path from a root), so an arrow never points backwards. Each box shows the output name, the step and settings that produced it, and the shape of the data at that point. A wrapped column (see _layout()) whose outputs share one set of parents takes one arrow per parent, into a bar down its left edge, rather than one into every box.

nirspipe.qc.figures.common.provenance_figure.provenance_title(label: str, mode: str | None) → str#
nirspipe.qc.figures.common.provenance_figure.write_provenance(nirs_dir: pathlib.Path, out_dir: pathlib.Path, fig_name, title: str | None = None, label: str | None = None) → list[pathlib.Path]#

Render the graph for nirs_dir into out_dir as a PNG and its mermaid source.

fig_name is a figure_namer(), so both files are named the way every other figure in the tree is and carry the run they are of.

label restricts the graph to one BIDS run; see scan().

Both outputs are drawn off simplify(), so the picture and the mermaid source are the same graph.

Returns the files written, empty if nirs_dir holds no provenance sidecars.