-
Notifications
You must be signed in to change notification settings - Fork 4
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
trf #107
base: v4.0
Are you sure you want to change the base?
Conversation
# | ||
# ## Simulation | ||
# we start with the simplest possible design, one condition | ||
design = SingleSubjectDesign(conditions=Dict(:dummy=>["A"])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
design = SingleSubjectDesign(conditions=Dict(:dummy=>["A"])); | |
design = SingleSubjectDesign(conditions = Dict(:dummy => ["A"])); |
brain_response = [LinearModelComponent(basis=p100(),formula=@formula(0~1),β=[1]), | ||
LinearModelComponent(basis=n170(),formula=@formula(0~1),β=[1]), | ||
LinearModelComponent(basis=p300(),formula=@formula(0~1),β=[1])]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
brain_response = [LinearModelComponent(basis=p100(),formula=@formula(0~1),β=[1]), | |
LinearModelComponent(basis=n170(),formula=@formula(0~1),β=[1]), | |
LinearModelComponent(basis=p300(),formula=@formula(0~1),β=[1])]; | |
brain_response = [ | |
LinearModelComponent(basis = p100(), formula = @formula(0 ~ 1), β = [1]), | |
LinearModelComponent(basis = n170(), formula = @formula(0 ~ 1), β = [1]), | |
LinearModelComponent(basis = p300(), formula = @formula(0 ~ 1), β = [1]), | |
]; |
feature = rand(1_000) | ||
|
||
# Next we have to nest the response in a `TRFComponent` and add ou | ||
trf_component = TRFComponent(brain_response,feature); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
trf_component = TRFComponent(brain_response,feature); | |
trf_component = TRFComponent(brain_response, feature); |
trf_component = TRFComponent(brain_response,feature); | ||
|
||
# Finally, when simulating, we have only a single "event" (that is, TRF-) onset, the first sample. Therefore, we use `TRFOnset` to indicate this. | ||
dat,evts = simulate(design,trf_component,UnfoldSim.TRFOnset()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
dat,evts = simulate(design,trf_component,UnfoldSim.TRFOnset()); | |
dat, evts = simulate(design, trf_component, UnfoldSim.TRFOnset()); |
dat,evts = simulate(design,trf_component,UnfoldSim.TRFOnset()); | ||
|
||
# Let's plot the feature signal and the TRF response | ||
f,ax,h =lines(dat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
f,ax,h =lines(dat) | |
f, ax, h = lines(dat) |
dat_l,_ = simulate(design,TRFComponent(brain_response,feature_luminance),UnfoldSim.TRFOnset()); | ||
dat_r,_ = simulate(design,TRFComponent(brain_response,feature_size),UnfoldSim.TRFOnset()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
dat_l,_ = simulate(design,TRFComponent(brain_response,feature_luminance),UnfoldSim.TRFOnset()); | |
dat_r,_ = simulate(design,TRFComponent(brain_response,feature_size),UnfoldSim.TRFOnset()); | |
dat_l, _ = | |
simulate(design, TRFComponent(brain_response, feature_luminance), UnfoldSim.TRFOnset()); | |
dat_r, _ = | |
simulate(design, TRFComponent(brain_response, feature_size), UnfoldSim.TRFOnset()); |
dat_r,_ = simulate(design,TRFComponent(brain_response,feature_size),UnfoldSim.TRFOnset()); | ||
|
||
# let's plot and compare to the previous plot | ||
f,ax,h = lines(dat_l .+ dat_r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
f,ax,h = lines(dat_l .+ dat_r) | |
f, ax, h = lines(dat_l .+ dat_r) |
dat_combined,_ = simulate(design,[TRFComponent(brain_response,feature_size),TRFComponent(brain_response,feature_luminance)],UnfoldSim.TRFOnset()); | ||
f,ax,h = lines(dat_combined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
dat_combined,_ = simulate(design,[TRFComponent(brain_response,feature_size),TRFComponent(brain_response,feature_luminance)],UnfoldSim.TRFOnset()); | |
f,ax,h = lines(dat_combined) | |
dat_combined, _ = simulate( | |
design, | |
[ | |
TRFComponent(brain_response, feature_size), | |
TRFComponent(brain_response, feature_luminance), | |
], | |
UnfoldSim.TRFOnset(), | |
); | |
f, ax, h = lines(dat_combined) |
# where you can see that the results are equivalent. | ||
|
||
# ## Another cool feature is to modulate the feature vector based on the design | ||
design_mod = SingleSubjectDesign(conditions=Dict(:condition=>["A","B"])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
design_mod = SingleSubjectDesign(conditions=Dict(:condition=>["A","B"])); | |
design_mod = SingleSubjectDesign(conditions = Dict(:condition => ["A", "B"])); |
design_mod = SingleSubjectDesign(conditions=Dict(:condition=>["A","B"])); | ||
|
||
# Let's take only a single component for simplicity. Note how the `formula` has been changed. The β allows to control the amplitude. In this linear model component, the default contrast-function is `Dummy` (also known as `Reference` coding), which means, the second beta indicated a "difference" | ||
brain_response_mod = LinearModelComponent(basis=p100(),formula=@formula(0~1+condition),β=[1,1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
brain_response_mod = LinearModelComponent(basis=p100(),formula=@formula(0~1+condition),β=[1,1]); | |
brain_response_mod = | |
LinearModelComponent(basis = p100(), formula = @formula(0 ~ 1 + condition), β = [1, 1]); |
feature_mod = rand(1000,2) | ||
feature_mod[:,2] .= 0 | ||
feature_mod[500:600,2] .= 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
feature_mod = rand(1000,2) | |
feature_mod[:,2] .= 0 | |
feature_mod[500:600,2] .= 1; | |
feature_mod = rand(1000, 2) | |
feature_mod[:, 2] .= 0 | |
feature_mod[500:600, 2] .= 1; |
# As visible, the first column has again a random signal, indicating e.g. luminance changes. The second temporal feature indicates some offset (a colorchange?) between 500 and 600 samples. | ||
|
||
|
||
dat_mod,_ = simulate(design_mod,TRFComponent([brain_response_mod],feature_mod),UnfoldSim.TRFOnset()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
dat_mod,_ = simulate(design_mod,TRFComponent([brain_response_mod],feature_mod),UnfoldSim.TRFOnset()); | |
dat_mod, _ = simulate( | |
design_mod, | |
TRFComponent([brain_response_mod], feature_mod), | |
UnfoldSim.TRFOnset(), | |
); |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
widths = | ||
UnfoldSim.generate_designmatrix(o.width_formula, events, o.width_contrasts) * | ||
generate_designmatrix(o.width_formula, events, o.width_contrasts) * | ||
o.width_β |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
widths = | |
UnfoldSim.generate_designmatrix(o.width_formula, events, o.width_contrasts) * | |
generate_designmatrix(o.width_formula, events, o.width_contrasts) * | |
o.width_β | |
widths = generate_designmatrix(o.width_formula, events, o.width_contrasts) * o.width_β |
generate_designmatrix(o.offset_formula, events, o.offset_contrasts) * | ||
o.offset_β |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
generate_designmatrix(o.offset_formula, events, o.offset_contrasts) * | |
o.offset_β | |
generate_designmatrix(o.offset_formula, events, o.offset_contrasts) * o.offset_β |
generate_designmatrix(o.offset_formula, events, o.offset_contrasts) * | ||
o.offset_β |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
generate_designmatrix(o.offset_formula, events, o.offset_contrasts) * | |
o.offset_β | |
generate_designmatrix(o.offset_formula, events, o.offset_contrasts) * o.offset_β |
TRFComponent