From a5c96a3d9459fae7427648cfc0bbc982b27f4fa5 Mon Sep 17 00:00:00 2001 From: mnoergaard Date: Mon, 24 Nov 2025 13:39:43 +0100 Subject: [PATCH 1/2] ENH: Fix subject ID conflicts in visualizations --- petprep/reports/core.py | 17 ++++++++++++++++- petprep/reports/tests/test_reports.py | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/petprep/reports/core.py b/petprep/reports/core.py index a4b83f8c..0199ed01 100644 --- a/petprep/reports/core.py +++ b/petprep/reports/core.py @@ -82,6 +82,21 @@ def generate_reports( errors = [] for subject_label in subject_list: subject_label = subject_label.removeprefix('sub-') + + subject_reportlets_dir = reportlets_dir + if reportlets_dir is not None: + subject_reportlets_dir = next( + ( + candidate + for candidate in ( + reportlets_dir / 'petprep' / f'sub-{subject_label}', + reportlets_dir / f'sub-{subject_label}', + reportlets_dir, + ) + if candidate.exists() + ), + reportlets_dir, + ) # The number of sessions is intentionally not based on session_list but # on the total number of sessions, because I want the final derivatives # folder to be the same whether sessions were run one at a time or all-together. @@ -106,7 +121,7 @@ def generate_reports( run_uuid, bootstrap_file=bootstrap_file, out_filename=html_report, - reportlets_dir=reportlets_dir, + reportlets_dir=subject_reportlets_dir, errorname=f'report-{run_uuid}-{subject_label}.err', subject=subject_label, ) diff --git a/petprep/reports/tests/test_reports.py b/petprep/reports/tests/test_reports.py index 75c122fd..e8152392 100644 --- a/petprep/reports/tests/test_reports.py +++ b/petprep/reports/tests/test_reports.py @@ -5,6 +5,7 @@ from bids.layout import BIDSLayout from petprep.reports.core import generate_reports +import petprep.reports.core as core from ... import config, data @@ -146,3 +147,29 @@ def test_pet_report(tmp_path, monkeypatch): assert html_file.is_file() html_content = html_file.read_text() assert '
Date: Mon, 24 Nov 2025 13:41:56 +0100 Subject: [PATCH 2/2] FIX: style --- petprep/reports/tests/test_reports.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/petprep/reports/tests/test_reports.py b/petprep/reports/tests/test_reports.py index e8152392..b7457ff4 100644 --- a/petprep/reports/tests/test_reports.py +++ b/petprep/reports/tests/test_reports.py @@ -4,8 +4,8 @@ import pytest from bids.layout import BIDSLayout -from petprep.reports.core import generate_reports import petprep.reports.core as core +from petprep.reports.core import generate_reports from ... import config, data