0

I'm newbie with Python.

I have found this code:

array = FLAIR_array[..., np.newaxis] # FLAIR_array is a Numpy array.

FLAIR_array shape is (960, 200, 200) and array shape is (960, 200, 200, 1).

np.newaxis has added a new dimension to the array, but I don't know what value is in that new dimension (this is a question, but I think I can't ask more than one thing on the same question).

My question is: What does ... mean in FLAIR_array[..., np.newaxis]?

APhillips
  • 1,175
  • 9
  • 17
VansFannel
  • 45,055
  • 107
  • 359
  • 626
  • Is the question about the new axis or about the ellipsis (=`...`)? – GPhilo Jan 28 '20 at 16:23
  • Yes. The problem is that I don't know how to name that, `...`, in English. – VansFannel Jan 28 '20 at 16:24
  • 1
    There are no "new values" in the new dimension, it's just a different shape, the same as if you go from `[1, 2, 3]` (shape `(3,)`) to `[[1], [2], [3]]` (shape `(3, 1)`). The ellipsis is kind of a wildcard for "as many dimensions as I am not explicitly giving", see (possible dupe) [How do you use the ellipsis slicing syntax in Python?](https://stackoverflow.com/q/118370/1782792). – jdehesa Jan 28 '20 at 16:24
  • Also, see [NumPy's documentation on indexing](https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.indexing.html) – ForceBru Jan 28 '20 at 16:25
  • 1
    @VansFannel the three dots are called "ellipsis" ;) – GPhilo Jan 28 '20 at 16:25
  • 1
    @GPhilo, thanks!! You are great! – VansFannel Jan 28 '20 at 16:25
  • Inside the `FLAIR_array` there are grey images. I think they are only a new dimension to denote that the images have only one channel. What do you think? – VansFannel Jan 28 '20 at 16:29

0 Answers0