zacswider / volume-distribution

A semi-automated pipeline for filtering 3D segmentations, and measuring the relative orientation of cells and spindles in 3D space.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Volume Distribution

This repository contains a collection of packages and pipelines for viewing and automating the volumetric segmentations of X. laevis embryos. For this project I was specifically interested in quantifying the spatial location and orientation of the mitotic spindle with respect to the cell volume and orientation. This readme describes some of the methods that I used to a) segment 3D cell volumes, b) filter poor quality segmentations, and c) measure the spatial properties of the cell and spindle.

Upstream processing

The images from this project were acquired at low resolution on an Olympus Fv1000 confocal, denoised using Noise2Void, and segmented in three dimensions using a custom Cellpose model trained with ground-truth annotations of XY, XZ, and YZ slices from 3D datasets.

The image below shows a raw XY slice on the left with human annotated cells on the right:

The image below shows a 3D projection of PI and anti-tubulin staining on the left and the cellpose-calculated cell labels on the right:

Quality control

3D segmentation is challenging, especial for data like these where the Z resolution is ~15x lower than the XY resolution. Given this limitation, segmentations can be imperfect and should be checked for accuracy. However, manual correction is low-throughput and inappropriate for large datasets (imagine hundreds or thousands of stacks). To safeguard against inappropriate segmentations we can implement low effort filters like minimum and maximum segmentation sizes that encompass the expected distribution of our cells. But what about labels that are within the right size range (such as the one below) but completely inaccurate?

This image below shows a mask that passes the size filters, but is complete garbage

To eliminate appropriately sized but inappropriately shaped labels we can take a slightly slower but more sophisticated filtering approach. Here I train a random forest classifier to discriminate between good and bad segmentations. The classifier learns uses the 3 dimensional properties (size, shape, density, etc) of labels with known classes (good or bad) to decide whether new labels are either good or bad. Generating training data for a random classifier is made easy with open source tools like napari, a multi-dimensional image viewer that can be paired with 3D measurement tools like scikit-image and machine learning libraries like scikit-learn.

In the example below I use napari to to quickly scrub through cell segmentations which can be classified as "good" or "bad" with a key press. Once the class has been specified, the spatial properties of the label (e.g., long/short axis length and label density/solidity) are measured and used to train the classifier.

After filtering, we are left with only cell shapes that match the data we used to train the classifier . Since I'm only interested in these relatively small epithelial cells, I trained the classifier against everything else.

The example below shows filtered labeled on the right, and the corresponding masked immunofluorescence on the left

Isolating spindles

In principle, we could also train a segmentation model to specifically threshold spindle shapes, but in this case classic thresholding worked well. In order to avoid applying a blanket threshold value to the entire image, where bright and dim cells would be segmented unequally, we isolate individual cell masks, run a 3D tophat filter to increase contast, and calculate cell-specific threshold values.

The example below shows raw anti-tubulin immunofluorescence and the correponding thresholded regions.

Similar to our approach to cell segmentations, we end up with a mix of accurate and inaccurate segmentations. Once again, we can filter the non-specific regions with a random forest classifier trained to recognize spindle shapes.

Below left: all labels following thresholding and connected component labeling. Below right: all labels after filtering with a random forest classifier trained to recognize spindle shapes.

In aggregate, this approach produces high quality segmentations from the majority of cells in a given embryo:

Example of cell and spindle thresholding

Measuring cell properties

Given isolated masks, we can easily measure 3D label properties with built-in python libraries like scikit-image. In this case I am more interested in measuring the relationships between shapes, such as distance and relative alignment.

Here we measure the distance between the spindle and the center of the cell, as well as the degree of alignment between the long axis of the spindle and the long axis of the cell.

Proof of principle: automated analysis of 350 cells from 15 different embryos reveals that mitotic spindles follow Hertwig's Rule and align perpendicular to the short axis of the cell. Deviations from this rule tend to be found in cells with a small aspect ratio (i.e., more spherical cells), where pressure to align is not as strong.

On average, mitotic spindles in the X. laevis epithelium tend to align perpendicular to the short axis of the cell. This trend is strongest when cell shape deviates from spherical.

We can make similar measurements of tissue-level organization by measuring the alignment of cell volumes relative to the geometric center of the embryo:

Cells tend to align with their long axis along the plane of the epithelium (perpendicular to a vector towards the center of the embryo), however, this morphology can be disturbed under certain conditions:

About

A semi-automated pipeline for filtering 3D segmentations, and measuring the relative orientation of cells and spindles in 3D space.


Languages

Language:Jupyter Notebook 77.3%Language:Python 21.0%Language:ImageJ Macro 1.7%