Skip to content

Commit

Permalink
Add level to args
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Feb 25, 2022
1 parent 748aa9a commit 3beef19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name = 'ep-skimage-mcubes-mni',
version = '1.0.0',
version = '1.1.0',
description = 'Marching-cubes implementation from scikit-image',
author = 'Jennings Zhang',
author_email = '[email protected]',
Expand Down
9 changes: 7 additions & 2 deletions skimc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from chris_plugin import chris_plugin, PathMapper

parser = ArgumentParser(description='cli description')
parser.add_argument('-l', '--level', default=None, type=float,
help='Contour value to search for isosurfaces in volume.'
'If not given or None, the average of the min and max'
' of vol is used.')
parser.add_argument('--spacing', default='1,1,1',
help='Voxel spacing in spatial dimensions corresponding'
' to numpy array indexing dimensions (M, N, P).')
Expand All @@ -29,13 +33,14 @@


def mcubes(mask_path: Path, surface_path: Path,
level: float,
spacing: tuple[float, float, float],
step_size: int,
method: str):
mask = nib.load(mask_path)
data = mask.get_fdata()
verts, faces, normals, values = measure.marching_cubes(
data, spacing=spacing, step_size=step_size, method=method, allow_degenerate=False
data, level=level, spacing=spacing, step_size=step_size, method=method, allow_degenerate=False
)
transformed_verts = apply_affine(mask.affine, verts)
obj = PolygonObj.from_data(transformed_verts, faces, normals)
Expand All @@ -60,7 +65,7 @@ def main(options: Namespace, inputdir: Path, outputdir: Path):
with ThreadPoolExecutor(max_workers=len(os.sched_getaffinity(0))) as pool:
mapper = PathMapper(inputdir, outputdir, glob=options.pattern, suffix='.obj')
for mnc, obj in mapper:
results.append(pool.submit(mcubes, mnc, obj, spacing, options.step_size, options.method))
results.append(pool.submit(mcubes, mnc, obj, options.level, spacing, options.step_size, options.method))

for future in results:
future.exception()
Expand Down

0 comments on commit 3beef19

Please sign in to comment.