PyMVPA/PyMVPA — Issue #56: out of bounds index error in searchlight when chunks has only one value
Author: satra
Created: 2011-10-24 15:28:12+00:00
State: open

```
dataset = fmri_dataset(faskeleton,
mask='/usr/share/fsl/4.1/data/standard/FMRIB58_FA-skeleton_1mm.nii.gz',
targets=features[:,0],
chunks=np.ones((33,)).tolist())

for radius in [0]: #[0, 1, 3]:
# tell which one we are doing
print "Running searchlight with radius: %i ..." % (radius)
sl = sphere_searchlight(cv, radius=radius, space='voxel_indices',
postproc=mean_sample())
ds = dataset.copy(deep=False,
sa=['targets', 'chunks'],
fa=['voxel_indices'],
a=['mapper'])
sl_map = sl(ds)
```

Error

```
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/mindhive/gablab/satra/notebooks/ in ()
8 fa=['voxel_indices'],
9 a=['mapper'])
---> 10 sl_map = sl(ds)
11 sl_map.samples *= -1
12 sl_map.samples += 1

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/base/learner.pyc in __call__(self, ds)
235 "used and auto training is disabled."
236 % str(self))
--> 237 return super(Learner, self).__call__(ds)
238
239

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/base/node.pyc in __call__(self, ds)
74
75 self._precall(ds)
---> 76 result = self._call(ds)
77 result = self._postcall(ds, result)
78

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/measures/searchlight.pyc in _call(self, dataset)
123
124 # pass to subclass

--> 125 results, roi_sizes = self._sl_call(dataset, roi_ids, nproc)
126
127 if not roi_sizes is None:

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/measures/searchlight.pyc in _sl_call(self, dataset, roi_ids, nproc)
239 # otherwise collect the results in a list

240 results, roi_sizes = \
--> 241 self._proc_block(roi_ids, dataset, self.__datameasure)
242
243 if __debug__ and 'SLC' in debug.active:

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/measures/searchlight.pyc in _proc_block(self, block, ds, measure)
291
292 # compute the datameasure and store in results

--> 293 results.append(measure(roi))
294
295 # store the size of the roi dataset

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/base/learner.pyc in __call__(self, ds)
235 "used and auto training is disabled."
236 % str(self))
--> 237 return super(Learner, self).__call__(ds)
238
239

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/base/node.pyc in __call__(self, ds)
74
75 self._precall(ds)
---> 76 result = self._call(ds)
77 result = self._postcall(ds, result)
78

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/measures/base.pyc in _call(self, ds)
470 # always untrain to wipe out previous stats

471 self.untrain()
--> 472 return super(CrossValidation, self)._call(ds)
473
474

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/measures/base.pyc in _call(self, ds)
303 ca.datasets.append(sds)
304 # run the beast

--> 305 result = node(sds)
306 # callback

307 if not self._callback is None:

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/base/learner.pyc in __call__(self, ds)
235 "used and auto training is disabled."
236 % str(self))
--> 237 return super(Learner, self).__call__(ds)
238
239

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/base/node.pyc in __call__(self, ds)
74
75 self._precall(ds)
---> 76 result = self._call(ds)
77 result = self._postcall(ds, result)
78

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/measures/base.pyc in _call(self, ds)
551 # activate the dataset splitter

552 dsgen = splitter.generate(ds)
--> 553 dstrain = dsgen.next()
554
555 if space:

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/generators/splitters.pyc in generate(self, ds)
140 # However, it only works if we have a contiguous chunk or

141 # regular step sizes for the samples to be split

--> 142 filter_ = mask2slice(filter_)
143
144 if collection is ds.sa:

/software/python/EPD/virtualenvs/7.1/nipype0.4/lib/python2.7/site-packages/mvpa2/misc/support.pyc in mask2slice(mask)
564 # get indices of non-zero filter elements

565 idx = mask.nonzero()[0]
--> 566 idx_start = idx[0]
567 idx_end = idx[-1] + 1
568 idx_step = None

IndexError: index out of bounds

Running searchlight with radius: 0 ...
```