diff --git a/chunkflow/chunk/base.py b/chunkflow/chunk/base.py index c1b4ac1..b99499a 100755 --- a/chunkflow/chunk/base.py +++ b/chunkflow/chunk/base.py @@ -206,7 +206,10 @@ def clone(self): ) @classmethod - def from_tif(cls, file_name: str, voxel_offset: tuple=None, dtype: str = None, + def from_tif(cls, file_name: str, + voxel_offset: tuple=None, + dtype: str = None, + layer_type: str = None, voxel_size: tuple=None): assert os.path.exists(file_name) if os.path.isfile(file_name): @@ -230,7 +233,7 @@ def from_tif(cls, file_name: str, voxel_offset: tuple=None, dtype: str = None, arr[idx+1, :, :] = section print(f'read tif chunk with size of {arr.shape}, voxel offset: {voxel_offset}, voxel size: {voxel_size}') - return cls(arr, voxel_offset=voxel_offset, voxel_size=voxel_size) + return cls(arr, voxel_offset=voxel_offset, voxel_size=voxel_size, layer_type=layer_type) def to_tif(self, file_name: str=None, compression: str = 'zlib'): if file_name is None: diff --git a/chunkflow/flow/flow.py b/chunkflow/flow/flow.py index dc692c0..360f1b7 100755 --- a/chunkflow/flow/flow.py +++ b/chunkflow/flow/flow.py @@ -925,6 +925,9 @@ def load_png(tasks: dict, path: str, help='global offset of this chunk') @click.option('--voxel-size', '-s', type=click.INT, nargs=3, default=None, callback=default_none, help='physical size of voxels. The unit is assumed to be nm.') +@click.option('--layer-type', '-l', + type=click.Choice(['image', 'segmentation']), default=None, + help='the layer type in neuroglancer for visualization.') @click.option('--dtype', '-d', type=click.Choice(['uint8', 'uint16', 'uint32', 'uint64', 'float32', 'float64', 'float16']), help='convert to data type') @@ -932,7 +935,7 @@ def load_png(tasks: dict, path: str, help='chunk name in the global state') @operator def load_tif(tasks, name: str, file_name: str, voxel_offset: tuple, - voxel_size: tuple, dtype: str, output_chunk_name: str): + voxel_size: tuple, layer_type: str, dtype: str, output_chunk_name: str): """Read tiff files.""" for task in tasks: if task is not None: @@ -941,6 +944,7 @@ def load_tif(tasks, name: str, file_name: str, voxel_offset: tuple, file_name, dtype=dtype, voxel_offset=voxel_offset, + layer_type=layer_type, voxel_size=voxel_size) task['log']['timer'][name] = time() - start yield task diff --git a/chunkflow/flow/neuroglancer.py b/chunkflow/flow/neuroglancer.py index 33cf546..e0734fa 100644 --- a/chunkflow/flow/neuroglancer.py +++ b/chunkflow/flow/neuroglancer.py @@ -373,7 +373,7 @@ def parse_selected_args(varname: str) -> Tuple[str, dict]: name, layer_kwargs = parse_selected_args(name) data = datas[name] layer_args = (viewer_state, name, data) - # breakpoint() + breakpoint() if data is None: continue @@ -401,7 +401,7 @@ def parse_selected_args(varname: str) -> Tuple[str, dict]: raise ValueError('affinity map is not working yet. To-Do.') else: raise ValueError('unsupported data type.') - if data.layer_type == 'segmentation': + elif data.layer_type == 'segmentation': self._append_segmentation_layer(*layer_args, **layer_kwargs) elif data.layer_type == 'probability_map': self._append_probability_map_layer(*layer_args, **layer_kwargs) diff --git a/chunkflow/plugins/agglomerate.py b/chunkflow/plugins/agglomerate.py index fa768f6..da20032 100644 --- a/chunkflow/plugins/agglomerate.py +++ b/chunkflow/plugins/agglomerate.py @@ -5,14 +5,14 @@ from waterz import agglomerate -threshold: float = 0.7 -aff_threshold_low: float = 0.001 -aff_threshold_high: float = 0.9999 -scoring_function: str = 'OneMinus>' -flip_channel: bool = True - - -def execute(affs: Chunk, fragments: np.ndarray = None): +def execute(affs: Chunk, + fragments: np.ndarray = None, + threshold: float = 0.7, + aff_threshold_low: float = 0.001, + aff_threshold_high: float = 0.9999, + scoring_function: str = 'OneMinus>', + flip_channel: bool = True, + ): """ Mean/max agglomeration of affinity map including watershed step.