Skip to content

Commit

Permalink
add test to verfify intercept only run level model throws a NotImplme…
Browse files Browse the repository at this point in the history
…ntedError
  • Loading branch information
Shotgunosine committed May 10, 2022
1 parent c7c928e commit da44817
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bids/modeling/statsmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def __init__(self, level, name, transformations=None, model=None,

# Check for intercept only run level model and throw an error
try:
if (self.level == 'run') and (self.model['X'] == [1]):
if (self.level == 'run') and (self.model['x'] == [1]):
raise NotImplementedError("Run level intercept only models are not currently supported."
"If this is a feature you need, please leave a comment at"
"https://github.com/bids-standard/pybids/issues/852.")
Expand Down
8 changes: 8 additions & 0 deletions bids/modeling/tests/test_statsmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,11 @@ def test_expand_wildcards():
assert expand_wildcards(
["non_steady_state*"], ["non_steady_state00", "non_steady_state01"]
) == ["non_steady_state00", "non_steady_state01"]


def test_interceptonly_runlevel_error():
layout_path = join(get_test_data_path(), "ds005")
layout = BIDSLayout(layout_path)
json_file = join(layout_path, "models", "ds-005_type-interceptonlyrunlevel_model.json")
with pytest.raises(NotImplementedError):
graph = BIDSStatsModelsGraph(layout, json_file)
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"Name": "ds005_mixedgamblestask",
"Description": "An intercept only run level model to test that an error is correctly thrown.",
"BIDSModelVersion": "1.0.0",
"Input": {
"task": [
"mixedgamblestask"
]
},
"Nodes": [
{
"Level": "Run",
"Name": "Run",
"GroupBy": [
"run",
"subject"
],
"Transformations": {
"Transformer": "pybids-transforms-v1",
"Instructions": [
{
"Name": "Factor",
"Input": "trial_type"
}
]
},
"Model": {
"Type": "glm",
"X": [
1
],
"HRF": {
"Variables": [
"trial_type.parametric gain"
],
"Model": "DoubleGamma",
"Parameters": {
"PeakDelay": 3,
"PeakDispersion": 6,
"UndershootDelay": 10,
"UndershootDispersion": 12,
"PeakUndershootRatio": 0.2
}
}
},
"Contrasts": [
{
"Name": "run_parametric gain",
"ConditionList": [
"trial_type.parametric gain"
],
"Weights": [
1.0
],
"Test": "t"
}
]
}
]
}

0 comments on commit da44817

Please sign in to comment.