Skip to content

Commit 51106b2

Browse files
committed
FIX: Adjust report to take in subject/session list
1 parent 77cf5b1 commit 51106b2

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

nibabies/cli/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ def main():
141141

142142
# Generate reports phase
143143
generate_reports(
144-
config.execution.participant_label,
145-
config.execution.session_id,
144+
config.execution.unique_labels,
146145
config.execution.nibabies_dir,
147146
config.execution.run_uuid,
148147
config=pkgrf("nibabies", "data/reports-spec.yml"),

nibabies/cli/workflow.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def build_workflow(config_file):
1414
"""Create the Nipype Workflow that supports the whole execution graph."""
15-
from niworkflows.utils.bids import check_pipeline_version, collect_participants
15+
from niworkflows.utils.bids import check_pipeline_version
1616
from niworkflows.utils.misc import check_valid_fs_license
1717

1818
from .. import config
@@ -42,24 +42,17 @@ def build_workflow(config_file):
4242
desc_content = dset_desc_path.read_bytes()
4343
config.execution.bids_description_hash = sha256(desc_content).hexdigest()
4444

45-
# First check that bids_dir looks like a BIDS folder
46-
subject_list = collect_participants(
47-
config.execution.layout, participant_label=config.execution.participant_label
48-
)
49-
subjects_sessions = {
50-
subject: config.execution.session_id
51-
or config.execution.layout.get_sessions(scope='raw', subject=subject)
52-
or [None]
53-
for subject in subject_list
54-
}
55-
5645
# Called with reports only
5746
if config.execution.reports_only:
5847
from pkg_resources import resource_filename as pkgrf
5948

60-
build_logger.log(25, "Running --reports-only on participants %s", ", ".join(subject_list))
49+
build_logger.log(
50+
25,
51+
"Running --reports-only on participants %s",
52+
", ".join(config.execution.unique_labels),
53+
)
6154
retval["return_code"] = generate_reports(
62-
subject_list,
55+
config.execution.unique_labels,
6356
nibabies_dir,
6457
config.execution.run_uuid,
6558
config=pkgrf("nibabies", "data/reports-spec.yml"),
@@ -71,9 +64,9 @@ def build_workflow(config_file):
7164
init_msg = f"""
7265
Running nibabies version {config.environment.version}:
7366
* BIDS dataset path: {config.execution.bids_dir}.
74-
* Participant list: {subject_list}.
67+
* Participant list: {config.execution.unique_labels}.
7568
* Run identifier: {config.execution.run_uuid}.
76-
* Output spaces: {config.execution.output_spaces}."""
69+
* Output spaces: {config.execution.output_spaces or 'MNIInfant'}."""
7770

7871
if config.execution.anat_derivatives:
7972
init_msg += f"""
@@ -84,7 +77,7 @@ def build_workflow(config_file):
8477
* Pre-run FreeSurfer's SUBJECTS_DIR: {config.execution.fs_subjects_dir}."""
8578
build_logger.log(25, init_msg)
8679

87-
retval["workflow"] = init_nibabies_wf(subjects_sessions)
80+
retval["workflow"] = init_nibabies_wf(config.execution.unique_labels)
8881

8982
# Check for FS license after building the workflow
9083
if not check_valid_fs_license():

nibabies/reports/core.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ def run_reports(
8787

8888

8989
def generate_reports(
90-
subject_list,
91-
sessions_list,
90+
sub_ses_list,
9291
output_dir,
9392
run_uuid,
9493
config=None,
@@ -100,15 +99,11 @@ def generate_reports(
10099
if work_dir is not None:
101100
reportlets_dir = Path(work_dir) / "reportlets"
102101

103-
if sessions_list is None:
104-
sessions_list = [None]
105-
106102
report_errors = []
107-
for subject_label, session in product(subject_list, sessions_list):
108-
html_report = f"sub-{subject_label}"
109-
if session:
110-
html_report += f"_ses-{session}"
111-
html_report += ".html"
103+
for subject_label, session in sub_ses_list:
104+
html_report = ''.join(
105+
[f"sub-{subject_label}", f"_ses-{session}" if session else "", ".html"]
106+
)
112107
report_errors.append(
113108
run_reports(
114109
output_dir,
@@ -127,7 +122,7 @@ def generate_reports(
127122

128123
logger = logging.getLogger("cli")
129124
error_list = ", ".join(
130-
"%s (%d)" % (subid, err) for subid, err in zip(subject_list, report_errors) if err
125+
"%s (%d)" % (subid, err) for subid, err in zip(sub_ses_list, report_errors) if err
131126
)
132127
logger.error(
133128
"Preprocessing did not finish successfully. Errors occurred while processing "

0 commit comments

Comments
 (0)