From a40539e7dfcd882754d3f3739b8e4d0848f2cfaa Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Tue, 21 Jul 2015 10:11:48 +0100 Subject: [PATCH] Bounds check in starting indices of subsample routine. --- fsl/fslview/gl/routines.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fsl/fslview/gl/routines.py b/fsl/fslview/gl/routines.py index 32b23296c..f47810ead 100644 --- a/fsl/fslview/gl/routines.py +++ b/fsl/fslview/gl/routines.py @@ -484,6 +484,10 @@ def subsample(data, resolution, pixdim=None, volume=None): xstart = np.floor(xstep / 2) ystart = np.floor(ystep / 2) zstart = np.floor(zstep / 2) + + if xstart >= data.shape[0]: xstart = data.shape[0] - 1 + if ystart >= data.shape[1]: ystart = data.shape[1] - 1 + if zstart >= data.shape[2]: zstart = data.shape[2] - 1 if len(data.shape) > 3: sample = data[xstart::xstep, ystart::ystep, -- GitLab