From 06ececc2919692f9f2f7b04fe74e90268efff583 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 19 Sep 2023 09:47:29 -0400 Subject: [PATCH] Sort task file entities for executive summary. --- xcp_d/interfaces/execsummary.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xcp_d/interfaces/execsummary.py b/xcp_d/interfaces/execsummary.py index c234bfbef..1ed428671 100644 --- a/xcp_d/interfaces/execsummary.py +++ b/xcp_d/interfaces/execsummary.py @@ -4,6 +4,8 @@ import re from pathlib import Path +import numpy as np +import pandas as pd from bids.layout import BIDSLayout, Query from bs4 import BeautifulSoup from jinja2 import Environment, FileSystemLoader, Markup @@ -166,10 +168,17 @@ def collect_inputs(self): task_entity_sets = [] for entity_set in unique_entity_sets: for entity in ORDERING: - entity_set[entity] = entity_set.get(entity, Query.NONE) + entity_set[entity] = entity_set.get(entity, np.nan) task_entity_sets.append(entity_set) + # Now sort the entity sets by each entity + task_entity_sets = pd.DataFrame(task_entity_sets) + task_entity_sets = task_entity_sets.sort_values(by=task_entity_sets.columns.tolist()) + task_entity_sets = task_entity_sets.fillna(Query.NONE) + task_entity_sets = task_entity_sets.to_dict(orient="records") + + # Collect figures for concatenated resting-state data (if any) concatenated_rest_files = {} query = {