-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from unfoldtoolbox/prepublication
Prepublication - #244 Added benchmarking with comparison of UM with MNE and MATLAB to measure speed of creating and updating figures. - adding supportive axes for `plot_topoplot`, `plot_topoplotseries`, `plot_butterfly` so now it is possible for users to change interpolations and axes of subplots - adding Observables into `plot_topoplot` - #245 was solved by adding `visual.colormap` - #248 - #240 - #257 - #261 - issue with `with_theme` - `Contribute` page added - issues templates added - upgrade Color and ColorTypes
- Loading branch information
Showing
34 changed files
with
527 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Contribution guide | ||
Contributions are very welcome. These could be typos, bug reports, feature requests, speed optimization, better code, and better documentation. | ||
You are very welcome to raise issues and start pull requests. | ||
|
||
## Issues | ||
If you notice any bugs, such as crashing code, incorrect results or speed issues, please raise a GitHub issue. | ||
|
||
Before filing an issue please | ||
- check that there are no similar existing issues already | ||
- check that your versions are up to date | ||
|
||
If you want to report a bug, include your version and system information, as well as stack traces with all relevant information. | ||
If possible, condense your bug into the shortest example possible that the maintainers can replicate, a so called "minimal working example" or MWE. | ||
|
||
If you want to suggest a new feature, for example functionality that other plotting packages offer already, include supplementary material such as example images if possible, so it's clear what you are asking for. | ||
|
||
## Code contributions (Pull requests) | ||
When opening a pull request, please add a short but meaningful description of the changes/features you implemented. Moreover, please add tests (where appropriate) to ensure that your code is working as expected. | ||
|
||
For each feature you want to contribute, please file a separate PR to keep the complexity down and time to merge short. | ||
Add PRs in draft mode if you want to discuss your approach first. | ||
|
||
|
||
## Adding documentation | ||
1. We recommend to write a Literate.jl document and place it in `docs/literate/FOLDER/FILENAME.jl` with `FOLDER` being `HowTo`, `Explanations`, `Tutorials` or `Intro` ([recommended reading on the 4 categories](https://documentation.divio.com/)). | ||
2. Literate.jl converts the `.jl` file to a `.md` automatically and places it in `docs/src/generated/FOLDER/FILENAME.md`. | ||
3. Edit [make.jl](https://github.com/unfoldtoolbox/Unfold.jl/blob/main/docs/make.jl) with a reference to `docs/src/generated/FOLDER/FILENAME.md`. | ||
|
||
## Formatting (Beware of reviewdog :dog:) | ||
We use the [julia-format](https://github.com/julia-actions/julia-format) Github action to ensure that the code follows the formatting rules defined by [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl). | ||
When opening a pull request [reviewdog](https://github.com/reviewdog/reviewdog) will automatically make formatting suggestions for your code. | ||
|
||
## Seeking Help | ||
|
||
If you get stuck, here are some options to seek help: | ||
|
||
- Use the REPL `?` help mode. | ||
- Check the Documentation. |
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
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
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,119 @@ | ||
# # Speed measurement | ||
# Here we will compare the speed of plotting UnfoldMakie with MNE (Python) and EEGLAB (MATLAB). | ||
# | ||
# Three cases are measured: | ||
# - Single topoplot | ||
# - Topoplot series with 50 topoplots | ||
# - Topoplott animation with 50 timestamps | ||
# | ||
# Note that the results of benchmarking on your computer and on Github may differ. | ||
using UnfoldMakie | ||
using TopoPlots | ||
using PyMNE | ||
using PythonPlot | ||
using BenchmarkTools | ||
using Observables | ||
using CairoMakie | ||
|
||
# Data input | ||
dat, positions = TopoPlots.example_data() | ||
df = UnfoldMakie.eeg_array_to_dataframe(dat[:, :, 1], string.(1:length(positions))); | ||
|
||
# # Topoplots | ||
|
||
# UnfoldMakie.jl | ||
@benchmark plot_topoplot(dat[:, 320, 1]; positions = positions) | ||
|
||
# UnfoldMakie.jl with DelaunayMesh | ||
@benchmark plot_topoplot( | ||
dat[:, 320, 1]; | ||
positions = positions, | ||
topo_interpolation = (; interpolation = DelaunayMesh()), | ||
) | ||
|
||
# MNE | ||
posmat = collect(reduce(hcat, [[p[1], p[2]] for p in positions])') | ||
pypos = Py(posmat).to_numpy() | ||
pydat = Py(dat[:, 320, 1]) | ||
|
||
@benchmark begin | ||
f = PythonPlot.figure() | ||
PyMNE.viz.plot_topomap( | ||
pydat, | ||
pypos, | ||
sphere = 1.1, | ||
extrapolate = "box", | ||
cmap = "RdBu_r", | ||
sensors = false, | ||
contours = 6, | ||
) | ||
f.show() | ||
end | ||
|
||
# # Topoplot series | ||
|
||
# Note that UnfoldMakie and MNE have different defaults for displaying topoplot series. | ||
# UnfoldMakie in `plot_topoplot` averages over time samples. | ||
# MNE in `plot_topopmap` displays single samples without averaging. | ||
# | ||
# UnfoldMakie.jl | ||
@benchmark begin | ||
plot_topoplotseries( | ||
df; | ||
bin_num = 50, | ||
positions = positions, | ||
axis = (; xlabel = "Time windows [s]"), | ||
) | ||
end | ||
|
||
# MNE | ||
easycap_montage = PyMNE.channels.make_standard_montage("standard_1020") | ||
ch_names = pyconvert(Vector{String}, easycap_montage.ch_names)[1:64] | ||
info = PyMNE.create_info(PyList(ch_names), ch_types = "eeg", sfreq = 1) | ||
info.set_montage(easycap_montage) | ||
simulated_epochs = PyMNE.EvokedArray(Py(dat[:, :, 1]), info) | ||
|
||
@benchmark simulated_epochs.plot_topomap(1:50) | ||
|
||
# MATLAB | ||
# | ||
# Running MATLAB on a GitHub Action is not easy. | ||
# So we benchmarked three consecutive executions (on a screenshot) on a server with an AMD EPYC 7452 32-core processor. | ||
# Note that Github and the server we used for MATLAB benchmarking are two different computers, which can give different timing results. | ||
|
||
# ```@raw html | ||
# <img src="../../../assets/MATLAB_benchmarking.png" align="middle"/> | ||
# ``` | ||
|
||
|
||
# # Animation | ||
# The main advantage of Julia is the speed with which the figures are updated. | ||
|
||
timestamps = range(1, 50, step = 1) | ||
framerate = 50 | ||
|
||
# UnfoldMakie with .gif | ||
|
||
@benchmark begin | ||
f = Makie.Figure() | ||
dat_obs = Observable(dat[:, 1, 1]) | ||
plot_topoplot!(f[1, 1], dat_obs, positions = positions) | ||
record(f, "topoplot_animation_UM.gif", timestamps; framerate = framerate) do t | ||
dat_obs[] = @view(dat[:, t, 1]) | ||
end | ||
end | ||
|
||
# ![](topoplot_animation_UM.gif) | ||
|
||
# MNE with .gif | ||
@benchmark begin | ||
fig, anim = simulated_epochs.animate_topomap( | ||
times = Py(timestamps), | ||
frame_rate = framerate, | ||
blit = false, | ||
image_interp = "cubic", # same as CloughTocher | ||
) | ||
anim.save("topomap_animation_mne.gif", writer = "ffmpeg", fps = framerate) | ||
end | ||
|
||
# ![](topomap_animation_mne.gif) |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
Oops, something went wrong.