DeProj is a MATLAB app made to yield accurate morphological measurements on cells in epithelia or tissues.

## What is DeProj useful for?

[TOC]

## What is DeProj useful for.

### Measuring cell morphologies on 2D projections.

...

...

@@ -26,7 +28,7 @@ On this illustration, a cell (in red, top-left quadrant) is located on a region

**DeProj** is a tool made to correct for this distorsion. It takes 1) the results of the segmentation on the projection - the green contour on the bottom-right quadrant above - 2) the height-map that follows the shape of the tissue - the gray smooth line on the top-right quadrant above - and "de-project" the cell back on its original position in the tissue - in red, top-right quadrant. Then it yields corrected morphological measurements.

## How-to use DeProj.

## Howto use DeProj.

DeProj requires two inputs:

...

...

@@ -85,7 +87,7 @@ ans =

id:[]

```

### Example analysis.

### Running the example.

The root folder of the DeProj repository has a [self-contained example](RunExample.m), that you can run with:

...

...

@@ -138,20 +140,208 @@ We can also measure the cell size (area and perimeter) on the XY projection, and

DeProj is mainly made of two classes, and running it from the MATLAB prompt should be convenient enough.

### From a segmentation mask and a height-map.

You need two images as input.

#### The segmentation mask.

It is the results of the segmentation step, and must be a black and white image where each object is white and separated from its neighbor by a black ridge. Importantly the ridge must be connected using 8-connectivity.

For instance, this is good (the ridges can be connected by the pixel diagonals):

The height-map is an image <u>of the exact same size that the segmentation image</u>, and for which the pixel value reports the Z position of the tissue surface. For instance:

On this example the pixel value is an integer that gives the Z-plane from which the projection pixel was taken. Several academic softwares generate this height-map (under varying names) on top of the projection. We list some of them at the end of this documentation.

#### Running the analysis.

For this example, we use the images that are present in the `samples` folder of this repository. They are a small excerpt of a 3D image of a drosophila pupal notum labelled for E-cadherin, and projected with the LocalZProjector (courtesy of Léo Valon, [Romain Levayer lab](https://research.pasteur.fr/en/team/cell-death-and-epithelial-homeostasis/), Institut Pasteur).

We can directly report all the measurements in physical units. To do so we need to specify what is the unit of length, and what is the pixel size in X & Y:

```matlab

pixel_size=0.183;% µm

units='µm';

```

The height-map of this dataset reports the *Z plane* of interest in the original 3D image. But we need to know the position in physical units, so we need to specify the pixel size in Z, or the voxel-depth:

```matlab

voxel_depth=1.;% µm

```

If your height-map already report the Z position and not the Z-plane, simply enter a value of `1` here.

Finally we have some options to deal with tissue orientation and missing tissue. When we have `value = 0` in a region of the height-map, this signals that the projection is not defined at this location, for instance if the tissue is not imaged in these regions. We can then extrapolate the height-map there, and/or remove cells that touch such a region.

```matlab

% If this flag is set to true, the height-map will be extrapolated in regions where its value is 0.

inpaint_zeros=true;

% Remove objects that have a Z position equal to 0. Normally this

% value reports objects that are out of the region-of-interest.

prune_zeros=true;

```

Often inverted microscopes are used to image these tissues. When the sample is arranged on its back, this leads the bottom of the tissue surface to have large Z value (this is the case for the sample data). The following flag is a convenience that flips it for better display.

```matlab

% Invert z for plotting.

invert_z=true;

```

Finally, we can run DeProj. Everything is done with a single call to:

```matlab

dpr=deproj.from_heightmap(...

I,...

H,...

pixel_size,...

voxel_depth,...

units,...

invert_z,...

inpaint_zeros,...

prune_zeros);

```

It can take some time, depending on the size of the images. You should see something like this in the MATLAB console:

```

Opening mask image: Segmentation-2.tif

Opening height-map image: HeightMap-2.tif

Converting mask to objects.

Converted a 282 x 508 mask in 1.2 seconds. Found 426 objects and 1840 junctions.

Typical object scale: 10.1 pixels or 1.84 µm.

Collecting Z coordinates.

Done in 0.1 seconds.

Removed 0 junctions at Z=0.

Removed 0 objects touching these junctions.

Computing tissue local curvature.

Computing morphological descriptors of all objects.

Done in 3.4 seconds.

```

What you get out this process is a `deproj` object:

```matlab

>>dpr

dpr=

deprojwithproperties:

epicells:[426×1epicell]

junction_graph:[1×1graph]

units:'µm'

```

It manages mainly a collection of `epicell` objects, that store the data for one cell:

The method can both be called in a GUI and by the command line of MATLAB

1. To call the method using the GUI:

## Appendix.

start the DeProj_GUI app in MATLAB `>> DeProj_GUI`. The GUI will guide you to provide the proper inputs and outputs to the method as well as the method parameters. The app has been created under MATLAB R2017b version and using an older version may create unexpected behavior.

### Projection tools that yields the height-map.

2. To call the method using the command line: enter `>> surface3D_combine()`

DeProj requires the height-map along with the segmentation of the projection, in order t "deproject" the cells onto the actual tissue surface. Here are some of the open-source projection tool that can return this output:

* In case all arguments are provided, the method will continue with the desired inputs

* In case no arguments are provided, the method will revert to default parameters and only ask the user for inputs and output paths.

-[LocalZProjector](https://gitlab.pasteur.fr/iah-public/localzprojector). DeProj is the component part of the DProj toolbox, and LocalZProjector is the first one. It can generate a hight-map that can directly be used by DeProj.

-[StackFocuser](https://imagej.nih.gov/ij/plugins/stack-focuser.html), an ImageJ plugin.

-[PreMosa](https://academic.oup.com/bioinformatics/article/33/16/2563/3104469), a standalone C++ software.

- The [Extended-Depth-Of-Field](http://bigwww.epfl.ch/demo/edf/) ImageJ plugin.

- The [Min Cost Z Surface](https://imagej.net/Minimum_Cost_Z_surface_Projection) ImageJ plugin.

- The [Smooth Manifold Extraction](https://github.com/biocompibens/SME) MATLAB tool (a Fiji version is also distributed) and its recent, faster implementation: [FastSME](https://github.com/Shihav/FastSME).

## Side note: Segmenting the projection.

### Segmentation tools for the projection.

Several open-source tools can segment the projection and yield the cells contour or the mask displayed above. Some of them offer an intuitive user interface, allowing for immediate usage and user interaction. For instance: