Skip to content

Code for Semi-Automated Segmentation of Microscopic Video Data. Created for Widefield Fluorescent Calcium Imaging data in Mice

License

Notifications You must be signed in to change notification settings

kr-hansen/SemiSeg

Repository files navigation

SemiSeg

Code for Semi-Automated Segmentation of Microscopic Video Data. Created for Widefield Fluorescent Calcium Imaging data formatted as tiff stacks in Mice. Nothing too novel used, as many techniques are used in commercial packages, but I needed something I could get under the hood with and alter things as necessary. I often use this code to generate my "ground-truth" values for segmentation projects, as I get dynamic feedback through the code and have my own personal certainty in the results that are outputted as my ground-truth. Uses built-in matlab functions to navigate the images and select regions of interest (ROIs) thresholded on various processed versions of the images, as described below.

  1. Raw Image - Threshold is determined from Max-Min projection across the video stack. This is the standard image that is shown.
  2. Cross Correlation Image - Threshold is determined from pixel-wise cross correlation across time for zoomed-in image selection, to speed up processing and allow this computation on large/high-resolution video files.
  3. Principal Component Analysis - Threshold is determined independenly for the first 3 principle components of the time traces across the zoomed-in image selection. ROIs are created for all values above a percentile threshold for any of those components and merged into one ROI.

Function Descriptions

  1. loadTifArray_Multifile -- Load tif files into memory with "LoadTifArray_Multifile.m." The input to this file is the number of frames to subsample the images by, meaning it will select every xth frame from the tifs, where x is the value inputted to the function. The output of this function is an imArray that represents the 3D video stack from the tif files.
  2. SemiSeg -- Load an imArray using 1. as input into the SemiSeg function. The first input for SemiSeg is the imArray to select ROIs from, while the second input is a CellList with selected pixel indexes. If there is no CellList yet, an empty vector can be used to start a new CellList. The initial contrast can be adjusted, whereupon the user can zoom to an area of interest, press any key, and select which processed version of the image they would like to segment. After the processed image is ready, the user can click to select a bounding box around an ROI that will be thresholded within to select the ROI. Threshold values can be adjusted until the user is satisfied with the ROI. This can be done iteratively until all ROIs are selected for the image array. An option is also provided to simply select circles around click points. Doesn't have spatial information, but is faster in terms of clicking.
  3. SemiSeg_Remove -- Load a single frame (typically a Max-Min Projection across an imArray volume) to overlay ROIs from a CellList on. The contrast of the image can be adjusted, and the user can zoom into areas of cells they are interested in. Once a button has been pressed after zooming, the user can single click within any ROIs they wish to remove. Pressing Enter causes those ROIs to be removed and the user can adjust the view to select more ROIs.
  4. shiftROIs -- Given two images (im1 and im2) and a CellList that corresponds to the image space of im1, the pixel indexes are shifted to provide an outputted CellList that corresponds to the image space of im2.

About

Code for Semi-Automated Segmentation of Microscopic Video Data. Created for Widefield Fluorescent Calcium Imaging data in Mice

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages