# Stockwell
Python package for time-frequency analysis through Stockwell transform.
Based on original code from [NIMH MEG Core Facility].
[NIMH MEG Core Facility]: https://kurage.nimh.nih.gov/meglab/Meg/Stockwell.
## Installation
### C compiler
Part of this Python package is written in C, so you will need a C compiler.
On Linux (Debian or Ubuntu), install the `build-essential` package:
sudo apt install build-essential
On macOS, install the XCode Command Line Tools:
xcode-select --install
On Windows, install the [Microsoft C++ Build Tools].
[Microsoft C++ Build Tools]:
https://visualstudio.microsoft.com/visual-cpp-build-tools
### FFTW
Make sure that you have [FFTW](http://www.fftw.org) installed.
If you use Anaconda (Linux, macOS, Windows):
conda install fftw
If you use Homebrew (macOS)
brew install fftw
If you use `apt` (Debian or Ubuntu)
sudo apt install libfftw3-dev
### Install the Python package
Finally, install this Python package using pip:
pip install .
Or, alternatively, in "editable" mode:
pip install -e .
## Usage
Example usage:
```python
import numpy as np
from scipy.signal import chirp
import matplotlib.pyplot as plt
from stockwell import st
t = np.linspace(0, 10, 5001)
w = chirp(t, f0=12.5, f1=2.5, t1=10, method='linear')
fmin = 0 # Hz
fmax = 25 # Hz
df = 1./(t[-1]-t[0]) # sampling step in frequency domain (Hz)
fmin_samples = int(fmin/df)
fmax_samples = int(fmax/df)
stock = st.st(w, fmin_samples, fmax_samples)
extent = (t[0], t[-1], fmin, fmax)
fig, ax = plt.subplots(2, 1, sharex=True)
ax[0].plot(t, w)
ax[0].set(ylabel='amplitude')
ax[1].imshow(np.abs(stock), origin='lower', extent=extent)
ax[1].axis('tight')
ax[1].set(xlabel='time (s)', ylabel='frequency (Hz)')
plt.show()
```
You should get the following output:
![stockwell.png](stockwell.png)
You can also compute the inverse Stockwell transform, ex:
```python
inv_stock = st.ist(stock, fmin_samples, fmax_samples)
fig, ax = plt.subplots(2, 1, sharex=True)
ax[0].plot(t, w, label='original signal')
ax[0].plot(t, inv_stock, label='inverse Stockwell')
ax[0].set(ylabel='amplitude')
ax[0].legend(loc='upper right')
ax[1].plot(t, w - inv_stock)
ax[1].set_xlim(0, 10)
ax[1].set(xlabel='time (s)', ylabel='amplitude difference')
plt.show()
```
![inv_stockwell.png](inv_stockwell.png)
## References
Stockwell, R.G., Mansinha, L. & Lowe, R.P., 1996. Localization of the complex
spectrum: the S transform, IEEE Trans. Signal Process., 44(4), 998–1001,
doi:[10.1109/78.492555](https://doi.org/10.1109/78.492555)
[S transform on Wikipedia](https://en.wikipedia.org/wiki/S_transform).
没有合适的资源?快使用搜索试试~ 我知道了~
stockwell:适用于Python的Stockwell转换
共18个文件
py:4个
txt:3个
c:3个
需积分: 48 10 下载量 101 浏览量
2021-05-20
11:18:20
上传
评论
收藏 215KB ZIP 举报
温馨提示
斯托克韦尔 通过Stockwell变换进行时频分析的Python软件包。 基于原始代码。 安装 C编译器 该Python软件包的一部分是用C编写的,因此您将需要C编译器。 在Linux(Debian或Ubuntu)上,安装build-essential软件包: sudo apt install build-essential 在macOS上,安装XCode命令行工具: xcode-select --install 在Windows上,安装 。 快速傅立叶变换 确保已安装 。 如果您使用Anaconda(Linux,macOS,Windows): conda install fftw 如果您使用自制软件(macOS) brew install fftw 如果您使用apt (Debian或Ubuntu) sudo apt install libfftw3-dev 安装
资源详情
资源评论
资源推荐
收起资源包目录
stockwell-master.zip (18个子文件)
stockwell-master
setup.py 2KB
.gitignore 182B
stockwell.png 85KB
stockwell
__init__.py 61B
c_libs
unlicense.txt 1KB
st.c 8KB
sinemodule.c 2KB
stmodule.c 4KB
lib
__init__.py 0B
inv_stockwell.png 113KB
MANIFEST.in 97B
LICENSE.txt 21KB
scripts
make_wheel.bat 344B
wheel_repair.py 4KB
make_dist.sh 65B
make_wheel.sh 258B
README.md 3KB
CONTRIBUTORS.txt 32B
共 18 条
- 1
沈临白
- 粉丝: 44
- 资源: 4572
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0