From 43cc7fb4279cf0cd255d7b7449be1e5f59c8acce Mon Sep 17 00:00:00 2001 From: balbasty Date: Wed, 18 Dec 2024 08:54:31 +0000 Subject: [PATCH] FIX(reslice): fix bug when not using chunking --- nitorch/cli/registration/reslice/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nitorch/cli/registration/reslice/main.py b/nitorch/cli/registration/reslice/main.py index 03a42018..45244c0f 100644 --- a/nitorch/cli/registration/reslice/main.py +++ b/nitorch/cli/registration/reslice/main.py @@ -407,8 +407,12 @@ def build_from_target(affine, shape, smart=False): # -------------------------------------------------------------- # chunkwise processing # -------------------------------------------------------------- - chunk = py.make_list(options.chunk, 3) - if resample and chunk and any(c < x for x, c in zip(file.shape, chunk)): + need_chunk = bool(options.chunk) + if need_chunk: + chunk = py.make_list(options.chunk, 3) + need_chunk = need_chunk and any(c < x for x, c in zip(file.shape, chunk)) + + if resample and need_chunk: odat = utils.movedim(torch.empty( [*oshape, file.channels], @@ -470,9 +474,9 @@ def build_from_target(affine, shape, smart=False): # -------------------------------------------------------------- else: if is_label: - dat = dat.data(**backend_int) + dat = vol.data(**backend_int) else: - dat = dat.fdata(rand=False, **backend) + dat = vol.fdata(rand=False, **backend) dat = dat[..., channels] dat = dat.reshape([*file.shape, file.channels]) dat = utils.movedim(dat, -1, 0)