Giter Club home page Giter Club logo

capillary-tracking's Introduction

Cell tracking and analysis protocol v2.0

Software required

Fiji/ImageJ 2.0.0 Matlab

Change RAM allocation in Fiji from Edit/Options/Memory&Threads (>10GB ideally).

File naming Scheme

“strain_position_media_replicate_video_experiment-.avi”

Where position is bottom, middle or top (section of capillary imaged), replicate is biological replicate and video is technical replicate

ImageJ script 1 (batch): imagej_stage_1.ijm

Select a folder and run below on all files in it. Runs steps 1-6 with the standard settings (steps 2 and 6 are skipped where unnecessary). Step 6 is run (and Step 2 skipped) when filename ends in ‘_F’. Set ROIs manually using position of non-swimming particle in same plane as swimmers. Select all points and save these in subfolder ROI within video folder (RoiSet_[filename].zip).

1. Fiji/ImageJ importing (.avi -> .tif)

File/Open – convert to grayscale

File/Save as/Tiff…

Image/Adjust/“Brightness/Contrast” – adjust to better visualise cells

2. Normalization

Plugin/Integral Image Filters/Normalise local contrast

  • Block radius x: 15
  • Block radius y: 15
  • SD: 15 (check with preview)
  • Centre: Yes
  • Stretch: Yes

3. Subtract background

Process/Subtract background

  • Radius (cell size ~10px, test with higher (20) to start with and check with preview)
  • Light background: Yes
  • Disable smoothing: Yes

4. Invert Image

Edit/Invert (software is designed for dark background)

5. Adjust for flow (run only if flow detected)

Analyse/Tools/ROI Manager Find non-swimming particle that follows flow and is visible for the whole video. Mark position with “Point Tool” in first frame, last frame and 1-3 extra frames throughout the video. The more positions marked, the more accurate the adjustment but the longer it will take.

Plugin/Multi DriftCorrection (run with ROI Manager window open with points loaded)

Final tweaks (manual)

Can be skipped if the images seem clear. Alter brightness/contrast (as above) to the point where cells are clearly visible with little noise.

Process/Noise/Remove outliers (can help with non-surface videos)

  • Radius: 0-2
  • Threshold: 0
  • Which outliers: Bright

If batch analysing data, save again.

TrackMate (basic)

Monitor memory with Plugins/Utilities/Monitor Memory…

Garbage collect with Plugins/Utilities/Collect Garbage – in lower Utilities menu (close completely when this doesn’t work due to memory leak)

Image/Properties (check image properties match)

  • Channels (c): 1
  • Slices (z): 1
  • Frames (x): ~600
  • Pixel width: 0.21 microns
  • Pixel height: 0.21 microns
  • Voxel depth: 1
  • Frame interval: 0.10 sec

Plugin/Tracking/TrackMate

  • Check properties match above

Detector: LoG detector

  • Blob: 2 microns
  • Threshold: 1 (test with different values, want to include as many positives as possible)
  • Median filter: No
  • Subpixel localization: Yes

No initial thresholding. The Quality metric tends to be less useful since it is designed for circular spots.

Viewer: Hyperstack displayer (check cells). Set cropping if adjusting for flow (go to last frame and remove the black column). Check both Quality and Standard deviation for clear bimodal distribution and select the higher group from the one which is clearest.

Tracker: Linear motion LAP tracker

  • Max search radius: 10 (maximum movement distance per frame, 100um/s)
  • Initial search radius: 10 (as above for initiating new track)
  • Gap closing frame: 1 (cell can undetected for 1 frame and still be on the same track)

Filter tracks to remove artefacts. Try to keep immobile bacteria for swimming fraction calculations.

  • Spots in track: >10 (remove tracks shorter than 1 second)
  • Mean quality: >1.5 (remove spurious tracks from out of focus cells usually at the edges; and/or use X/Y location)

Save log with default name. Skip to ImageJ script 2.

TrackMate Part 1 (if removing non-motile particles)

Monitor memory with Plugins/Utilities/Monitor Memory…

Garbage collect with Plugins/Utilities/Collect Garbage – in lower Utilities menu (close completely when this doesn’t work due to memory leak)

Image/Properties (check image properties match)

  • Channels (c): 1
  • Slices (z): 1
  • Frames (x): ~600
  • Pixel width: 0.21 microns
  • Pixel height: 0.21 microns
  • Voxel depth: 1
  • Frame interval: 0.10 sec

Plugin/Tracking/TrackMate

  • Check properties match above

Detector: LoG detector

  • Blob: 2 microns
  • Threshold: 1 (test with different values, want to include as many positives as possible)
  • Median filter: No
  • Subpixel localization: Yes

No initial thresholding. The Quality metric tends to be less useful since it is designed for circular spots.

Viewer: Hyperstack displayer (check cells) Set cropping if adjusting for flow (go to last frame and remove the black column). Check both Quality and Standard deviation for clear bimodal distribution and select the higher group from the one which is clearest.

Hit next before saving to ensure the filtering is saved. Save spots to file. Suffix: -initial_spots.xml.

Tracker: Simple LAP tracker

  • No initial thresholding.
  • Linking max distance: 2.0 (maximum movement distance per frame, set low to track non-motile cells)
  • Gap-closing max distance: 2.0 (as above for gap-closing)
  • Gap-closing max frame gap: 10 (maximum frames cell can be untracked)

Filter tracks to remove motile spots.

  • Duration of track: >1 seconds
  • Can remove obvious swimming tracks with track displacement

Hit next before saving to ensure the filtering is saved. Save tracks to file. Suffix: -nonmotile_tracks.xml.

Python Script 1 (batch): remove_tracked_spots.py

Removes spots found in *-nonmotile_tracks.xml from *-initial_spots.xml, producing *-motile_spots.xml. Effectively, this removes the nonmotile spots from interfering with motile tracks.

TrackMate Part 2 (if removing non-motile particles)

Plugins/Tracking/Load a trackmate file Load generated files. Suffix: -motile_spots.xml.

Tracker: Linear motion LAP tracker

  • Max search radius: 10 (maximum movement distance per frame, 100um/s)
  • Initial search radius: 10 (as above for initiating new track)
  • Gap closing frame: 1 (cell can be undetected for 1 frame and still be on the same track)

Filter tracks to remove artefacts. Try to keep immobile bacteria for swimming fraction calculations.

  • Spots in track: >10 (remove tracks shorter than 1 second)
  • Mean quality: >2 (remove spurious tracks from out of focus cells usually at the edges; and/or use X/Y location)
  • Track displacement: >2 (remove non-motile tracks that were not caught by Part 1)

Hit next before saving to ensure the filtering is saved. Save tracks to file. Suffix: -motile_tracks.xml.

ImageJ script 2 (batch): imagej_stage_2.py

Generates spreadsheets of trajectory data for Matlab scripts from manually run TrackMate. If spot morphology was not tracked, semiaxislengths and phi are set to 0.

Edit:

  • directory = base directory for paths
  • inpath = path to ‘.xml’ files
  • outpath = path to place output ‘.csv’ files

Matlab script 1 (batch): loadtrackmate_orientation.m

Run in Matlab. Loads data from ‘[filename].csv’ to form data structure. Runs ‘loadtrackmate_orientation_function.m’ on all the ‘.csv’ files in a directory.

Edit:

  • minnumbspots = 10 (threshold for minimum number of points in a track, 1s at 10fps)

Output:

  • ‘[filename].mat’ (data structure)

Matlab script 2 (batch): rhizobia_general_analysis.m

Run in Matlab. Updates data structure from above with tumble and mean squared displacement analysis.

Edit:

  • Frametime = 0.1 (fps of images)
  • thresholds.tumble = deg2rad(2500) (tumble radians/s cutoff in dtheta/dt vs t plot)
  • thresholds.angle_bounds = 0.02 (time before and after reorientation event to find total angle)
  • coverage = 1000 (Number of spline smoothing points for each real point)

Output:

  • ‘[filename]_analysed.mat’ (saved analysis with updated data structure)

R script 1: matlab_to_csv-with_analysis.R

Run in R. Converts matlab '*_analysed.mat' files to '*.csv'.

Edit (wrangling section):

  • chosen_folders: vector of file.paths containing '*_analysed.mat' files
  • output_file: name of compiled csv file

Output files

Used in R script

  • ts: time coordinates (seconds)
  • x: x-coordinates (microns)
  • y: y-coordinates (microns)
  • extract_velo: velocity from spline at track times
  • locs: time coordinates of peaks
  • spline_angle: angle at peak points
  • msd: mean squared displacement (mean, sd, n, intercept, slope). Linear model fit statistics, linear indicates Brownian motion, non-linear increasing directed motion, non-linear decreasing constrained with the intercept estimating measurement error.

Extra values

  • t: frame coordinates
  • minorleng: ellipsoid fit semi-axis length c
  • majorleng: ellipsoid fit semi-axis length b
  • phi: movement direction of cell
  • meanintens: average intensity
  • duration: duration of track (seconds)
  • scale_points: boundaries for spline values
  • splinex_gof: goodness of fit for x spline (sse, rsquare, dfe, adjrsquare, rmse)
  • splinex_fit: fit data for x spline (numobs, numparam, residuals, Jacobian, exitflag, p)
  • spliney_gof: goodness of fit for y spline (sse, rsquare, dfe, adjrsquare, rmse)
  • spliney_fit: fit data for y spline (numobs, numparam, residuals, Jacobian, exitflag, p)
  • peaks: value of peaks detected in spline_head

Removed due to space constraints

  • spline_ts: time coordinates used for spline (seconds)
  • splinex: x-coordinates for spline (microns)
  • spliney: y-coordinates for spline (microns)
  • spline_velo: velocity across spline
  • spline_acc: acceleration across spline
  • spline_head: angle heading from spline
  • spline_dhead: change in spline.head

capillary-tracking's People

Contributors

aroneys avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.