Skip to content

Commit c95fa1b

Browse files
authored
Stop loading image data by default with tiohd (#1344)
1 parent c8acede commit c95fa1b

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/torchio/cli/print_info.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ def main(
3333
'-l/-s',
3434
help='Use torchio.LabelMap to instantiate the image.',
3535
),
36-
):
36+
load: bool = typer.Option( # noqa: B008
37+
False,
38+
help=(
39+
'Load the image from disk so that information about data type and memory '
40+
'can be displayed. Slower, especially for large images.'
41+
),
42+
),
43+
) -> None:
3744
"""Print information about an image and, optionally, show it.
3845
3946
Example:
@@ -44,7 +51,8 @@ def main(
4451

4552
class_ = tio.LabelMap if label else tio.ScalarImage
4653
image = class_(input_path)
47-
image.load()
54+
if load:
55+
image.load()
4856
print(image) # noqa: T201
4957
if plot:
5058
image.plot()

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_bad_transform(self):
3636

3737
def test_cli_hd(self):
3838
image = str(self.get_image_path('cli'))
39-
args = [image]
39+
args = [image, '--load']
4040
result = runner.invoke(print_info.app, args)
4141
assert result.exit_code == 0
4242
assert (

0 commit comments

Comments
 (0)