Skip to content

"NameError: 'inf' not defined in harmonize_b0s when processing DWI data with non-standard bval schemes" #982

@arovai

Description

@arovai

Summary

QSIPrep fails to process DWI data with unusual bval schemes (containing b0 volumes but non-standard bval values), resulting in a NameError related to inf in the harmonize_b0s function.

Additional details

  • QSIPrep version: 1.0.1
  • Docker version: 28.5.0

What were you trying to do?

Process a BIDS-compatible DWI dataset with two phase-encoding directions (AP and PA). Both datasets contain b0 volumes, but the bval files have non-standard values:

  • dir-AP: Starts with multiple zeros (b0 volumes), followed by 1200 values.
  • dir-PA: Starts with 2000, followed by zeros and 2000 values.

What did you expect to happen?

QSIPrep should successfully identify and harmonize the b0 volumes across both phase-encoding directions, regardless of the unusual bval scheme.

What actually happened?

QSIPrep failed with a NameError in the harmonize_b0s function, specifically:

NameError: ("Input formula couldn't be processed, you provided 'img*inf',", "name 'inf' is not defined"). Did you mean: 'int'?

This suggests that inf is not defined in the context where it is used, and should likely be replaced with np.inf.

Reproducing the bug

Steps:

  1. Run QSIPrep (Docker) on a BIDS dataset with the described bval scheme.
  2. Use the following bval files:
    • dir-AP: 0 0 0 ... 1200 1200 1200 ...
    • dir-PA: 2000 0 2000 2000 ...
  3. Observe the error during the harmonize_b0s step.

Additional Notes:

  • The dataset is BIDS-compatible and contains no NaN values.
  • All acquisition parameters (including prescan) were kept constant except for phase direction.
  • The error persists even when using the unstable branch of QSIPrep.
  • Related neurostarts topic: https://neurostars.org/t/qsiprep-error-merge-dwis/33967/17

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