Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adelavega opened this issue Jun 1, 2022 · 3 comments
Assignees
Labels
statsmodels Pertain to implementation of BEP-002 - BIDS StatsModels variables

Comments

@adelavega
Copy link
Collaborator

# If all variables are sparse/simple, we can pass them as-is. Otherwise
# we first force all variables to dense via .resample().
if all(isinstance(v, SimpleVariable) for v in _vars):
variables = _vars
else:
sampling_rate = sampling_rate or self.sampling_rate
var_names = [v.name for v in _vars]
collection = self.resample(
sampling_rate, variables=var_names, force_dense=include_sparse
)
variables = list(collection.variables.values())

@adelavega adelavega self-assigned this Jun 1, 2022
@adelavega adelavega added statsmodels Pertain to implementation of BEP-002 - BIDS StatsModels variables labels Jun 1, 2022
@adelavega
Copy link
Collaborator Author

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 adelavega changed the title variables: Add sparse/dense more for to to_df, and add alternative design matrix API to access sparse variables variables: Add sparse/dense mode for to to_df, and add alternative design matrix API to access sparse variables Jun 2, 2022
@adelavega
Copy link
Collaborator Author

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

@adelavega
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
statsmodels Pertain to implementation of BEP-002 - BIDS StatsModels variables
Projects
None yet
Development

No branches or pull requests

1 participant