Skip to content

Problem in _parse_range with min_constraint #1389

@iimog

Description

@iimog

Is there an existing issue for this?

  • I have searched the existing issues

Bug summary

When setting a min_constraint in Transform._parse_range and calling with an upper bound only, the upper bound is also used as the lower bound (instead of using the min_constraint there).

The bug is in this line

min_range = -nums_range if min_constraint is None else nums_range

It should read:

            min_range = -nums_range if min_constraint is None else min_constraint

Code for reproduction

tio.Transform._parse_range(5, 'name', min_constraint=0)

Actual outcome

(5, 5)

Error messages

Expected outcome

(0, 5)

System info

Platform:   Linux-6.1.0-40-amd64-x86_64-with-glibc2.36
TorchIO:    0.21.0
PyTorch:    2.9.1+cu128
SimpleITK:  2.5.3 (ITK 5.4)
NumPy:      2.3.5
Python:     3.13.8 (main, Oct 10 2025, 12:48:21) [Clang 20.1.4 ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions