indexing image with a list of indices cannot, in general, return a consistent affine
Bug #514040 reported by
Bago
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NIPY |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
In [66]: img[..., np.array((0,1))]
95 # allow slicing of form [...,1]
96 if Ellipsis in index:
---> 97 if sum([i == Ellipsis for i in index]) > 1:
98 raise ValueError("only one Ellipsis (...) allowed in slice")
99 # convert ellipsis to series of slice(None) objects. For
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I believe the i == Ellipsis should be i is Ellipsis
summary: |
- indexing image object with numpy array fails + indexing image with a list of indices cannot, in general, return a valid + affine |
summary: |
- indexing image with a list of indices cannot, in general, return a valid - affine + indexing image with a list of indices cannot, in general, return a + consistent affine |
Changed in nipy: | |
status: | New → Fix Committed |
To post a comment you must log in.
Hi Bago,
On Thu, Jan 28, 2010 at 10:45 PM, Bago <email address hidden> wrote:
> Public bug reported:
>
> In [66]: img[..., np.array((0,1))]
>
>
> 95 # allow slicing of form [...,1]
> 96 if Ellipsis in index:
> ---> 97 if sum([i == Ellipsis for i in index]) > 1:
> 98 raise ValueError("only one Ellipsis (...) allowed in slice")
> 99 # convert ellipsis to series of slice(None) objects. For
>
> ValueError: The truth value of an array with more than one element is
> ambiguous. Use a.any() or a.all()
>
> I believe the i == Ellipsis should be i is Ellipsis
Ah - yes - the problem is, that implementing fancy indexing (indexing
with an array) would be rather hard. Do you have a particular
use-case in mind? Can it be covered by getting the array:
data = np.asarray(img)
sampled = data[index_array]
and then putting in your own affine? The complications arise trying
to deal with all the possible crazy things you can do with fancy
indexing, when keeping track of the affine...
Thanks a lot,
Matthew