File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -337,21 +337,24 @@ def _build_groups(objects, group_by):
337337
338338 groups = defaultdict (list )
339339
340- # sanitize grouping entities, otherwise weird things can happen
341- group_by = list (set (group_by ) & VALID_GROUPING_ENTITIES )
342-
343340 # Get unique values in each grouping variable and construct indexing DF
344341 entities = [obj .entities for obj in objects ]
345342 df = pd .DataFrame .from_records (entities )
346343
344+ # Single-run tasks and single-session subjects may not have entities
345+ dummy_groups = {"run" , "session" } - set (df .columns )
346+
347+ # sanitize grouping entities, otherwise weird things can happen
348+ group_by = set (group_by ) & VALID_GROUPING_ENTITIES - dummy_groups
349+
347350 # Verify all columns in group_by exist and raise sensible error if not
348- missing_vars = list (set ( group_by ) - set (df .columns ))
351+ missing_vars = list (group_by - set (df .columns ))
349352 if missing_vars :
350353 raise ValueError ("group_by contains variable(s) {} that could not "
351354 "be found in the entity index." .format (missing_vars ) )
352355
353356 # Restrict DF to only grouping columns
354- df = df .loc [:, group_by ]
357+ df = df .loc [:, list ( group_by ) ]
355358
356359 unique_vals = {col : df [col ].dropna ().unique ().tolist () for col in group_by }
357360
You can’t perform that action at this time.
0 commit comments