# MWF toolbox for EEG artifact removal
## License
See the [LICENSE](LICENSE.md) file for license rights and limitations.
By downloading and/or installing this software and associated files on your computing system you agree to use the software under the terms and condition as specified in the License agreement.
## Using the MWF toolbox
### About
This MATLAB toolbox implements an algorithm based on the Multi-channel Wiener Filter (MWF)
for processing multi-channel EEG as published in [1]. The algorithm removes any type of
artifact marked a-priori by the user from the EEG in order to enhance signal quality for
further processing.
The functions of the MWF toolbox can be used either
-through a graphical user interface (see [GUI manual](gui/GUI_manual.pdf))
-directly in your own scripts or from the MATLAB command window (see [MWF manual](doc/mwf_manual.pdf)). Manual marking of artifacts can be done in [EEGLAB](https://sccn.ucsd.edu/eeglab/index.php) (Make sure EEGLAB is added to the MATLAB path: you can check this by typing "eeglab" in the command window)
NOTE: Scripting + EEGLab was developed and tested in MATLAB R2015a. The use of the GUI in V2.0 requires MATLAB R2018b
### Documentation
All functions are documented properly in their respective m-files. Additional documentation and examples can be found in:
- For the GUI: [gui](gui/) folder, which contains a [manual](gui/GUI_manual.pdf) in pdf format and demo data to illustrate the usage of the various functions. Open the GUI with the file [main_GUI.m](gui/main_GUI.m).
- For scripting: [doc](doc/) folder, which contains a [manual](doc/mwf_manual.pdf) in pdf format and a [MWF demo file](doc/mwf_demo.m) to illustrate
the usage of the various functions. A quick start guide is provided below.
### Quick start guide for the graphical user interface (GUI)
NEW: Release 2.0 includes a GUI to mark artifact segments, apply the MWF and inspect signals during the process. Use of the GUI is an optional alternative to using MWF functions from the MATLAB command line/scripts or with EEGLAB for manual marking of artifacts (see below). Open the GUI with the file [main_GUI.m](gui/main_GUI.m).
More information about functionality and usage can be found in the included [GUI manual](gui/GUI_manual.pdf), which includes a quick start guide on demo data.
The MWF GUI requires MATLAB **version R2018b** or later (scripting with MWF functions (see below) also works with older versions of Matlab).
### Quick start guide for scripting with MWF functions (without GUI)
All functions needed to perform MWF-based EEG artifact removal are in the mwf folder.
Before starting, make sure that this folder is added to the MATLAB path.
The MWF first requires examples of EEG with and EEG without artifacts. Based on this
segmentation of the EEG data, the MWF can be computed and applied in order to remove
the artifacts. This two-step approach is fully implemented in the toolbox.
**Step 1: EEG segmentation.** In the toolbox, this step is performed by manual marking
of the data using EEGlab. If you have your EEG data matrix in the the MATLAB workspace
(channels x samples), you can create(*) the artifact mask by calling
mask = mwf_getmask(EEG, samplerate); [requires EEGLAB to be installed (**)]
A pop-up window will appear in which artifacts can be marked by clicking and dragging over
them. When done, clicking the 'Save Marks' button will close the pop-up window and the function
returns a binary (1 x samples) mask. In this mask, ones correspond to artifact segments, and
zeros correspond to clean data. Optionally, the mask may contain NaNs which indicate segments
to be ignored from the MWF computation (i.e. they belong neither to the artifact nor the clean
segments). Section 4.1.4. of the [manual](doc/mwf_manual.pdf) contains extra
tips on annotating artifacts.
(*) The artifact marking/detection step is not inherently a part of the MWF algorithm: if you prefer,
you can also use a different method for acquiring the artifact mask (e.g. an automatic method,
for example based on thresholding,. . . ). The mask needs to consist of ones, zeros and NaNs,
and must have the same length as the EEG data.
(**)The function mwf_getmask requires EEGLAB to be installed (only required for manual marking of artifacts):
[EEGLAB website](https://sccn.ucsd.edu/eeglab/index.php). (Make sure EEGLAB is added to the MATLAB path: you can check this by typing "eeglab" in the command window)
**Important note:** all segments that are not marked and come *before* the lasted marked
segment will be treated as artifact-free samples in the training of the filter. The samples
that come after the last marked segment are not used in the filter design. In other words:
the filter design assumes that *all* artifacts before the last marked artifact are marked.
Because samples after the lasted marked segment are ignored, it is not necessary to go through
the entire signal to mark all the artifacts. It is sufficient to annotate only the first few
seconds or minutes of the signal. However, the more artifacts are marked, the better the filter
design will be. Additionally, there should be enough clean (unmarked) segments before the last
marked artifact for a good filter design.
**Step 2: MWF artifact removal** is performed by calling the mwf_process function. It
requires the EEG data, the mask indicating which segments are artifacts, and optionally a
delay parameter:
clean_EEG = mwf_process(EEG, mask, delay);
More parameters than the delay value can be changed and used by setting them in a struct using mwf_params()
function and passing this struct to the mwf_process function:
params = mwf_params(...
'delay', 5, ...
'delay_spacing', 2);
clean_EEG = mwf_process(EEG, mask, params);
This will return the artifact-free EEG in the clean EEG variable. Using a delay greater than zero
includes temporal information into the filter, leading to better artifact removal but
may increase processing time. If omitted, the default value is zero. See [1] for more details.
### 2024 update - Optional modification to MWF artifact removal by using sparser delays
A contribution made by Neil Bailey (Monash University) suggests that MWF cleaning can be improved
by using sparse delay spacing. For example, instead of using consecutive delays [-3 -2 -1 0 1 2 3],
it is now possible to specify the "delay_spacing" parameter to create a sparser sampling such as [-9 -6 -3 0 3 6 9],
which is obtained with "delay = 3" and "delay_spacing = 3". This is also useful to include more relevant samples when your data has a higher sample rate.
From informal testing by Neil Bailey, for data sampled at 1000Hz, optimal performance at cleaning
eye blink artifacts was obtained by using a delay parameter setting of 8 (so that 8 positive & negative delays are included in the MWF ),
as well as a delay spacing of 16 (so that each delay is separated from the previous delay by 16 samples or 16 milliseconds).
This provides the MWF algorithm with delay embedded covariance matrices that characterises 272ms of the data, enabling the MWF algorithm
to account for a considerable proportion of each blink period. For muscle artifact cleaning
of data sampled at 1000Hz, a delay period of 10 and delay spacing of 2 was found to be optimal.
To use this functionality, the delay_spacing parameter can be set using the mwf_params function (as in the example above).
## References
[1] Somers, B., Francart, T. and Bertrand, A. (2018). A generic EEG artifact removal algorithm based on the multi-channel Wiener filter.
_Journal of Neural Engineering, 15_(3), 036007. DOI: 10.1088/1741-2552/aaac92
没有合适的资源?快使用搜索试试~ 我知道了~
基于 MWF 的 EEG 伪影消除Matlab代码.rar
共70个文件
m:53个
mat:7个
pdf:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 84 浏览量
2024-06-14
20:44:25
上传
评论
收藏 12.63MB RAR 举报
温馨提示
1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
资源推荐
资源详情
资源评论
收起资源包目录
基于 MWF 的 EEG 伪影消除Matlab代码.rar (70个子文件)
基于 MWF 的 EEG 伪影消除Matlab代码
mwf-artifact-removal-master
LICENSE.md 8KB
mwf
mwf_getmask.m 7KB
mwf_params.m 5KB
mwf_manual.pdf 460KB
mwf_apply.m 2KB
mwf_compute.m 3KB
mwf_performance.m 2KB
+mwf_utils
ensure_symmetry.m 472B
get_mask_dummy_callback.m 142B
check_dimensions.m 893B
stack_delay_data.m 3KB
sort_evd.m 799B
mwf_process.m 1KB
doc
mwf_manual.pdf 460KB
mwf_demo.m 5KB
manual_build
fig_getmask.pdf 279KB
mwf_manual.tex 18KB
demo_data.mat 5.58MB
paper
method_comparison
method_cached_components.m 2KB
method_fastica.m 1KB
method_infomax_ica.m 1KB
method_cca.m 1KB
paper_figures
movement_artifact_figure_mask.mat 295B
pf_hybriddata.m 2KB
pf_timelags.m 924B
pf_allfigures.m 814B
pf_blink_muscle_artifact.m 1KB
pf_methodtables.m 4KB
pf_rank.m 2KB
pf_movement_artifact.m 1KB
pf_eigenvalues.m 930B
pf_printpdf.m 806B
pf_muscle_only_artifact.m 1KB
pf_eeglabmarkings.m 558B
+contributions
shadedErrorbar.m 4KB
sigstar.m 8KB
bonf_holm.m 4KB
pf_methodcomparison.m 3KB
paper_dataset
demo_eyeblink.m 1KB
get_artifact_data.m 1KB
EEG_data_synthetic.m 4KB
get_artifact_mask.m 5KB
get_artifact_data_synthetic.m 1KB
remove_artifacts_allsubjects.m 1KB
remove_artifacts.m 1KB
get_name_from_id.m 868B
mwfgui_localsettings_template.m 960B
EEG_data_readout.m 2KB
blink_template.mat 2KB
deprecated_studies
study_othermethods.m 2KB
study_synthetic_SNR.m 2KB
study_noiseweighting.m 620B
study_overfitting.m 2KB
study_timelag.m 921B
study_rank.m 1KB
study_synthetic.m 2KB
study_nchannels.m 2KB
gui
main_GUI.m 40KB
GUI_manual.pdf 142KB
demo_data
gui_channel_labels.mat 674B
gui_64_Channel_locations.mat 987B
gui_demo_data.mat 5.58MB
gui_demo_marks.mat 281B
functions
mwf_compute_gui.m 3KB
Topoplot_GUI.m 19KB
Topoplot_GUI.fig 42KB
Compute_options.fig 13KB
main_GUI.fig 77KB
Compute_options.m 11KB
README.md 8KB
共 70 条
- 1
资源评论
matlab科研助手
- 粉丝: 3w+
- 资源: 5960
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功