diff --git a/CHANGES.rst b/CHANGES.rst
index 1af0fe94..ab27a29f 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,3 +1,15 @@
+23.2.2 (August 19, 2024)
+========================
+Bug-fix release in the 23.2.x series.
+
+CHANGES
+-------
+
+**Full Changelog**: https://github.com/nipreps/nireports/compare/23.2.1...23.2.2
+
+* ENH: Support PNGs and JPGs in reportlets (#126)
+
+
23.2.1 (May 07, 2024)
=====================
Bug-fix release in the 23.2.x series.
diff --git a/nireports/assembler/report.py b/nireports/assembler/report.py
index 19db2680..145906b5 100644
--- a/nireports/assembler/report.py
+++ b/nireports/assembler/report.py
@@ -97,7 +97,7 @@ class Report:
... dirs_exist_ok=True,
... )
>>> REPORT_BASELINE_LENGTH = 41770
- >>> RATING_WIDGET_LENGTH = 83308
+ >>> RATING_WIDGET_LENGTH = 83343
Examples
diff --git a/nireports/assembler/reportlet.py b/nireports/assembler/reportlet.py
index 3924a929..b9b4afa7 100644
--- a/nireports/assembler/reportlet.py
+++ b/nireports/assembler/reportlet.py
@@ -34,22 +34,21 @@
from nireports.assembler.misc import dict2html, read_crashfile
from nireports.exceptions import RequiredReportletException
-SVG_SNIPPET = [
- """\
+IMG_SNIPPET = """\
-
+
Get figure file: {name}
-""",
- """\
+"""
+
+SVG_SNIPPET = """\
-
+
Get figure file: {name}
-""",
-]
+"""
METADATA_ACCORDION_BLOCK = """\
@@ -266,10 +265,36 @@ def __init__(self, layout, config=None, out_dir=None, bids_filters=None, metadat
style = {"width": "100%"} if is_static else {}
style.update(config.get("style", {}))
- contents = SVG_SNIPPET[is_static].format(
+ snippet = IMG_SNIPPET if is_static else SVG_SNIPPET
+ contents = snippet.format(
+ ext=ext[1:],
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%"}
+ style.update(config.get("style", {}))
+
+ snippet = IMG_SNIPPET
+ contents = snippet.format(
+ ext=ext[1:],
+ name=html_anchor,
+ style="; ".join(f"{k}: {v}" for k, v in style.items()),
+ )
+ else:
+ raise RuntimeError(f"Unsupported file extension: {ext}")
if contents:
self.components.append((contents, desc_text))
diff --git a/nireports/conftest.py b/nireports/conftest.py
index c67ff257..4fb25190 100644
--- a/nireports/conftest.py
+++ b/nireports/conftest.py
@@ -41,6 +41,14 @@
test_workdir = os.getenv("TEST_WORK_DIR")
+@pytest.fixture(scope="session", autouse=True)
+def legacy_printoptions():
+ from packaging.version import Version
+
+ if Version(np.__version__) >= Version("1.22"):
+ np.set_printoptions(legacy="1.21")
+
+
@pytest.fixture(autouse=True)
def expand_namespace(doctest_namespace):
doctest_namespace["PY_VERSION"] = version_info
diff --git a/pyproject.toml b/pyproject.toml
index 297e4bc5..b67d93e9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -24,7 +24,7 @@ dependencies = [
"nibabel >= 3.0.1",
"nilearn >= 0.5.2",
"nipype",
- "numpy < 2.0",
+ "numpy",
"pandas",
"pybids",
"pyyaml",
@@ -57,6 +57,7 @@ dev = [
test = [
"coverage",
"matplotlib",
+ "packaging",
"pytest",
"pytest-cov",
"pytest-env",