unfoldtoolbox / Unfold.jl

Neuroimaging (EEG, fMRI, pupil ...) regression analysis in Julia
MIT License
47 stars 10 forks source link

Speed up `effects` function #214

Open jschepers opened 1 month ago

jschepers commented 1 month ago

At the moment, calculating marginal effects for several subjects, channels, predictors etc. is rather time-consuming. I think it would be worth checking whether there is optimization potential for the effects function.

Example: Computing the marginal effects for one subject with an Unfold model with 128 channels, 2 basis functions and specifying one predictor with 3 levels (with 9 predictor variables in total in the model), took about 99.4 seconds.

This does not scale well if one has 20-30 subjects and more predictor values.

behinger commented 4 weeks ago

acknowledged. I did a deep dive into the effects function to try to make it faster - and for small models I succeeded. But I also noticed I didnt get any gains for large models.

I already shifted every column to a special vector that encodes unique values as Ints (forgot the name right now). I will try to look into it again. I would also like to be able to calculate effects only for specific channels.

I did see much faster speeds, with me needing 200s for 30subjects with a slightly smaller model. So not entirely sure what happenening here