Skip to content

Paired difference models at Subject Node #99

@demidenm

Description

@demidenm

Subject-level paired difference models fail with design matrix dimension mismatch

Dataset: ds000171

Problem Description

In the current instance, it appears feasible to specify a paired difference model using the below in the subject-level node:

"Model": {
    "X": [
        "run"
    ],
    "Type": "meta",
    "Formula": "0 + C(run)"
},
"Contrasts": [
    {
        "Name": "run1vrun2",
        "ConditionList": [
        "C(run)[1]",
        "C(run)[2]"
        ],
        "Weights": [
        1,
        -1
        ],
        "Test": "t"
    },
    {
        "Name": "run1vrun3",
        "ConditionList": [
        "C(run)[1]",
        "C(run)[3]"
        ],
        "Weights": [
        1,
        -1
        ],
        "Test": "t"
    }
]

However, when attempting this on ds000171, Fitlins returns an error:

ValueError: design_matrix does not match the number of maps considered. 3 rows in design matrix do not match with 9 maps.

This arises from the check:
_check_n_rows_desmat_vs_n_effect_maps(effect_maps, self.design_matrix_)

The design matrix is correct with 3 rows for 3 runs (consistent with the above model spec):

X C(run)[1] C(run)[2] C(run)[3]
0 1 0 0
1 0 1 0
2 0 0 1

However, Fitlins returns that 9 maps =! 3. Is it expecting a map for each cell?

Debugging Details

When filtering the crash file's stat metadata variable, there are only 3 runs per subject and contrast. Furthermore, across all subjects, the number of computed contrasts is the same (run-level completed w/o error). Given the filtering/groupby configuration, this would be the expected 3 maps:

"GroupBy": [
    "subject",
    "contrast"
]

In discussing with @effigies, this may be a unique issue that arises at the subject-level node. While a standard, fixed-effect model at the subject-level node works without errors, issues are encountered here despite the consistent number of files.

Questions

  1. Is this a known limitation at subject-level node for paired differences?
  2. Should paired difference models be specified differently at the subject level, e.g. using transformations rather than meta data? This would simultaneously help resolve potential issues when runs are named differently in select cases like this dataset.

Environment

  • Fitlins version: using uv with fitlins pinned fitlins @ git+https://github.com/jmumford/fitlins.git@paddedintand pybids pinned pybids @ git+https://github.com/bids-standard/pybids.git@92607f70e4f0c42adecf921abcd1a8992eb84089
  • Dataset: ds000171
  • Model type: Run-level with paired differences at Subject-Level
    • Node Error: Subject-level

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions