bids-standard / pybids

Python tools for querying and manipulating BIDS datasets.
https://bids-standard.github.io/pybids/
MIT License
222 stars 122 forks source link

variables: Add sparse/dense mode for to to_df, and add alternative design matrix API to access sparse variables #865

Open adelavega opened 2 years ago

adelavega commented 2 years ago

https://github.com/bids-standard/pybids/blob/f4bf70cccaf85dc65f2b610f448d141c014562d9/bids/variables/collections.py#L610-L620

adelavega commented 2 years ago

to_df casts everything to dense, which is a problem for the HRF property of BSM.

To be able to hand off HRF convolution to another program we need to be able to output sparse variables seperately from dense variables.

We need to add a mode that separate dense/sparse, and a different way of accessing the design matrix (aside from .X).

adelavega commented 2 years ago

@jmumford also requests this in order to look at the unconvolved regressors for model inspection

adelavega commented 2 years ago

This is actually more complex than it looks, because BIDSStatsModelsNodeOutput would need to keep in parallel both dense and sparse parts of the DM, so all logic downstream (i.e. handling intercept, expanding wild cards, etc), would have to be refactor to handle keeping the DM split.