fissa.neuropil module#
Functions for removal of neuropil from calcium signals.
- Authors:
Sander W Keemink <swkeemink@scimail.eu>
Scott C Lowe <scott.code.lowe@gmail.com>
- Created:
2015-05-15
- fissa.neuropil.separate(S, sep_method='nmf', n=None, max_iter=10000, tol=0.0001, random_state=892, max_tries=10, W0=None, H0=None, alpha=0.1, verbosity=1, prefix='')[source]#
Find independent signals, sorted by matching score against the first input signal.
- Parameters
- Sarray_like shaped (signals, observations)
2-d array containing mixed input signals. Each column of S should be a different signal, and each row an observation of the signals. For
S[i, j]
,j
is a signal, andi
is an observation. The first column,j = 0
, is considered the primary signal and the one for which we will try to extract a decontaminated equivalent.- sep_method{“ica”, “nmf”}
Which source separation method to use, either ICA or NMF.
"ica"
: Independent Component Analysis"nmf"
: Non-negative Matrix Factorization
- nint, optional
How many components to estimate. If
None
(default), for the NMF method,n
is the number of input signals; for the ICA method, we use PCA to estimate how many components would explain at least 99% of the variance and adopt this value forn
.- max_iterint, default=10000
Maximum number of iterations before timing out on an attempt.
Changed in version 1.0.0: Argument maxiter renamed to max_iter.
- tolfloat, default=1e-4
Tolerance of the stopping condition.
- random_stateint or None, default=892
Initial state for the random number generator. Set to
None
to use thenumpy.random
default. Default seed is892
.- max_triesint, default=10
Maximum number of random initial states to try. Each random state will be optimized for max_iter iterations before timing out.
Changed in version 1.0.0: Argument maxtries renamed to max_tries.
- W0array_like, optional
Optional starting condition for
W
in NMF algorithm. (Ignored when using the ICA method.)- H0array_like, optional
Optional starting condition for
H
in NMF algorithm. (Ignored when using the ICA method.)- alphafloat, default=0.1
Sparsity regularizaton weight for NMF algorithm. Set to zero to remove regularization. Default is
0.1
. (Ignored when using the ICA method.)- verbosityint, default=1
Level of verbosity. The options are:
0
: No outputs.1
: Print separation progress.
- prefixstr, optional
String to include before any progress statements.
- Returns
- S_sep
numpy.ndarray
shaped (signals, observations) The raw separated traces.
- S_matched
numpy.ndarray
shaped (signals, observations) The separated traces matched to the primary signal, in order of matching quality (see Notes below).
- A_sep
numpy.ndarray
shaped (signals, signals) Mixing matrix.
- convergencedict
Metadata for the convergence result, with the following keys and values:
convergence["random_state"]
Seed for estimator initiation.
convergence["iterations"]
Number of iterations needed for convergence.
convergence["max_iterations"]
Maximum number of iterations allowed.
convergence["converged"]
Whether the algorithm converged or not (
bool
).
- S_sep
Notes
To identify which independent signal matches the primary signal best, we first normalize the columns in the output mixing matrix A such that
sum(A[:, separated]) = 1
. This results in a relative score of how strongly each raw signal contributes to each separated signal. From this, we find the separated signal to which the ROI trace makes the largest (relative) contribution.