-
Notifications
You must be signed in to change notification settings - Fork 0
Dimensionality reduction
Nabarb edited this page Mar 26, 2026
·
1 revision
NeuralEmbedding exposes a common interface to several dimensionality reduction algorithms through findEmbedding. Each method consumes the preprocessed neural activity stored in the NeuralEmbedding object and returns embedded trajectories along with the projection matrices that produced them.
% D is a struct array, numeric array, or cell array of trials (see constructor for formats)
NE = NeuralEmbedding(D, ...
"fs", 1000, ... % sampling frequency in Hz
"time", tvec, ... % optional trial time vector
"area", areaLabels, ... % optional area labels per unit
"condition", condLabels); % optional condition label per trial
% Choose an embedding
[E, W, VarExplained] = NE.findEmbedding("PCA"); % returns embedded data, projection, variance explainedfindEmbedding(type, projectOnly) accepts the method name (case-insensitive) and an optional projectOnly flag to bypass model fitting when a projection already exists.
-
Call:
NE.findEmbedding("PCA"); - Purpose: Orthogonal linear projection capturing maximal variance.
-
Parameters:
NumPCproperty (automatically capped at 30 and the available units in the selected area mask); inherits smoothing/z-scoring from preprocessing. -
Inputs: Smoothed data
obj.S(cells ofnDims × Tmatrices per trial). -
Outputs: Embedded trajectories
E, projection matricesW, variance explained per componentVarExplained.
-
Call:
NE.findEmbedding("GPFA"); - Purpose: Captures smooth latent trajectories with temporal structure.
-
Parameters:
NumPC(set on the object),TrialL(trial length in bins),subsampling(inherited from preprocessing). -
Inputs: Preprocessed binned data
obj.P. -
Outputs:
E,W, andVarExplained; inverse projection is computed automatically.
-
Call:
NE.findEmbedding("CCA"); - Purpose: Finds correlated projections across multiple recorded areas.
-
Parameters:
NumPC,nArea,nTrial,TrialL. -
Inputs: Cell array
Dcontaining smoothed activity per area (obj.Sis assembled internally). -
Outputs:
E, area-specific projection matricesW, and canonical correlations.
-
Call:
NE.findEmbedding("MCCA"); -
Purpose: Aligns multiple
NeuralEmbeddingobjects (e.g., multiple sessions) into a shared latent space. -
Parameters:
mcca_k(regularization, default0.9),nTrial,TrialL. - Notes: If invoked on a single object, it falls back to the CCA workflow.
- Outputs: Shared embeddings and projections applied back to each object in the array.
-
Call:
NE.findEmbedding("identity"); - Purpose: Bypasses dimensionality reduction; returns smoothed data with an identity projection.
- Outputs: Embedded data identical to the smoothed input, identity projection matrix, and explained variance of the original space.
- UMAP / t-SNE: Stubs exist, but calls currently print “support is WIP. Stay tuned!” and return without computation.
- The constructor automatically performs preprocessing (
removeInactiveNeurons,binData,smoothData,zscoreData) using the parameters passed inopts(e.g.,binwidth,prekern,useGpu). If you change these properties after construction, rerunperformPreProbefore callingfindEmbeddingto refresh the processed data. - Use
projectOnly=truewhen projecting new trials with an existingWmatrix. - Access masks (
aMask,cMask,tMask) to limit areas, conditions, or time bins before running an embedding.