Repository navigation
Dimensionality Reduction (v1.0.6b)
version release date:30/04/25
This plugin captures data from an open image stack, folder of images, or an open results table and performs one of three dimensionality reduction techniques (PCA, t-SNE, or UMAP) to project the high-dimensional data into a lower dimensional (2D) space that is then plotted onto an ImageJ scatter-plot. Under-the-hood, the plugin uses two really-awesome libraries (t-SNE: Leif Jonsson's pure Java implementation of Van Der Maaten and Hinton's t-sne clustering algorithm; and UMAP: Jesse Paquette's (of tag.bio) Java implementation of UMAP, based on the reference Python implementation). Both are distributed under open-source licences, so even if this plugin doesn't suit you, perhaps their libraries can find a place in your respective projects!
The PCA implementation is from Peter Abeles' (lessthanoptimal) efficient java matrix library. This ImageJ version allows specified principal component axes (e.g. PC-1 vs PC-5) to be plotted and displayed. A specified eigenvector (eigenface) can optionally be reconstructed into an image (NOTE: this option is currently displaying incorrect pixel ranges even if the eigenvectors are true).
From v1.0.3, an interactive scatter plot is output, in addition to the normal ImageJ plot, that allows easy view-toggling of data-clusters and the individual selection of graph points. Clicking on plot points will highlight the corresponding image in an image stack, which is nice for interrogating cluster members and outliers.
v1.0.4 has added a lasso tool to the interactive plot for counting of multiple points within a selection area. In the future, this may be used for sub-level data analysis or labelling.
An open results table to process can be named anything (it does not need to be the default 'Results' table), but must only contain numeric data. A label may be used to colour datapoints in the final DR plot, but must be selected separate from the table to process.
v1.0.5 added more PCA options, as below.
v1.0.6 added an Fx_Scatter constructor class to allow duplicate JavaFx scatter plot code to be migrated out of the dimensionality reduction classes (backend change that allows for more generic use of the Fx plot code).
v1.0.6b added plot point re-colouring options. Plot points can be re-coloured by any user specified principal component (irrespective of which dimensionality reduction method was originally applied) or by an input data variable (e.g. coloured by one of the input data columns or one of the pixel positions across an image stack).
PCA specific options
Specify the number of principal components to use. 2 is specified in this example (PC1 + PC2), but it is also the default:
run("PCA", "pca_comp=2");Specify which principal component axes to display on the 'PCA output' scatterplot. Principal component 5 and 6 will be displayed using this example:
(Note: pca_comp will automatically increase to facilitate the request)
run("PCA", "pc_x=5 pc_y=6");Specify eigenvectors (eigenfaces) to recompose and display as an image(stack):
(Note: this seems to work well for 8-bit and 16-bit images, but mapping to other output image bitdepths needs more work.)
// Display the first eigenvector, corresponding to principal component 1.
run("PCA", "eigen_out=1");
// Dispay a range of eigenvectors, using commas and/or hyphens
run("PCA", "pca_comp=50 eigen_out=1,2,3,5-25,27,30");For example, specifying the output of the first 12 eigenvectors from a stack like this:

Results in:

Requesting a mean image be output:
run("PCA", "mean_out");Example setting multiple parameters:
run("PCA", "pca_comp=10 pc_x=1 pc_y=5 eigen_out=1-10 mean_out label_path=[C:/Users/Antinos/Documents/My_label_file.csv]");Installation and comments
Download the plugin here or from my googledrive. I have also included some test image-stacks and accompanying label.csv files to play with in the googledrive.
To install the plugin:
- copy 'Dimensionality_Reduction-1.0.6.jar' to your Fiji plugins folder.
- copy 'javafx.base.jar', 'javafx.swing.jar', javafx.graphics.jar', and 'javafx.controls.jar' to your Fiji jars folder. (required from v1.0.3.)