Skip to content

[ENH] StatsModels: Add invalid_inputs parameter to allow dropping of missing data columns to run nodes#1145

Merged
effigies merged 3 commits intobids-standard:masterfrom
coryshain:master
Sep 23, 2025
Merged

[ENH] StatsModels: Add invalid_inputs parameter to allow dropping of missing data columns to run nodes#1145
effigies merged 3 commits intobids-standard:masterfrom
coryshain:master

Conversation

@coryshain
Copy link
Copy Markdown
Contributor

BIDSStatsModelsNode.run() gracefully drops missing contrasts when invalid_contrasts=="drop", but missing data columns in the GLM at the run level (entries of Model.X) currently always throw an error. As far as I can tell, this makes it impossible to use BIDSStatsModelsNode (and BIDS apps that depend on it, like fitlins) for tasks in which some conditions do not appear in some runs (a use case I happen to have at the moment, which also seems to pop up for others, e.g., here and here). This PR adds an invalid_inputs parameter BIDSStatsModelsNode.run() and BIDSStatsModelsNodeOutput.__init__() that permits a "drop" value just like invalid_contrasts, which warns about missing data columns and then removes them from var_names. I've tested this modification with fitlins and it appears to give the desired enhancement: individual runs estimate all and only the available contrasts (and missing contrasts at downstream nodes are then handled by the existing invalid_contrasts feature). I've set the default value of invalid_inputs to "error", so that the previous default behavior remains unchanged.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.25%. Comparing base (5350b4f) to head (518ce62).
⚠️ Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
src/bids/modeling/statsmodels.py 14.28% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1145      +/-   ##
==========================================
- Coverage   89.40%   89.25%   -0.16%     
==========================================
  Files          66       66              
  Lines        7252     7258       +6     
  Branches     1145      850     -295     
==========================================
- Hits         6484     6478       -6     
- Misses        559      571      +12     
  Partials      209      209              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@effigies effigies merged commit 8895e28 into bids-standard:master Sep 23, 2025
28 checks passed
effigies added a commit that referenced this pull request Sep 24, 2025
Version 0.20.0 (September 24, 2025)

New feature release in the 0.20.x series.

This release finalizes some deprecations that were started in the 0.7 and 0.14 series.
In particular, passing indexer arguments to ``BIDSLayout`` and disabling
``absolute_paths`` mode in ``BIDSLayout()`` or ``BIDSLayout.get()`` will now error.
To adjust indexing behavior, create an explicit ``BIDSLayoutIndexer()`` and pass
``BIDSLayout(..., indexer=indexer)``.
To access relative paths, use the ``BIDSFile.relative_path`` property on
``BIDSLayout.get()`` return values.

* FIX: Check for attribute that can be absent before assigning (#1165)
* FIX: Accommodate deprecations in the upcoming Pandas 3 release (#1173)
* FIX: Repaired convolution issue that arises when onset values are repeated (#1133)
* ENH: StatsModels: Add `invalid_inputs` parameter to allow dropping of missing data columns to run nodes (#1145)
* ENH: Add missing root-level path patterns (#1169)
* ENH: Parse ``seg-`` entities from dseg or probseg files (#1172)
* DOC: Update link to derivatives config file (#1132)
* MNT: Address warnings produced by pybids and dependencies (#1136)
* MNT: Lock test environment, update with dependabot (#1134)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants