Skip to content

Commit

Permalink
add layer-type option for load-tif
Browse files Browse the repository at this point in the history
  • Loading branch information
xiuliren committed Nov 26, 2024
1 parent 12f9232 commit b900538
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
7 changes: 5 additions & 2 deletions chunkflow/chunk/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion chunkflow/flow/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,14 +925,17 @@ 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')
@click.option('--output-chunk-name', '-o', type=str, default='chunk',
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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions chunkflow/flow/neuroglancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions chunkflow/plugins/agglomerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<MeanAffinity<RegionGraphType, ScoreValue>>'
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<MeanAffinity<RegionGraphType, ScoreValue>>',
flip_channel: bool = True,
):
"""
Mean/max agglomeration of affinity map including watershed step.
Expand Down

0 comments on commit b900538

Please sign in to comment.