ICA_BlindSourceSeparation
Documentation for ICA_BlindSourceSeparation.
ICA_BlindSourceSeparation.demo
ICA_BlindSourceSeparation.estimate_cumulants
ICA_BlindSourceSeparation.estimate_cumulants
ICA_BlindSourceSeparation.gradient
ICA_BlindSourceSeparation.ica_jade
ICA_BlindSourceSeparation.ica_picard
ICA_BlindSourceSeparation.ica_shibbs
ICA_BlindSourceSeparation.joint_diagonalize
ICA_BlindSourceSeparation.l_bfgs_direction
ICA_BlindSourceSeparation.line_search
ICA_BlindSourceSeparation.loss
ICA_BlindSourceSeparation.plot_dataset
ICA_BlindSourceSeparation.proj_hessian_approx
ICA_BlindSourceSeparation.read_dataset
ICA_BlindSourceSeparation.regularize_hessian
ICA_BlindSourceSeparation.score
ICA_BlindSourceSeparation.score_der
ICA_BlindSourceSeparation.solve_hessian
ICA_BlindSourceSeparation.sort_by_energy
ICA_BlindSourceSeparation.whiten_dataset
ICA_BlindSourceSeparation.whiten_dataset
ICA_BlindSourceSeparation.demo
— Methoddemo()
Plots the whitened data in the foetal_ecg database.
ICA_BlindSourceSeparation.estimate_cumulants
— Methodestimate_cumulants(X::AbstractMatrix)
Returns cumulant matrix.
ICA_BlindSourceSeparation.estimate_cumulants
— MethodEstimation of cumulant matrices
ICA_BlindSourceSeparation.gradient
— Methodgradient(Y, psiY)
Compute the gradient of the contrast function with respect to the input signals.
Arguments
Y::AbstractMatrix{<:Real}
: anN×T
matrix where each row is a signal component overT
samples.psiY::AbstractMatrix{<:Real}
: the elementwise derivative of the contrast function, same size asY
.
Returns
- An
N×N
matrix representing the relative gradient
ICA_BlindSourceSeparation.ica_jade
— MethodJADE Algorithm for ICA source separation
ICA_BlindSourceSeparation.ica_picard
— Methodica_picard(dataset::sensorData, m::Int, maxiter::Int, tol::Real, lambda_min::Real, ls_tries::Int; verbose::Bool=false)
Perform Independent Component Analysis (ICA) using the Picard algorithm with limited-memory BFGS optimization.
Arguments
dataset::sensorData
m::Int
: Size of L-BFGS's memory. Typical values are in the range 3-15maxiter::Int
: Maximal number of iterationstol::real
: tolerance for the stopping criterion. Iterations stop when the norm of the projected gradient gets smaller than tol.lambda_min::Real
: Minimum eigenvalue for regularizing the Hessian approximation.ls_tries::Int
: Number of tries allowed for the backtracking line-search. When that number is exceeded, the direction is thrown away and the gradient is used instead.verbose::Bool=false
: If true, prints the informations about the algorithm.
Returns
sensorData
: A newsensorData
object containing the unmixed data.
ICA_BlindSourceSeparation.ica_shibbs
— Methodica_shibbs(dataset::sensorData, m::Integer, maxSteps::Integer)
Outer loop of the shibbs algorithm. Whitens data and loops untile diagonalization result is within threshold. Returns the dataset combined with transformation matrix as well as the transformation Matrix
ICA_BlindSourceSeparation.joint_diagonalize
— Methodjoint_diagonalize(CM_in::AbstractMatrix, thresh::Real, max_iters::Integer)
Returns diagonalization matrix and rotation size
ICA_BlindSourceSeparation.l_bfgs_direction
— Methodl_bfgs_direction(G, h, s_list, y_list, r_list)
Compute a search direction using the limited-memory BFGS (L-BFGS) algorithm.
Arguments
- `G::AbstractMatrix{<:Real}: the current gradient.
h::AbstractMatrix{<:Real}
: a diagonal approximation to the Hessian.s_list::Vector{AbstractMatrix{<:Real}}
: list of previous update vectors.y_list::Vector{AbstractMatrix{<:Real}}
: list of previous gradient differences.r_list::Vector{Float64}
: list of scalars for each pair(s, y)
.
Returns
- the descent direction computed using the L-BFGS two-loop recursion.
ICA_BlindSourceSeparation.line_search
— Methodfunction line_search(Y, direction, signs, current_loss; ls_tries)
Perform a backtracking line search using a matrix exponential update.
Arguments
Y::AbstractMatrix{<:Real}
: current signal matrix (N×T
).direction::AbstractMatrix{<:Real}
: descent direction matrix of the same size asY
.signs::AbstractVector{<:Real}
: sign weights for the loss, same size asY
.current_loss::Real
: current loss value, orInf
to force recomputation.ls_tries::Integer
(keyword): maximum number of backtracking steps.
Returns
- A tuple
(converged, Y_new, new_loss, alpha)
where converged::Bool
indicates whether a successful step was found,Y_new::AbstractMatrix{<:Real}
is the updated signal matrix (or original if no step succeeded),new_loss::Real
is the loss atY_new
,alpha::Real
is the final step size.
ICA_BlindSourceSeparation.loss
— Methodloss(Y, signs)
Compute the total loss for a set of signals.
Arguments
Y::AbstractMatrix{<:Real}
: matrix of shapeN×T
, where each row is a signal component overT
samples.signs::AbstractMatrix{<:Real}
: matrix of the same shape asY
, containing signs or weights for each signal value.
Returns
- A scalar representing the average contrast-based loss across all components and time steps.
ICA_BlindSourceSeparation.plot_dataset
— Methodplot_matrix(dataset::sensorData)
Plots each column of the dataset against the timestamp vector
ICA_BlindSourceSeparation.proj_hessian_approx
— Methodproj_hessian_approx(Y, psidY_mean, G)
Compute an approximation of the projected Hessian matrix.
Arguments
Y::AbstractMatrix{<:Real}
: anN×T
matrix of current signal components.psidY_mean::AbstractVector{<:Real}
: a length-N
vector containing the average of the second derivative (or negative squared derivative) of the contrast function for each component.G::AbstractMatrix{<:Real}
: the gradient matrix of sizeN×N
.
Returns
- An
N×N
symmetric matrix approximating the projected Hessian.
ICA_BlindSourceSeparation.read_dataset
— Methodread_dataset(filename::String) -> sensorData
Reads a file containing numbers separated by spaces or tabs. Number of columns is detected by analyzing the first valid line. Returns an instance of sensorData.
ICA_BlindSourceSeparation.regularize_hessian
— Methodregularize_hessian(h, lambda_min)
Clip the diagonal values of the Hessian approximation from below, ensuring all values are at least lambda_min
.
Arguments
h::AbstractMatrix{<:Real}
: a diagonal matrix, where diagonal elements approximate eigenvalues.lambda_min::Real
: minimum allowed eigenvalue
Returns
- A matrix of the same size as
h
, with all values less thanlambda_min
replaced bylambda_min
ICA_BlindSourceSeparation.score
— Methodscore(Y::AbstractArray{<:Real})
Apply the hyperbolic tangent elementwise to each entry of Y
.
Arguments
Y::AbstractArray{<:Real}
: input array (vector, matrix, or higher‑dimensional array) of real numbers.
Returns
- an array with the same shape as
Y
, where each element istanh(y)
.
ICA_BlindSourceSeparation.score_der
— Methodscore_der(psiY::AbstractMatrix{<:Real})
Computes the average derivative of the hyperbolic tangent nonlinearity for each row of psiY
.
Arguments
psiY::AbstractMatrix{<:Real}
: input array of sizeN×T
, where each row is a signal component overT
observations.
Returns
- a vebtor in which each entry represents the average derivative of the
tanh
nonlinearity, evaluated at each value in the corresponding row ofpsiY
.
ICA_BlindSourceSeparation.solve_hessian
— Methodsolve_hessian(G, h)
Compute the product of the inverse Hessian approximation with the gradient.
Arguments
G::AbstractMatrix{<:Real}
: the gradient matrix.h::AbstractMatrix{<:Real}
: diagonal approximation of the Hessian.
Returns
- A matrix of same size as
G
, where each element isG[i,j] / h[i,j]
.
ICA_BlindSourceSeparation.sort_by_energy
— Methodsort_by_energy(B::AbstractMatrix)
Sort rows of B to put most energetic sources first Returns sorted matrix
ICA_BlindSourceSeparation.whiten_dataset
— Methodwhiten_dataset(X::sensorData, m::Int64) -> sensorData, W::Matrix{Float64}, iW::Matrix{Float64}
Applies PCA whitening to TxN data matrix to decorrelate m sources T: number of samples n: number of sensors m: number of sources Returns the whitened dataset (Txm data matrix), whitening matrix W (mxn), pseudo-inverse whitening matrix iW (nxm)
ICA_BlindSourceSeparation.whiten_dataset
— Methodwhiten_dataset(X::sensorData)
Applies PCA whitening to TxN data matrix T: number of samples N: number of sensors Returns the whitened dataset.