Skip to content

Commit 2600e4f

Browse files
authored
Merge pull request #621 from mgxd/enh/squeeze-clipping
FIX: Ensure IntensityClip input is a 3D file
2 parents 1a2c3e8 + f2a39b5 commit 2600e4f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

niworkflows/interfaces/nibabel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def _run_interface(self, runtime):
369369

370370
class _IntensityClipInputSpec(BaseInterfaceInputSpec):
371371
in_file = File(
372-
exists=True, mandatory=True, desc="file which intensity will be clipped"
372+
exists=True, mandatory=True, desc="3D file which intensity will be clipped"
373373
)
374374
p_min = traits.Float(35.0, usedefault=True, desc="percentile for the lower bound")
375375
p_max = traits.Float(99.98, usedefault=True, desc="percentile for the upper bound")
@@ -519,7 +519,9 @@ def _advanced_clip(
519519
out_file = (Path(newpath or "") / "clipped.nii.gz").absolute()
520520

521521
# Load data
522-
img = nb.load(in_file)
522+
img = nb.squeeze_image(nb.load(in_file))
523+
if len(img.shape) != 3:
524+
raise RuntimeError(f"<{in_file}> is not a 3D file.")
523525
data = img.get_fdata(dtype="float32")
524526

525527
# Calculate stats on denoised version, to preempt outliers from biasing

0 commit comments

Comments
 (0)