Algorithms

Here you will find some Excel VBA codes and Fiji macros.

Trajectories analysis – SkyPad:

SkyPad is an excel add-on that can analyze multiple particles tracks at once using the coordinates (in 2D or 3D) and retrieves several parameters, such as speed, number of pauses, duration of pauses, persistance, percentage of time in motion…). It gives both the analysis of each particle and a compilation of all of them with the standard deviation.      Untitled-3-01
                 Input window, compilation result table and overlay of particles tracks
 
The distance threshold represents the minimal distance you consider to be a real displacement, and the speed threshold is the minimal speed you consider your particle in movement.
You just have to download the file, and add it to excel using the Excel Add-ins button in the developer tab of Excel. Then, to launch it, just press Ctrl+shift+S.
 
Last version:
                       SkyPad2.1: For Windows (Make an overlay of the tracks, all starting from 0)
                       Help file.
 

Older versions:

               SkyPad2: For Windows (accept tracks with different number of frames)

SkyPad for MacOS : SkyPadMacOS

SkyPad for Windows : SkyPadWindows, to see the code.

How to install and use: Cadot et al, PlosOne 2014
 
 
Folders tools:
 
List folders and subfolders in a folder (code)
 
Excel tools:
 
Label point in a scatter plot: here
Do a polar chart in Excel: here and download the excel file.
 
WEKA analysis on multiple large images
 
After having saved a WEKA classifier, this macro (beanshell language) will divide your images in a chosen number of tiles and run the analysis using your classifier. Found at : https://imagej.net/Scripting_the_Trainable_Weka_Segmentation
 
// @File(label="Input directory", description="Select the directory with input images", style="directory") inputDir
// @File(label="Output directory", description="Select the output directory", style="directory") outputDir
// @File(label="Weka model", description="Select the Weka model to apply") modelPath
// @String(label="Result mode",choices={"Labels","Probabilities"}) resultMode
// @Integer(label="Number of tiles in X:", description="Number of image subdivisions in the X direction", value=3) xTiles
// @Integer(label="Number of tiles in Y:", description="Number of image subdivisions in the Y direction", value=3) yTiles
// @Integer(label="Number of tiles in Z (set to 0 for 2D processing):", description="Number of image subdivisions in the Z direction (ignored when using 2D images)", value=3) zTiles
  
import trainableSegmentation.WekaSegmentation;
import trainableSegmentation.utils.Utils;
import ij.io.FileSaver;
import ij.IJ;
import ij.ImagePlus;
   
// starting time
startTime = System.currentTimeMillis();
   
// caculate probabilities?
getProbs = resultMode.equals( "Probabilities" );
  
// create segmentator
segmentator = new WekaSegmentation( zTiles > 0 );
// load classifier
segmentator.loadClassifier( modelPath.getCanonicalPath() );
   
// get list of input images
listOfFiles = inputDir.listFiles();
for ( i = 0; i < listOfFiles.length; i++ )
{
    // process only files (do not go into sub-folders)
    if( listOfFiles[ i ].isFile() )
    {
        // try to read file as image
        image = IJ.openImage( listOfFiles[i].getCanonicalPath() );
        if( image != null )
        {
            tilesPerDim = new int[ 2 ];
            if( image.getNSlices() > 1 )
            {
                tilesPerDim = new int[ 3 ];
                tilesPerDim[ 2 ] = zTiles;
            }
            tilesPerDim[ 0 ] = xTiles;
            tilesPerDim[ 1 ] = yTiles;
             
            // apply classifier and get results (0 indicates number of threads is auto-detected)
            result = segmentator.applyClassifier( image, tilesPerDim, 0, getProbs );
 
            if( !getProbs )
                // assign same LUT as in GUI
                result.setLut( Utils.getGoldenAngleLUT() );
              
            // save result as TIFF in output folder
            outputFileName = listOfFiles[ i ].getName().replaceFirst("[.][^.]+$", "") + ".tif";
            new FileSaver( result ).saveAsTiff( outputDir.getPath() + File.separator + outputFileName );
   
            // force garbage collection (important for large images)
            result = null;
            image = null;
            System.gc();
        }
    }
}
// print elapsed time
estimatedTime = System.currentTimeMillis() - startTime;
IJ.log( "** Finished processing folder in " + estimatedTime + " ms **" );
System.gc();