diff --git a/nireports/assembler/reportlet.py b/nireports/assembler/reportlet.py index d31d1231..e1ebd822 100644 --- a/nireports/assembler/reportlet.py +++ b/nireports/assembler/reportlet.py @@ -220,7 +220,6 @@ def __init__(self, layout, config=None, out_dir=None, bids_filters=None, metadat "name", "_".join("%s-%s" % i for i in sorted(bidsquery.items())), ) - # Query the BIDS layout of reportlets files = layout.get(**bidsquery) @@ -269,6 +268,26 @@ def __init__(self, layout, config=None, out_dir=None, bids_filters=None, metadat name=html_anchor, style="; ".join(f"{k}: {v}" for k, v in style.items()), ) + elif ext in (".png", ".jpg", ".jpeg"): + entities = dict(bidsfile.entities) + if desc_text: + desc_text = desc_text.format(**entities) + + try: + html_anchor = src.relative_to(out_dir) + except ValueError: + html_anchor = src.relative_to(Path(layout.root)) + dst = out_dir / html_anchor + dst.parent.mkdir(parents=True, exist_ok=True) + copyfile(src, dst, copy=True, use_hardlink=True) + + style = {"width": "100%"} if is_static else {} + style.update(config.get("style", {})) + + stylestr = "; ".join(f"{k}: {v}" for k, v in style.items()) + contents = f'' + else: + raise RuntimeError(f"Unsupported file extension: {ext}") if contents: self.components.append((contents, desc_text))