1. Functions for analysis

Note

The following functions are used to analyze movies in Figure 1, 3, 4, 5, and in Suplementary Figures 1, 2, 3.

analysis.BreakDownTraj(in, b)

BreakDownTraj takes in trajectories and break them down to shorter fragments.

Parameters
  • in – trajectories in simple format

  • b – length of the short fragment

Output:

out: trajectories with length b.

Note: for each trajectory, if the tail is longer than 5 frames, then keep the tail.

analysis.Kilfoil_to_simple_traj(in)

Kilfoil_to_simple_traj: Transform the output of Kilfoil particle tracking into the format produced by uTrackToSimpleTraj.m

Parameters

in – output data in array format used by Kilfoil

Output:

out: a list of particle tracks in the format output by the function uTrackToSimpleTraj:

‘first’ = the first movie frame in which this track appears

‘last’ = the last movie frame in which this track appears.

‘lifetime’ = the length of the track in frames.

‘x’ = an array containing the sequence of x positions.

‘y’ = an array containing the sequence of y positions.

‘I’ = an array containing the intensity values.

analysis.Kilfoil_to_uTrack_particles(particles, firstFrame, nFrames)

Kilfoil_to_uTrack_particles Transforms a set of particle data produced by Kilfoil preTrack into format for tracking by uTrack. Extracts a subset of data defined by firstfarme and nrames.

Parameters
  • particles – An array of particles in Kilfoil format

  • firstFrame – First frame to extract

  • nFrames – Total number of frames to extrract.

Output:

out: An array of structures f length nFrames, where each structyure defines a list of particles with the following fields:

xCoord: An array of x coordinates, one for each particle

yCoord: An array of y coordinates, one for each particle

amp: An array of intensities, one for each particle

analysis.Rotation(tracks, center, angle)

Rotation rotates the x,y coordinates of trajectories around the center of the movie. :param tracks: tracks in Kilfoil format :param center: center of the movie in [x;y] format :param angle: rotation angle

Output:

out: the same set of trajectories with new x,y coordinates.

analysis.TrajDirection2(trks)

TrajDirection2 calculate the direction of each trajectory. The way it measures the direction is to calculate the atan angle between the first and the last point.

Parameters

trks – trajectories in simple format.

Output:

out: trajectories in simple format with direction field.

analysis.addAsymmetry(trks)

addAsymmetry adds asymmetry values to each trajectory. The asymmetry value is calculated as S=-ln(1-((v1-v2)^2)/(v1+v2)^2)), where v1 and v2 are the eigenvalues v1 and v2 of the variance-covariance matrix of the trajectory positions over time.

Parameters

trks – tracks that’s in the simple format

Output:

out: trajecoties in simple format with Asymmetry field.

analysis.addSpeed(trk, b)

addSpeed adds the instant speed of each trajectory at each given point. First it will take a trajectory, and using a moving average b to smooth the x and y position. After smoothing, it will calculate the distance between (xt,yt) and (x(t-1), y(t-1)), and record that as the instant speed at that given moment t.

Parameters
  • trk – should be simple format;

  • b – the span to smooth the data;

Output:

out: the simple format trajectory database, with one extra structure, speed, which record the speed of each trajectory at every time point.

analysis.filterByLifetime(tracks, min_max_track_L)

filterByLifetime returns the subset of particle tracks whose lengths lie within the range defined by max_min_track_L.

Parameters
  • tracks

    An array of particle trajectory structures in format produced by uTrackToSimpleTraj:

    ’first’ = the first movie frame in which this track appears

    ’last’ = the last movie frame in which this track appears.

    ’lifetime’ = the length of the track in frames.

    ’x’ = an array containing the sequence of x positions.

    ’y’ = an array containing the sequence of y positions.

    ’I’ = an array containing the intensity values.

  • min_max_track_L – [min max]

Output:

subTracks: subset of tracks statisfying min < track length < max

analysis.interpolateGaps(in)

Given an array of trajectories in simple fomrat, interpolateGaps finds gaps in each trajectory represented by NaN and fills x, y and I values by linear interpolation.

Parameters

in

array of trajectories in simple format: ‘first’ = the first movie frame in which this track appears

’last’ = the last movie frame in which this track appears.

’lifetime’ = the length of the track in frames.

’x’ = an array containing the sequence of x positions.

’y’ = an array containing the sequence of y positions.

’I’ = an array containing the intensity values.

Output:

out: same array with interpolated values

analysis.measureManyAlignment(in, ROI, center, angle, threshold)

measureManyAlignment takes in a raw movie, and measure alignment degree of filament orientation for each frame.

Parameters
  • in – raw movie

  • ROI – region of interest in [xmin,xmax,ymin,ymax] format

  • center – center of the movie, for rotation. See Rotation.mat for more infomation

  • angle – for Rotation. See Rotation.mat for more information

  • threshold – minimum pixel intensity to be considered as signal

Output:

out: The direction distribution of pixels in ROI from -pi/2 to pi/2 in 45 bins

analysis.measureOneAlignment(ip, center, angle, threshold)

this function uses two 3X3 kernel masks to calculate the direction of each pixel. Notice that the final product takes into consideration of both the sharpness of the boundary and the intensity of the pixel at that location.

Parameters
  • ip – the original movie frame

  • center – the center of that frame used to rotate the image. See

  • infomation. (Rotation.mat for more) –

  • angle – Angle for rotation. see function Rotation.mat for more

  • infomation.

  • threshold – minimum intensity of each pixel to be considered

output:

out: the orientation of each pixel in the following format:

1st column: x position

2nd column: y position

3nd column: intensity

4th column: angle

5th column: norm (used to plot angle distribution)

analysis.plotTraj(trks)

PlotTraj plots all the trajectories onto a same graph.

Parameters

trks – trajecotories in simple format

Output:

plots of all trajectories on a same graph

analysis.showParticles(stk, trks)

ShowParticles generates TIFF images that have tracking results overlayed on top of the raw image.

Parameters
  • stk – stacks of raw movie.

  • trks – trajectories in simple format.

Output:

TIFF images that have tracking results overlayed on top of the raw image.

analysis.simple_to_Kilfoil_traj(trks)

simple_to_Kilfoil_traj: Transform the output of uTrack_to_simple_traj into the format produced by Kilfoil

Parameters

trks

a list of particle tracks which is assumed to be in the format output by the function uTrackToSimpleTraj:

’first’ = the first movie frame in which this track appears

’last’ = the last movie frame in which this track appears.

’lifetime’ = the length of the track in frames.

’x’ = an array containing the sequence of x positions.

’y’ = an array containing the sequence of y positions.

’I’ = an array containing the intensity values.

Output:

out: output data in array format used by Kilfoil with columns: Xpos, Ypos, Int, frame#, trackID, xDis/yDis/d/SI/speed

analysis.uTrack_to_simple_traj(tracks)

uTrack_to_simple_Traj transforms track data from the tracksFinal format into a form that is suitable for further analysis.

Parameters

tracks – the tracksFinal structure output by ScriptTrackGeneral.

Output:

out: an array of structures, one for each track, whose fields are defined as follows:

‘first’ = the first movie frame in which this track appears

‘last’ = the last movie frame in which this track appears.

‘lifetime’ = the length of the track in frames.

‘x’ = an array containing the sequence of x positions.

‘y’ = an array containing the sequence of y positions.

‘I’ = an array containing the intensity values.