Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 125 additions & 41 deletions examples/machine_learning/53_constrained_ICA_example.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/cedalion/sigdecomp/multimodal/arc_ebm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
from cedalion import cite

def arc_ebm(X: np.ndarray, guess_mat, constraint = 'correlation') -> np.ndarray:
"""Adaptive-reverse Constrained ICA by Entropy Bound Minimization (arc-EBM) is a constrained ICA algorithm.
arc-EBM calculates the blind source separation demixing matrix corresponding to X,
"""Adaptive-reverse (Spectrally) Constrained ICA by Entropy Bound Minimization (arc-EBM/arsc-EBM) is a constrained ICA algorithm.
arc-EBM/arsc-EBM calculates the blind source separation demixing matrix W corresponding to data X,
using the reference signals in guess_mat and the constraint specified by constraint.

Args:
X (np.ndarray, (Channels, Time Points)): the [N x T] input multivariate time series with dimensionality N observations/channels and T time points
guess_mat (np.ndarray, (Time Points, Referenced Channels)), (np.ndarray, (Time Points/2, Referenced Channels)): Time or frequency domain reference signals. The number of reference signals should be less than or equal to the number of channels in X. The first dimension should be T for time domain signals and T/2 for frequency domain signals.
constraint (str): the constraint to be used for the gradient step, either 'correlation' (default) or 'psd'
constraint (str): the constraint to be used for the gradient step, either 'correlation' (default) for arc-EBM or 'psd' for arsc-EBM

Returns:
W (np.ndarray, (Channels, Channels)): the [N x N] demixing matrix with weights for N channels/sources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import cedalion.data
from cedalion import cite

def arc_erbm(X: np.ndarray, guess_mat, p: int = None , pr_guess_mat = None) -> np.ndarray:
""" Adaptive-reverse Constrained ICA by Entropy Rate Bound Minimization (arc-ERBM) is a spectrally constrained ICA algorithm.
def arsc_erbm(X: np.ndarray, guess_mat, p: int = None , pr_guess_mat = None) -> np.ndarray:
""" Adaptive-reverse Spectrally Constrained ICA by Entropy Rate Bound Minimization (arsc-ERBM) is a constrained ICA algorithm.

Args:
X (np.ndarray, (Channels, Time Points)): the [N x T] input multivariate time series with dimensionality N observations/channels and T time points
Expand Down Expand Up @@ -106,7 +106,7 @@ def epsilon_grad(r_n_c):
# compute gradient vector
vec = (sign / np.linalg.norm(psd_s, 2)) * r_n_c - (np.abs(current_corr) / np.linalg.norm(psd_s, 2)**2) * psd_s
vec = vec.reshape((-1, 1, 1))
c_grad = (T/2) * mu_c[n] * np.sum( np.multiply(np.dot(C_tilde, w), vec), axis = 0 )
c_grad = (T/2) * mu_c[n] * np.sum( np.multiply(np.dot(C_tilde, w), vec), axis = 0 )
return c_grad

if constraint == 'phase_retrieval' :
Expand All @@ -117,7 +117,7 @@ def pr_update(amp, y, filter, X_filtered):

# filter reference amplitude
amp_filtered = sp.signal.lfilter(filter, 1, amp , axis = 0 )
amp_filtered = np.abs(np.fft.rfft(amp_filtered))
amp_filtered = np.abs(np.fft.rfft(amp_filtered))

# compute fft of estimated source
y_hat = np.fft.rfft(y)
Expand Down
Loading