How to implement time-Spline basis functions as available in MATLAB unfold? #331
-
|
Hi all :) I used to use the MATLAB version and would use time-spline basis functions as opposed to stick functions. From what I understand, firbasis() is a stick function basis set. I liked the spline method in MATLAB because of the smoothing properties. Is this spline basis set available in the Julia version? Alternatively Not sure if I understand correctly but, if the spline approach is not available in Unfold.jl, does this mean I could just keep the stick functions but just downsample to address this? Do you see any issues with doing this? Thanks very much, I really appreciate how helpful this discussion board is! EDIT: I just realised there is splinebasis() in basisfunctions.jl. I will try this out. But I am still curious about using the stick function + downsampling possibility |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Hey! Just to quickly give a few thoughts because Benedikt is on holiday: Yes you can use splines as basisfunctions, however it is part of the BSplineKit extension, so you have to using Unfold
using UnfoldSim
using BSplineKit
data, events = UnfoldSim.predef_eeg();
Unfold.splinebasis((-0.1, 0.8), 100, 5, "basisA")
f = @formula 0~ 1 + condition
#etc.For some reason Additionally, using Pluto currently seems to result in a bug: Failed to show value:
FieldError: type Unfold.SplineBasis has no field `scale_duration`, available fields: `kernel`, `colnames`, `times`, `name`, `shift_onset`I tracked it down to be purely an issue with some compat for spline plotting in Pluto, so if you are using normal scripts you should be fine. I'll make an issue for it as well. (I also wanted to try out the stickfunction + downsampling, but I don't have time to not do it in Pluto; maybe Bene has more thoughts when he's back) |
Beta Was this translation helpful? Give feedback.

Hey Jordan,
ah I see, the renderable obj is always tested to have the scale_duration attribute, hence the error when displaying. I will edit the issue, thanks for the catch!
For the dataframe error: I just had a bit of a dive into the code and there is definitely something wrong.
First, the error in line 424 is viable, and I can make a PR as a quickfix:
But that doesn't fix the results. I can confirm that I also only get one estimate per spline if I only use an intercept model. Ideally you are correct and you should get the same output as in the Matlab version (i.e. one beta per time point per channel). Alt…