Skip to main content

Table 1 Pseudocode for SLS trajectories optimization and generation

From: SmaRT2P: a software for generating and processing smart line recording trajectories for population two-photon calcium imaging

Input: random path through all ROIs (path0), labels indicating which ROI corresponds to each path0 pixel (tags)

Step 1. Find unique ROIs

For ROI in unique(tags):

    Find ROI centroid

Step 2. Find optimal path through ROIs centroids (pathTSP) applying genetic algorithm to solve TSP

Randomly initialize a population of 100 individuals (random paths through all ROIs)

Find minimum path length minglob and the individual than minimize path length (pathTSP)

For generation in [1:1000]:

    Compute the path length for each individual

    If exist a path shorter then minglob, then update minglob and pathTSP

    Randomly split population in groups of 4 individuals

    For each group of 4 individuals:

        Find the individual with shortest path

        Create 4 mutations (original, flip, swap, slide) of the individual for the next generation

Step 3. Compute pathSLS

Initialize empty trajectory pathSLS

For ROI in pathTSP:

    Find path through all ROI’s pixels (pathROI) using a greedy algorithm

    Append pathROI to pathTSP

Return: pathTSP