# Spectral Parameterization - Matlab Wrapper
This repository offers a Matlab wrapper for [specparam](https://github.com/fooof-tools/fooof).
The main documentation for spectral parameterization is on the [documentation site](https://fooof-tools.github.io/fooof/).
This repository describes the Matlab wrapper, in which you call the Python implementation of FOOOF from Matlab,
without having to interact directly with Python. Under the hood, this approach does still use the Python code
of the original implemetation.
## Other Matlab Workflows
An alternative to using the wrapper from Matlab, you can also try the
[Matlab->Python->Matlab](https://github.com/fooof-tools/mat_py_mat)
approach. In this approach, there are examples of how to spectral parameterization, in Python,
integrated into a primarily Matlab workflow.
Alternately, there are also some toolboxes which have integrated the spectral parameterization
algorithm, including re-implementations such that you don't have to use / install Python.
The spectral parameterization algorithm has also been implemented in the following Matlab toolboxes:
- The [Brainstorm](https://neuroimage.usc.edu/brainstorm/Introduction) toolbox, with an associated
[tutorial](https://neuroimage.usc.edu/brainstorm/Tutorials/Fooof)
- The [Fieldtrip](https://www.fieldtriptoolbox.org/) toolbox, with an associated
[tutorial](https://www.fieldtriptoolbox.org/example/fooof/)
## FOOOF_MAT
The Matlab wrapper is Matlab code that calls the Python implementation of fooof. This requires that you have Python & fooof installed, but does not require you to ever use or write Python code yourself.
To use the wrapper, first install Python & fooof - there are instructions to do so below. Then clone or download this repository, and use the provided Matlab code to do spectral parameterization. Typically, the only function you will need to run is 'fooof.m', which has documentation on inputs and outputs.
Note that this is a very minimal wrapper - it provides access only to the core algorithm, and does not offer access to most of the extra utilities in the Python module. However, since the fitting algorithm is the core purpose of the module, you do have full access to the model itself, including all inputs settings and model outputs.
#### Dependencies
This Matlab wrapper uses the Python support introduced by Matlab in 2014b, and as such requires that version, or higher, to run.
## Installing Python & fooof
Using the Matlab wrapper and/or the Mat-Py-Mat approach require that Python & fooof be installed. The easiest way to do this is as follows:
#### Install Python
To call Python from Matlab, you will need to have Python installed.
One option to install Python, as well as all the dependencies you need and including tools like Jupyter notebook, is to use the Anaconda distribution. To do so, go to the [Anaconda Website](https://www.anaconda.com/download/) and download the latest version Python3 version available. Install the file you download, and then you should be good to go!
Note that your computer may already have a version of Python, but you should still go an install a new one. This ensures that you can have a new version of Python where you can install new modules, without interfering with your system Python.
You can also install Python without using Anaconda, for example directly from [python.org](https://www.python.org/downloads/). This might be useful, as Matlab doesn't always seem to work well with the Anaconda distribution.
If you are having trouble getting Python set up with Matlab, this
[blog post](https://irenevigueguix.wordpress.com/2020/03/25/loading-python-into-matlab/)
also offers a step-by-step guide.
#### Install FOOOF
FOOOF can be installed through pip, meaning you just have to run the following from the command line:
`pip install fooof`
If you're on mac, 'command line' means terminal - after installing anaconda, just copy the above command into the terminal, and it should work. If you're on windows, you will need to run this in 'anaconda command prompt' which is basically a command line specifically for managing Python with Anaconda.
#### Calling Python from Matlab
Once you have downloaded Python, you shouldn't need to do anything for Matlab to be able to
[call Python](https://www.mathworks.com/help/matlab/call-python-libraries.html).
The most common problem seems to be if Matlab is not using the correct version or location for Python. If calling Python is not working, then checking and setting where Matlab is calling Python from is likely the solution.
To check and update which Python Matlab is using, you can use
[pyversion](https://www.mathworks.com/help/matlab/ref/pyversion.html), or
[pyenv](https://www.mathworks.com/help/matlab/ref/pyenv.html)
if you are on a newer version of Matlab (>= R2019b).
For example, you can run `pyversion` to see which Python you are using, and update it if required.
Note that you must do this _after installing Python and FOOOF_.
```
% Check which python is being used
pyversion
% The print out from above should tell you which Python you are calling
% It should show that you are using Python version 3.X
% If you are using anaconda, it should show your Python is in the anaconda folder
% If either of these things are not right, reset which Python you are using, as below
% Set python version to use
% Note: you must do this first thing after opening Matlab (relaunch if you need to)
% You should only ever have to run this at most, once.
% You might need to change the path to where your python or anaconda install is
% For example, your anaconda folder might be `anaconda3` instead of `anaconda`
% or your anaconda path might be somewhere else, for example, '/opt/anaconda3/bin/python'
pyversion('/anaconda/bin/python')
```
## Reference
If you use this code in your project, please cite::
Donoghue T, Haller M, Peterson EJ, Varma P, Sebastian P, Gao R, Noto T, Lara AH, Wallis JD,
Knight RT, Shestyuk A, & Voytek B (2020). Parameterizing neural power spectra into periodic
and aperiodic components. Nature Neuroscience, 23, 1655-1665.
DOI: 10.1038/s41593-020-00744-x
Direct link: https://doi.org/10.1038/s41593-020-00744-x
More information for how to cite this method can be found on the
[reference page](https://fooof-tools.github.io/fooof/reference.html).
没有合适的资源?快使用搜索试试~ 我知道了~
A Matlab wrapper for spectral parameterization.zip
共16个文件
m:10个
mat:2个
md:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 27 浏览量
2023-07-23
10:12:17
上传
评论
收藏 437KB ZIP 举报
温馨提示
A Matlab wrapper for spectral parameterization.zip
资源推荐
资源详情
资源评论
收起资源包目录
A Matlab wrapper for spectral parameterization.zip (16个子文件)
fooof_mat-main
LICENSE 1KB
examples
data
ch_dat_one.mat 210KB
ch_dat_two.mat 215KB
fooof_example_plot_model.m 607B
fooof_example_one_spectrum.m 582B
fooof_example_multi_spectra.m 698B
CITATION.cff 1KB
.gitignore 47B
fooof_mat
fooof_unpack_results.m 1KB
fooof_plot.m 1KB
fooof.m 3KB
fooof_group.m 1KB
fooof_get_model.m 886B
fooof_check_settings.m 1KB
fooof_version.m 771B
README.md 6KB
新建文件夹
共 16 条
- 1
资源评论
AbelZ_01
- 粉丝: 1010
- 资源: 5440
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功