Skip to content

Commit

Permalink
better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xiuliren committed Oct 25, 2023
1 parent 6e3b33d commit c49ebe6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 3 additions & 5 deletions chunkflow/flow/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ def delete_var(tasks, var_names: str):
type=click.INT, default=None, help='mip level of the cutout.')
@click.option('--expand-margin-size', '-e',
type=click.INT, nargs=3, default=None,
help='include surrounding regions of output bounding box.')
help='include surrounding regions of output bounding box. It should have 3 values. If it is 1,1,1, the chunk size will be expanded with 2x2x2.')
@click.option('--chunk-start', '-s',
type=click.INT, nargs=3, default=None, callback=default_none,
help='chunk offset in volume.')
Expand Down Expand Up @@ -1889,8 +1889,7 @@ def mask_out_objects(tasks, input_chunk_name, output_chunk_name,
help='name of this operator')
@click.option('--margin-size', '-m',
type=click.INT, nargs=6, default=None, callback=default_none,
help='crop the chunk margin. ' +
'The default is None and will use the bbox as croping range.')
help='crop the chunk margin. The default is None and will use the bbox as croping range. It should have 6 values. If it is 1,1,1,1,1,1, the chunk will shrink by 2x2x2 in each direction.')
@click.option('--crop-bbox/--no-crop-bbox', default=False,
help='adjust the bounding box or not.')
@click.option('--input-chunk-name', '-i',
Expand All @@ -1905,8 +1904,7 @@ def crop_margin(tasks, name: str, margin_size: tuple, crop_bbox: bool,
if task is not None:
start = time()
if margin_size:
task[output_chunk_name] = task[
input_chunk_name].crop_margin(
task[output_chunk_name] = task[input_chunk_name].crop_margin(
margin_size=margin_size)
if crop_bbox and 'bbox' in task:
bbox = task['bbox']
Expand Down
7 changes: 5 additions & 2 deletions chunkflow/volume.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations
import os
from typing import Union, List
from abc import ABC, abstractmethod, abstractproperty
from functools import cached_property
Expand Down Expand Up @@ -221,12 +222,14 @@ def load_chunk_or_volume(file_path: str, *arg, **kwargs):
file_path (str): the file path of chunk or volume.
Returns:
Union[Chunk, AbstractVolume]: loaded chunk or volume
Union[Chunk, AbstractVolume]: loaded chunk or volume. return None if file does not exist.
"""
if kwargs is None:
kwargs = dict()

if file_path.endswith('.h5'):
if not os.path.exists(file_path):
return None
elif file_path.endswith('.h5'):
return Chunk.from_h5(file_path)
elif file_path.endswith('.npy'):
arr = np.loads(file_path)
Expand Down

0 comments on commit c49ebe6

Please sign in to comment.