Skip to content

Commit

Permalink
No subsample by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennings Zhang authored and Jennings Zhang committed Sep 12, 2022
1 parent 867a06f commit 9713a19
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ We found that CIVET's implementation of the marching-cubes algorithm, `sphere_me
than scikit-image's implementation, which requires FWHM blurring of the volume.
Moreover, `sphere_mesh` guarantees a spherical topology.

It is necessary to use the `-subsample` option for fetal brains to avoid
"bridge" errors between tight (<1 voxel) sulcal walls.

## Surface Extraction Algorithm

1. Proprocess mask using `mincmorph` to fill in disconnected voxels (improve mask quality)
Expand Down Expand Up @@ -71,6 +68,11 @@ individually and in parallel.

### Options

#### `--subsample`

It is necessary to use the `--subsample` option for fetal brains 29 GA
and older to avoid "bridge" errors between narrow (<1 voxel) sulcal walls.

#### `--mincmorph-iterations`

Number of `mincmorph` iterations to perform on the mask before marching-cubes.
Expand Down
2 changes: 2 additions & 0 deletions extract_cp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
help='brain hemisphere side. "auto" => infer from file name')
parser.add_argument('-p', '--pattern', default='**/*.mnc',
help='pattern for file names to include')
parser.add_argument('--subsample', action='store_true',
help='Use -subsample option for spehre_mesh, use with narrow sulci')
parser.add_argument('--mincmorph-iterations', dest='mincmorph_iterations', type=int, default=5,
help='Number of mincmorph iterations. Mincmorph is a mask preprocessing step '
'which repairs disconnected voxels. A larger value may improve results '
Expand Down
2 changes: 1 addition & 1 deletion extract_cp/extract_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def extract_surface(mask: Path, surface: Path, params: Parameters):
with log_path.open('wb') as log:
HemisphereMask(mask)\
.smoothen_using_mincmorph(iterations=params.mincmorph_iterations)\
.just_sphere_mesh(chosen_side, subsample=True)\
.just_sphere_mesh(chosen_side, subsample=params.subsample)\
.adapt_object_mesh(*params.adapt_object_mesh)\
.interpolate_with_sphere(chosen_side, *params.inflate_to_sphere_implicit)\
.save(surface, shell=__curry_log(log))
Expand Down
10 changes: 7 additions & 3 deletions extract_cp/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Parameters:
adapt_object_mesh: tuple[int, int, int]
inflate_to_sphere_implicit: tuple[int, int]
keep_mask: bool
subsample: bool

def __post_init__(self):
if not len(self.adapt_object_mesh) == 3:
Expand All @@ -30,14 +31,16 @@ def new(
mincmorph_iterations: int,
adapt_object_mesh: str,
inflate_to_sphere_implicit: str,
keep_mask: bool
keep_mask: bool,
subsample: bool
) -> 'Parameters':
return cls(
side=side,
mincmorph_iterations=mincmorph_iterations,
adapt_object_mesh=_str2ints(adapt_object_mesh),
inflate_to_sphere_implicit=_str2ints(inflate_to_sphere_implicit),
keep_mask=keep_mask
keep_mask=keep_mask,
subsample=subsample
)

@classmethod
Expand All @@ -47,7 +50,8 @@ def from_obj(cls, options) -> 'Parameters':
mincmorph_iterations=options.mincmorph_iterations,
adapt_object_mesh=options.adapt_object_mesh,
inflate_to_sphere_implicit=options.inflate_to_sphere_implicit,
keep_mask=options.keep_mask
keep_mask=options.keep_mask,
subsample=options.subsample
)


Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

setup(
name='extract_cp',
version='1.1.0',
version='1.2.0',
description='Fetal brain MRI CP surface extraction using CIVET marching-cubes',
author='Jennings Zhang',
author_email='[email protected]',
url='https://github.com/FNNDSC/pl-fetal-cp-surface-extract',
packages=['extract_cp'],
install_requires=['chris_plugin'],
install_requires=['chris_plugin', 'loguru', 'pycivet'],
license='MIT',
python_requires='>=3.10.4',
entry_points={
'console_scripts': [
'extract_cp = extract_cp.__main__:main'
Expand Down

0 comments on commit 9713a19

Please sign in to comment.