-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* up predict.jl update predict function for partial overlap, so that keep_basis input is converted to vector. * add assert * Update src/predict.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/predict.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * rename variable rename variable to be Julia standard compliant * Update src/predict.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * update assert in predict.jl * minor predict improvements * small typo * Update README.md * Update README.md * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update src/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> * Update docs/literate/explanations/predict.jl Co-authored-by: René Skukies <[email protected]> --------- Co-authored-by: ReneSkukies <[email protected]> Co-authored-by: René Skukies <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4d57950
commit 65cfcc7
Showing
4 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# # The predict-family | ||
## Setup | ||
using Unfold | ||
using UnfoldSim | ||
using CairoMakie | ||
|
||
dat, evts = UnfoldSim.predef_eeg(noiselevel = 5) | ||
design = [ | ||
"car" => (@formula(0 ~ 1 + continuous), firbasis(τ = (-0.5, 1), sfreq = 100)), | ||
"face" => (@formula(0 ~ 1 + continuous), firbasis(τ = (-0.3, 0.5), sfreq = 100)), | ||
] | ||
|
||
m = fit(UnfoldModel, design, evts, dat; eventcolumn = :condition); | ||
|
||
# # Overview | ||
# In a linear model $EEG = Xβ + e$, predictions boil down to finding $\hat{EEG} = Xβ$, thus EEG data without any error term. | ||
# Different types of predictions can be generated by modifying the $X$ accordingly. | ||
# | ||
# !!! note | ||
# We simulated only a single channel, all results generalize to the multi channel case | ||
# | ||
# # Different types of predictions | ||
# ## Time-Continuous case | ||
# Let's start with the cases, where the EEG was not epoched before using Unfold, i.e. the EEG was analysed with e.g. FIR-deconvolution | ||
|
||
# ### Continuous EEG | ||
# In the most simple case, we can predict the continuously modelled EEG - This returns $EEG = Xβ$ | ||
p = predict(m) # same as predict(m, overlap = true) | ||
lines(p[1, 1:1000]) | ||
|
||
|
||
# ### No-overlap | ||
# We can also predict each epoch without any overlap - This results in one prediction Array per event (in our case we have two events "car" and "face", thus ```size(p[1]) = 2``` | ||
p = predict(m, overlap = false) | ||
size(p) | ||
# Each Array has the size (1, samples, epochs): | ||
size(p[1]) | ||
|
||
# Visualizing the 1000 events | ||
series(range(-0.5, 1, step = 1 / 100), p[1][1, :, :]', solid_color = :orange) | ||
series!(range(-0.3, 0.5, step = 1 / 100), p[2][1, :, :]', solid_color = :teal) | ||
current_figure() | ||
|
||
# !!! note | ||
# At ~0.3s we can see a split between the predicted EEG single trials into 10 "strands" - this is the granularity of our continuous predictor. You could use `effects` to improve upon this granularity / customize it. | ||
# | ||
# ### With-overlap, epoched | ||
# Sometimes helpful is to add in the overlap we removed via the deconvolution. | ||
p = predict(m, epoch_to = ["car"], eventcolumn = :condition) | ||
series(range(-0.5, 1, step = 1 / 100), p[1, :, 1:3]', solid_color = :orange) | ||
|
||
# ### Partial-overlap | ||
# We can also include/exclude certain events with "partial-overlap", i.e. only overlap with kept events. | ||
p_car = predict(m, keep_basis = ["car"], eventcolumn = :condition) | ||
p_face = predict(m, exclude_basis = ["car"], eventcolumn = :condition) # same as keep_basis=["face"] | ||
f = lines(p_car[1, 1:1000]) | ||
lines!(p_face[1, 1:1000]) | ||
f | ||
|
||
# In the plot, we see the two partial predictions for car and face. They are respectively "0" outside the basisfunction windows | ||
|
||
# !!! note | ||
# The above options can be combined as well, e.g. to get an `epoch_to`, `exclude_basis` version. `epoch_timewindow` can be specified as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters