Adaptive Mixture ICA in Python
Project description
AMICA-Python
A Python implementation of the AMICA (Adaptive Mixture Independent Component Analysis) algorithm for blind source separation, that was originally developed in FORTRAN by Jason Palmer at the Swartz Center for Computational Neuroscience (SCCN). AMICA-Python is correctness tested against the Fortran implementation.
| Python | Fortran |
|---|---|
Installation
AMICA-Python is available from PyPI and conda-forge. Since AMICA-Python uses PyTorch for the core numerical routines, installation depending on which PyTorch build you need (e.g. CPU-only or with GPU support):
uv pip install "amica-python[torch-cpu]"
For a CUDA-enabled PyTorch install, use:
uv pip install "amica-python[torch-cuda]"
You can also install with pip:
python -m pip install "amica-python[torch-cpu]"
Or with conda-forge, which installs the PyTorch runtime dependency as part of the AMICA-Python package:
conda install -c conda-forge amica-python
If you need a specific PyTorch build, install PyTorch first using the instructions for your platform at pytorch.org, then install AMICA-Python without the PyTorch extra:
python -m pip install amica-python
Usage
AMICA-Python exposes a scikit-learn interface. Here is an example of how to use it:
import numpy as np
from scipy import signal
from amica import AMICA
rng = np.random.default_rng(0)
n_samples = 2000
time = np.linspace(0, 8, n_samples)
s1 = np.sin(2 * time) # Sinusoidal
s2 = np.sign(np.sin(3 * time)) # Square wave
s3 = signal.sawtooth(2 * np.pi * time) # Sawtooth
S = np.c_[s1, s2, s3]
S += 0.2 * rng.standard_normal(S.shape) # Add noise
S /= S.std(axis=0) # Standardize
A = np.array([[1, 1, 1],
[0.5, 2, 1.0],
[1.5, 1.0, 2.0]]) # Mixing matrix
X = S @ A.T # Observed mixtures
ica = AMICA(random_state=0)
X_new = ica.fit_transform(X)
GPU acceleration
If PyTorch was installed with CUDA support, you can fit AMICA on GPU:
ica = AMICA(device='cuda', random_state=0)
For more examples and documentation, please see the documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file amica_python-0.1.2.tar.gz.
File metadata
- Download URL: amica_python-0.1.2.tar.gz
- Upload date:
- Size: 62.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00118550647a2bc0e5c3c1a3c2f143c22c195a514d05f00419362b1eade0d211
|
|
| MD5 |
861908ff67b2d785169a5e68aa99b202
|
|
| BLAKE2b-256 |
c485cd5965f5a6873501a7a671e40a70784f94f3633e906ce505554c6d5d043b
|
File details
Details for the file amica_python-0.1.2-py3-none-any.whl.
File metadata
- Download URL: amica_python-0.1.2-py3-none-any.whl
- Upload date:
- Size: 68.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf57326cf77ece45e122b57bae1ead5c3771ca7912bec45ec0979e499adb857a
|
|
| MD5 |
579f1b9664cd9e23ae87c2798d38b943
|
|
| BLAKE2b-256 |
693471d2f032559436a36ec9e483a17cc258de2eb8dd8ec267c1a99faf07c11a
|