Skip to content

Commit 6e2bb99

Browse files
committed
feat(focus-cli): add support for x-separated chunk sizes and no-slicing option
1 parent f8f565a commit 6e2bb99

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

sarpyx/cli/focus.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def _parse_chunk_shape(chunk_shape: str) -> Optional[Union[str, Tuple[int, ...]]
3636
- 'auto'
3737
- 'none' (or empty) to use default behavior in saver
3838
- comma-separated positive integers, e.g. "2048,2048"
39+
- x-separated positive integers, e.g. "2048x2048"
3940
"""
4041
if chunk_shape is None:
4142
return 'auto'
@@ -47,11 +48,15 @@ def _parse_chunk_shape(chunk_shape: str) -> Optional[Union[str, Tuple[int, ...]]
4748
return None
4849

4950
try:
50-
parsed = tuple(int(v.strip()) for v in chunk_shape.split(','))
51+
parsed_text = chunk_shape.strip().lower().replace('x', ',')
52+
parts = [v.strip() for v in parsed_text.split(',')]
53+
if any(v == '' for v in parts):
54+
raise ValueError
55+
parsed = tuple(int(v) for v in parts)
5156
except ValueError as exc:
5257
raise ValueError(
5358
f'Invalid --chunk-shape value "{chunk_shape}". '
54-
'Use "auto", "none", or comma-separated integers like "2048,2048".'
59+
'Use "auto", "none", comma-separated integers like "2048,2048", or x-separated integers like "2048x2048".'
5560
) from exc
5661

5762
if len(parsed) == 0 or any(v <= 0 for v in parsed):
@@ -124,9 +129,11 @@ def create_parser() -> argparse.ArgumentParser:
124129

125130
parser.add_argument(
126131
'--chunk-shape',
132+
'--chunk-size',
133+
dest='chunk_shape',
127134
type=str,
128135
default='auto',
129-
help='Output Zarr chunk shape: "auto", "none", or comma-separated ints (e.g. 2048,2048)'
136+
help='Output Zarr chunk shape: "auto", "none", comma-separated ints (e.g. 2048,2048), or x-separated ints (e.g. 2048x2048)'
130137
)
131138

132139
parser.add_argument(

sarpyx/cli/main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,18 @@ def _add_focus_arguments(parser: argparse.ArgumentParser) -> None:
165165
default=15000,
166166
help='Slice height for processing (default: 15000)'
167167
)
168+
parser.add_argument(
169+
'--no-slicing',
170+
action='store_true',
171+
help='Disable slicing and process the full input as a single slice'
172+
)
168173
parser.add_argument(
169174
'--chunk-shape',
175+
'--chunk-size',
176+
dest='chunk_shape',
170177
type=str,
171178
default='auto',
172-
help='Output Zarr chunk shape: "auto", "none", or comma-separated ints (e.g. 2048,2048)'
179+
help='Output Zarr chunk shape: "auto", "none", comma-separated ints (e.g. 2048,2048), or x-separated ints (e.g. 2048x2048)'
173180
)
174181
parser.add_argument(
175182
'--compression-level',

0 commit comments

Comments
 (0)