Skip to content

Commit

Permalink
Small doc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennings Zhang authored and Jennings Zhang committed Feb 17, 2023
1 parent d2413cb commit d7e405f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Fetal CP Surface Extraction

[![Version](https://img.shields.io/docker/v/fnndsc/pl-fetal-cp-surface-extract?sort=semver)](https://hub.docker.com/r/fnndsc/pl-fetal-cp-surface-extract)
[![MIT License](https://img.shields.io/github/license/fnndsc/pl-fetal-cp-surface-extract)](https://github.com/FNNDSC/pl-fetal-cp-surface-extract/blob/main/LICENSE)
[![ci](https://github.com/FNNDSC/pl-fetal-cp-surface-extract/actions/workflows/ci.yml/badge.svg)](https://github.com/FNNDSC/pl-fetal-cp-surface-extract/actions/workflows/ci.yml)
[![Version](https://img.shields.io/docker/v/fnndsc/pl-fetal-surface-extract?sort=semver)](https://hub.docker.com/r/fnndsc/pl-fetal-surface-extract)
[![MIT License](https://img.shields.io/github/license/fnndsc/pl-fetal-surface-extract)](https://github.com/FNNDSC/pl-fetal-surface-extract/blob/main/LICENSE)
[![ci](https://github.com/FNNDSC/pl-fetal-surface-extract/actions/workflows/ci.yml/badge.svg)](https://github.com/FNNDSC/pl-fetal-surface-extract/actions/workflows/ci.yml)

Fetal brain cortical plate surface extraction using CIVET marching-cubes (`sphere_mesh`).

![Figure](docs/fig.png)

## Abstract

`pl-fetal-cp-surface-extract` consumes binary volumetric `.mnc` brain masks to produce
`pl-fetal-surface-extract` consumes binary volumetric `.mnc` brain masks to produce
surfaces as `.obj` files with standard connectivity (81,920 triangles). This program is
suitable for targeting the **inner cortical plate** surface (gray-white matter boundary)
of high-quality human fetal brain MRI segmentation for subjects between 23-35 gestational
Expand All @@ -21,29 +21,29 @@ weeks of age.
Polygonal surface mesh representations of brain hemispheres are useful for measuring cortical
thickness, image registration, and quantitative regional analysis.

## Marching Cubes
## Surface Extraction Algorithm

1. Preprocess mask using `mincmorph` to fill in disconnected voxels (improve mask quality)
2. Marching-cubes -> spherical topology surface mesh with unknown number of triangles
3. Calculate distance error
4. _If_ maximum distance error is too large, _then_ redo marching-cubes with subsampling
5. Sphere-to-sphere interpolation -> resample mesh to standard connectivity of 81,920 triangles, preserving morphology
6. Calculate smoothness error
7. Run `adapt_object_mesh` to achieve desired smoothness. Number of iterations is predicted by a regression

### Marching Cubes

We have evaluated two implementations of marching-cubes:

- [scikit-image](https://github.com/FNNDSC/pl-fetal-cp-surface-extract)
- [scikit-image](https://github.com/FNNDSC/pl-fetal-surface-extract)
- [CIVET](https://github.com/FNNDSC/ep-sphere_mesh)

We found that CIVET's implementation of the marching-cubes algorithm, `sphere_mesh`, is
[more accurate](docs/compare_civet_skimage.md)
than scikit-image's implementation, which requires FWHM blurring of the volume.
Moreover, `sphere_mesh` guarantees a spherical topology.

## Surface Extraction Algorithm

1. Preprocess mask using `mincmorph` to fill in disconnected voxels (improve mask quality)
2. Marching-cubes -> spherical topology surface mesh with unknown number of triangles
3. Calculate distance error
4. _If_ maximum distance error is too large, _then_ redo marching-cubes with subsampling
5. Sphere-to-sphere interpolation -> resample mesh to standard connectivity of 81,920 triangles, preserving morphology
6. Calculate smoothness error
7. Run `adapt_object_mesh` to achieve desired smoothness. Number of iterations is predicted by a regression model

### Estimation of: How much smoothing?
### How much Smoothing? Estimation

We developed a model which predicts the number of `adapt_object_mesh` smoothing iterations necessary, given a desired smoothness error threshold.
The model was created from the experiment described here:
Expand All @@ -56,7 +56,7 @@ The model was created from the experiment described here:
1. https://github.com/FNNDSC/ep-premc-mincmorph
2. https://github.com/FNNDSC/pl-nums2mask
3. https://github.com/FNNDSC/pl-subdiv-minc TODO
4. pl-fetal-cp-surface-extract
4. pl-fetal-surface-extract
5. pl-extracted-surface-asp TODO

<!--
Expand All @@ -68,10 +68,10 @@ without the extra step the accuracy is nonetheless sufficient.

## Installation

`pl-fetal-cp-surface-extract` is a _[ChRIS](https://chrisproject.org/) plugin_, meaning it can
`pl-fetal-surface-extract` is a _[ChRIS](https://chrisproject.org/) plugin_, meaning it can
run from either within _ChRIS_ or the command-line.

[![Get it from chrisstore.co](https://raw.githubusercontent.com/FNNDSC/ChRIS_store_ui/963938c241636e4c3dc4753ee1327f56cb82d8b5/src/assets/public/badges/light.svg)](https://chrisstore.co/plugin/pl-fetal-cp-surface-extract)
[![Get it from chrisstore.co](https://raw.githubusercontent.com/FNNDSC/ChRIS_store_ui/963938c241636e4c3dc4753ee1327f56cb82d8b5/src/assets/public/badges/light.svg)](https://chrisstore.co/plugin/pl-fetal-surface-extract)

## Usage

Expand Down Expand Up @@ -99,31 +99,31 @@ values shouldn't do any harm, and would help compensate for larger brain sizes.

Copy input mask file to output directory.

`--keep-mask` is a workaround for using `pl-fetal-cp-surface-extract` as part of a
`--keep-mask` is a workaround for using `pl-fetal-surface-extract` as part of a
_ChRIS_ pipeline. It eliminates the need for an extra _ts_ plugin step.

## Local Usage

To get started with local command-line usage, use [Apptainer](https://apptainer.org/)
to run `pl-fetal-cp-surface-extract` as a container:
to run `pl-fetal-surface-extract` as a container:

```shell
apptainer exec docker://fnndsc/pl-fetal-cp-surface-extract extract_cp input/ output/
apptainer exec docker://fnndsc/pl-fetal-surface-extract extract_cp input/ output/
```

To print its available options, run:

```shell
apptainer exec docker://fnndsc/pl-fetal-cp-surface-extract extract_cp --help
apptainer exec docker://fnndsc/pl-fetal-surface-extract extract_cp --help
```

## Suggested Software

### Before `pl-fetal-cp-surface-extract`
### Before `pl-fetal-surface-extract`

- [`pl-nums2mask`](https://chrisstore.co/plugin/pl-nums2mask): create input masks

### After `pl-fetal-cp-surface-extract`
### After `pl-fetal-surface-extract`

- [`pl-surfdisterr`](https://chrisstore.co/plugin/pl-surfdisterr): QC
- [`pl-smoothness-error`](https://chrisstore.co/plugin/pl-smoothness-error): QC
Expand All @@ -137,7 +137,7 @@ Instructions for developers.
Build a local container image:

```shell
docker build -t localhost/fnndsc/pl-fetal-cp-surface-extract .
docker build -t localhost/fnndsc/pl-fetal-surface-extract .
```

### Get JSON Representation
Expand All @@ -146,7 +146,7 @@ Run [`chris_plugin_info`](https://github.com/FNNDSC/chris_plugin#usage)
to produce a JSON description of this plugin, which can be uploaded to a _ChRIS Store_.

```shell
docker run --rm localhost/fnndsc/pl-fetal-cp-surface-extract chris_plugin_info > chris_plugin_info.json
docker run --rm localhost/fnndsc/pl-fetal-surface-extract chris_plugin_info > chris_plugin_info.json
```

### Local Test Run
Expand All @@ -157,5 +157,5 @@ Mount the source code `extract_cp.py` into a container to test changes without r
docker run --rm -it --userns=host -u $(id -u):$(id -g) \
-v $PWD/extract_cp:/opt/conda/lib/python3.10/site-packages/extract_cp:ro \
-v $PWD/in:/incoming:ro -v $PWD/out:/outgoing:rw -w /outgoing \
localhost/fnndsc/pl-fetal-cp-surface-extract extract_cp /incoming /outgoing
localhost/fnndsc/pl-fetal-surface-extract extract_cp /incoming /outgoing
```
2 changes: 1 addition & 1 deletion docs/compare_civet_skimage.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Brief comparison of marching-cubes implementations between
[scikit-image](https://github.com/FNNDSC/pl-fetal-cp-surface-extract)
[scikit-image](https://github.com/FNNDSC/pl-fetal-surface-extract)
and [CIVET](https://github.com/FNNDSC/ep-sphere_mesh).

Cost function is mean
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
description='Fetal brain MRI CP surface extraction using CIVET marching-cubes',
author='Jennings Zhang',
author_email='Jennings.Zhang@childrens.harvard.edu',
url='https://github.com/FNNDSC/pl-fetal-cp-surface-extract',
url='https://github.com/FNNDSC/pl-fetal-surface-extract',
packages=find_packages(exclude=['tests']),
install_requires=['chris_plugin', 'loguru', 'pycivet', 'pybicpl', 'numpy'],
license='MIT',
Expand Down

0 comments on commit d7e405f

Please sign in to comment.