Unfold.jl
Neuroimaging (EEG, fMRI, pupil ...) regression analysis in Julia
Install / Use
/learn @unfoldtoolbox/Unfold.jlREADME
|Estimation|Visualisation|Simulation|BIDS pipeline|Decoding|Statistics|MixedModelling| |---|---|---|---|---|---|---| | <a href="https://github.com/unfoldtoolbox/Unfold.jl/tree/main"><img src="https://github-production-user-asset-6210df.s3.amazonaws.com/10183650/277623787-757575d0-aeb9-4d94-a5f8-832f13dcd2dd.png" alt="Unfold.jl Logo"></a> | <a href="https://github.com/unfoldtoolbox/UnfoldMakie.jl"><img src="https://github-production-user-asset-6210df.s3.amazonaws.com/10183650/277623793-37af35a0-c99c-4374-827b-40fc37de7c2b.png" alt="UnfoldMakie.jl Logo"></a>|<a href="https://github.com/unfoldtoolbox/UnfoldSim.jl"><img src="https://github-production-user-asset-6210df.s3.amazonaws.com/10183650/277623795-328a4ccd-8860-4b13-9fb6-64d3df9e2091.png" alt="UnfoldSim.jl Logo"></a>|<a href="https://github.com/unfoldtoolbox/UnfoldBIDS.jl"><img src="https://github-production-user-asset-6210df.s3.amazonaws.com/10183650/277622460-2956ca20-9c48-4066-9e50-c5d25c50f0d1.png" alt="UnfoldBIDS.jl Logo"></a>|<a href="https://github.com/unfoldtoolbox/UnfoldDecode.jl"><img src="https://github-production-user-asset-6210df.s3.amazonaws.com/10183650/277622487-802002c0-a1f2-4236-9123-562684d39dcf.png" alt="UnfoldDecode.jl Logo"></a>|<a href="https://github.com/unfoldtoolbox/UnfoldStats.jl"><img src="https://github-production-user-asset-6210df.s3.amazonaws.com/10183650/277623799-4c8f2b5a-ea84-4ee3-82f9-01ef05b4f4c6.png" alt="UnfoldStats.jl Logo"></a>|<a href="https://github.com/unfoldtoolbox/UnfoldMixedModels.jl"><img src="https://github.com/user-attachments/assets/ffb2bba6-3a30-48b7-9849-7d4e7195b297" alt="UnfoldMixedModels.jl logo"></a>|
Package (-family) to perform linear / GAM / hierarchical / deconvolution regression on biological signals.
This kind of modelling is also known as encoding modeling, linear deconvolution, Temporal Response Functions (TRFs), linear system identification, and probably under other names. fMRI models with HRF-basis functions and pupil-dilation bases are also supported.
Getting started
🐍Python User?
We clearly recommend Julia 😉 - but Python users can use juliacall/Unfold directly from python!
Julia installation
<details> <summary>Click to expand</summary>The recommended way to install julia is juliaup. It allows you to, e.g., easily update Julia at a later point, but also test out alpha/beta versions etc.
TL:DR; If you dont want to read the explicit instructions, just copy the following command
Windows
AppStore -> JuliaUp, or winget install julia -s msstore in CMD
Mac & Linux
curl -fsSL https://install.julialang.org | sh in any shell
Unfold.jl installation
using Pkg
Pkg.add("Unfold")
Usage
Please check out the documentation for extensive tutorials, explanations and more!
Tipp on Docs
You can read the docs online: - or use the
?fit, ?effects julia-REPL feature. To filter docs, use e.g. ?fit(::UnfoldModel)
Here is a quick overview on what to expect.
What you need
using Unfold
events::DataFrame
# formula with or without random effects
f = @formula 0~1+condA
fLMM = @formula 0~1+condA+(1|subject) + (1|item)
# in case of [overlap-correction] we need continuous data plus per-eventtype one basisfunction (typically firbasis)
data::Array{Float64,2}
basis = firbasis(τ=(-0.3,0.5),srate=250) # for "timeexpansion" / deconvolution
# in case of [mass univariate] we need to epoch the data into trials, and a accompanying time vector
epochs::Array{Float64,3} # channel x time x epochs (n-epochs == nrows(events))
times = range(0,length=size(epochs,3),step=1/sampling_rate)
To fit any of the models, Unfold.jl offers a unified syntax:
| Overlap-Correction | Mixed Modelling | julia syntax |
|:---:|:---:|---|
| | | fit(UnfoldModel,[Any=>(f,times)),evts,data_epoch] |
| x | | fit(UnfoldModel,[Any=>(f,basis)),evts,data] |
| | x | fit(UnfoldModel,[Any=>(fLMM,times)),evts,data_epoch] |
| x | x | fit(UnfoldModel,[Any=>(fLMM,basis)),evts,data] |
Comparison to Unfold (matlab)
<details> <summary>Click to expand</summary>The matlab version is still maintained, but active development happens in Julia.
| Feature | Unfold | unmixed (defunct) | Unfold.jl | |-------------------------|--------|---------|-----------| | overlap correction | x | x | x | | non-linear splines | x | x | x | | speed | | 🐌 | ⚡ 2-100x | | GPU support | | | 🚀| | plotting tools | x | | UnfoldMakie.jl | | Interactive plotting | | | stay tuned - coming soon! | | simulation tools | x | | UnfoldSim.jl | | BIDS support | x | | alpha: UnfoldBIDS.jl) | | sanity checks | x | | x | | tutorials | x | | x | | unittests | x | | x | | Alternative bases e.g. HRF (fMRI) | | | x | | mix different basisfunctions | | | x | | different timewindows per event | | | x | | mixed models | | x | x | | item & subject effects | | (x) | x | | decoding | | | UnfoldDecode.jl | | outlier-robust fits | | | many options (but slower) | | 🐍Python support | | | via juliacall|
</details>Contributions
Contributions are very welcome. These could be typos, bugreports, feature-requests, speed-optimization, new solvers, better code, better documentation.
How-to Contribute
You are very welcome to raise issues and start pull requests!
Adding Documentation
- We recommend to write a Literate.jl document and place it in
docs/literate/FOLDER/FILENAME.jlwithFOLDERbeingHowTo,Explanation,TutorialorReference(recommended reading on the 4 categories). - Literate.jl converts the
.jlfile to a.mdautomatically and places it indocs/src/generated/FOLDER/FILENAME.md. - Edit make.jl with a reference to
docs/src/generated/FOLDER/FILENAME.md.
Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/jschepers"><img src="https://avatars.githubusercontent.com/u/22366977?v=4?s=100" width="100px;" alt="Judith Schepers"/><br /><sub><b>Judith Schepers</b></sub></a><br /><a href="#bug-jschepers" title="Bug reports">🐛</a> <a href="#code-jschepers" title="Code">💻</a> <a href="#doc-jschepers" title="Documentation">📖</a> <a href="#tutorial-jschepers" title="Tutorials">✅</a> <a href="#ideas-jschepers" title="Ideas, Planning, & Feedback">🤔</a> <a href="#test-jschepers" title="Tests">⚠️</a></td> <td align="center" valign="top" width="14.28%"><a href="http://www.benediktehinger.de"><img src="https://avatars.githubusercontent.com/u/10183650?v=4?s=100" width="100px;" alt="Benedikt Ehinger"/><br /><sub><b>Benedikt Ehinger</b></sub></a><br /><a href="#bug-behinger" title="Bug reports">🐛</a> <a href="#code-behinger" title="Code">💻</a> <a href="#doc-behinger" title="Documentation">📖</a> <a href="#tutorial-behinger" title="Tutorials">✅</a> <a href="#ideas-behinger" title="Ideas, Planning, & Feedback">🤔</a> <a href="#test-behinger" title="Tests">⚠️</a> <a href="#infra-behinger" title="Infrastructure (HosRelated Skills
node-connect
338.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.6kCommit, push, and open a PR
