GithubHelp home page GithubHelp logo

unfoldtoolbox / unfoldsim.jl Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 4.0 14.74 MB

Simulate EEG / ERP data with overlap, non-linear effects, multiple regression

License: MIT License

Julia 100.00%
eeg erp julia simulation time-series

unfoldsim.jl's People

Contributors

allcontributors[bot] avatar behinger avatar jschepers avatar llips avatar maanikmarathe avatar reboreexplore avatar reneskukies avatar vladdez avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

unfoldsim.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

suggestions

  1. Would be nice to format a code in Home page in docs.
  2. It crashed when I entered 8 at σ in onset = LogNormalOnset(μ = 5, σ = 5.1). Extrema parameters should be tested.
  3. Here would be nice to have more spaces in label = "($μ,$σ,$offset,$truncate_upper)". Hard to read
  4. DocStrings probably should renamed to API
  5. UnfoldSim.predef_eeg - this docstring definitely should be check for grammar and formatting.
  6. I solved the issue of _ transforming to italic in my docstrings. You can check it here https://github.com/unfoldtoolbox/UnfoldMakie.jl/blob/main/src/docstring_template.jl on string 48
  7. UnfoldSim.simulate_component - 4 spaces should be put before a function in doctrings
  8. Each docstring should end with a returned value

Too slow right now

We have to profile a run to see why we are relatively slow (~200ms for simulating 30subjects, 100 trials with LMMs). I want to be much faster :)

renaming

Before 1.0 we should rename a few things:

  • simulate and generate are used in different places, not clear why not same name for everything. Makes sense to me, you can simulate a design, simulate an EEG, simulate noise
  • rand_onsets actually delivers distances between onsets, generate(rng,onset,...) generates the onsets

Let's collect as we go

sequence of different events

Currently not clear how to best do something like
A -> B -> C as three different events, or even worse, B follows A in 80% of cases, etc.


Design and Develop Signal Module

  • module for the simulating underlying EEG signal data.
    • per event: one set of coefficients, able to simulate random effect structure subject + item
    • from mathematical functions - exponential functions etc
    • from filters - hanning window etc

I will elaborate them later in the thread as we proceed further.

Todo for Registratior

  • Readme
  • Check dependencies
  • Add Compat entries
  • Author => Luis Lips, Benedikt Ehinger, Judith Schepers,
  • Setup Continuous Integration (maybe redoing the package is easier as we can use PkgTemplate.jl?
  • We need unittests
  • We need documentation

Potential things to look at

Here we collect ideas that we might want to simulate and look at

  • Timefrequency response to overlapping signals (with @olafdimigen)
  • discrete vs. continuous jitter
  • duration effects
  • length of estimation window
  • number of parameters/predictors/splines/events (@ReneSkukies)
  • show that bias in e.g. saccade-amplitude leads to spurios decoding
  • have a second look at sequence effects (described in Gert et al 2022)
  • simulate patterns for erpimages to autodetect interesting covariates (@vladdez )
  • overlap via source-activation, then do source inversion, then check if Unfold still has to do something

Feel free to add your own ideas!

Ideas for new features

  • Simulate outliers
  • Option to save simulated data in typical EEG format(s)
  • Simulate ECG signal

Todos/Notes from bene

Luis, please dont do any of those - you have your project/thesis! but if you have thoughts happy to hear them :)

  • add some basic basis functions (ERP-style, P300, N400, N170, fMRI, PupilDilation etc.)
  • provide Docs to these basis functions with pretty example
  • add realistic EEG Noise - maybe based on Artifacts.jl or DataDeps.jl so not everyone needs to download it
  • provide a simplistic doc HowTo to run a power analysis (out of scope for this package? dunno)

bugs

  • if Condition/level is an int, I get an error later
  • if #betas or #thetas doesnt fit, I get a hard to parse error
  • convert generates a "cond" not a "stimType" column

infinite loop in simulate multiple dispatch

function simulate(args...; kwargs...)
    @warn "No random generator defined, used the default (`Random.MersenneTwister(1)`) with a fixed seed. This will always return the same results and the user is strongly encouraged to provide their own random generator!"
    simulate(MersenneTwister(1), args...; kwargs...)
end

on second thought, that wasnt our best idea. As soon as you misspecify the simulate input in any way (e.g. NoNoise instead of NoNoise()) it runs into an infinite loop

Unhelpful error message when using `generate` on a MultiSubjectDesign without `subjects_between`, `items_between` and `both_within`

When creating a MultiSubjectDesign without giving arguments for subjects_between, items_between and both_within (their default is nothing), the generate function gives a MethodError as in the following example:
grafik

The problem originates from the following line in the generate function:

@assert :dv keys(merge(allconditions[.!isnothing.(allconditions)]...)) "due to technical limitations in MixedModelsSim.jl, `:dv` cannot be used as a factorname"

Suggestions:

  • Either rewrite the function to make it possible to generate designs without any conditions
  • Or handle this case with an appropriate error + message.

New noisetypes

  • realistic EEG Noise - maybe based on Artifacts.jl or DataDeps.jl so not everyone needs to download it. Currently discussing with @ReneSkukies how to do this
  • Autocorrelated noise - @jschepers there was a paper we cite that had a nice noise-generator, do you remember?
  • Exponential Noise - already implemented, but we should cap the exponential function at some point and apply it in batches or so
  • Noise á la carte - implement the approach from Richard Gao on generating arbitrary complex signal-stubs from short segments (or generate data with their implementation and use Artifacts.jl to serve it)

bug with event_order_function

the bug I have seen in @vladdez notebook with the event_order_function appeared again. I have to test and drill it down further, but it appeared now with a sequence+repetition design model. Unclear if without these it would appear too

without shuffle:
grafik

with shuffle:
grafik

clearly the conditions are not separated correctly.

error

There is a code example on the main page: https://github.com/unfoldtoolbox/UnfoldSim.jl

data,evts = UnfoldSim.predef_eeg(;n_trials=20,noiselevel=0.8)
I got this error:
image

But everything works after:

data, evts = UnfoldSim.predef_eeg(;n_repeats=20, noiselevel=0.8, return_epoched=true)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.