AI-based nucleus segmentation and tracking tool with downstream analysis of D2min
This tool was developed and modified to measure and analysis the collective migration of two-dimensional cell sheets that are imaged over time using phase contrast microscopy. The whole workflow has three main components:
- U-Net nucleus segmentation (trained_model folder)
- Nucleus tracking (UNetCrocker_Tracker_v2.m)
- Analyze nucleus motion compared to their close neighbors (their neighbors are founding using and calculate how willing they are to follow their neighbors’ motion (D2min).
The current version of the code was adapted for analysis of the data in:
Shuyao Gu, Rachel M. Lee, Zackery Benson, Chenyi Ling, Michele I. Vitolo, Stuart S. Martin, Joe Chalfoun, Wolfgang Losert, "Label-free Cell Tracking Enables Collective Motion Phenotyping in Epithelial Monolayers"
https://doi.org/10.1101/2021.12.14.472148
All scripted were tested in MATLAB 2020a with the Image Processing Toolbox, Deep Learning Toolbox, and Computer Vision Toolbox.
The trained_model
folder contains the trained network in MATLAB ((UNet_single_cell_seg_norm_256_weights_1_3_Workspace.mat
) to segment the nucleus of single stem cells in phase contrast, as well as the scripts in MATLAB to run the inferencing code (Inferencing_2D_with_overlap.m
). This is the raw output from the neural network, one still need to launch some morphological cleaning on the output and some object separation methods (like FogBank or Watershed in Fiji) to get the final result. Here we included the Fiji macro Watershed_macro.ijm
that has been used to segment objects.
This code should work without GPU support, but it will be much faster if you have a GPU on your machine (strongly recommend).
User Inputs
read_imDir
: path to the raw images to segmentread_img_common_name
: common name of the imagesread_file_ext
: extension of the name of the imagessave_pxDir
: path to save the segmented masks
This code uses track.m
function to track the motion of individual nucleus over time. Segmented binary mask from the previous step is needed as input, and this code extract the centroid of each region of interest and performs tracking. The output tracks are stored in variable tr
.
User Inputs
number_Frames
: number of frames in the input image sequencepathname
: path to the segmented binary mask to perform trackingsavefolder
: path to save tracksfile_short
: common name of the imagesbwareaopen_size
: any region of interested smaller than this size is removed as noise, this value should be smaller than the average nucleus size of your cellsxmin
,xmax
: min and max of pixels in the x direction of the input imagesymin
,ymax
: min and max of pixels in the y direction of the input images
Finds the nearest n neighbors of each cell nuclei.
User Inputs
r
: how many nearest neighbors to useloadname
: name of the tracks to loadrootdir
: path to trackspathname
: path to save neighbors
Uses output from find_n_neighbors2D.m
to calculate the D2min for each nucleus at each time t
User Inputs
findneighborname
: name of the neighbors to inputfindneighbordir
: path to the neighbors to inputsavedfilename
: name of the D2min file to savesave_path
: path to save D2min filetotal_frame
: number of frames to calculate D2min