1

I'm newbie with Python and also with Numpy.

I have this code:

one_array.shape

When I run it, I get this output:

(20, 48, 240, 240)

one_array is a Numpy Array that has 20 images.

What do mean the other three numbers in shape output (48, 240, 240)?

VansFannel
  • 45,055
  • 107
  • 359
  • 626

4 Answers4

2

Your array consist of 20 images, each of them is the size 48X240X240. Which is odd, I would expect that it will be something like 240X240X3 but for some reason you have way more channels (referring to RGB). ]

So the shape function return the size of dimension along each axis (the current shape of the entire array), so in your case there is (20, 48, 240, 240)

Edit:

As the user said, each image consist of 48 NITFY images of 1 channel which explain the output of shape

David
  • 8,113
  • 2
  • 17
  • 36
  • Thanks for your answer. I think is: 20 elements in the array. Each of these elements are a NIFTY image. Each of these NITFY images are: 48 images of 240x240. – VansFannel Dec 19 '19 at 14:19
  • @VansFannel Thanks for the acceptance, I added your comment to my answer in that it will be clearer to one reading the answer – David Dec 19 '19 at 14:23
  • 1
    You are welcome. I have used the program MRIcron to open a T1.nii.gz and check that it has 48 images, 240x240 each of them. – VansFannel Dec 19 '19 at 14:33
0

Imagine your Numpy Array as a Vector that can be in one dimension, but in your case it looks like it is in dimension 4. (20, 4, 240, 240) means a big matrix composed of 20 x 4 x 240 x 240 elements.

Phoenixo
  • 2,071
  • 1
  • 6
  • 13
0

one_array.shape == (20, 48, 240, 240) means that one_array is a 4-dimensional array with 20*48*240*240 or 55296000 elements.

9mat
  • 1,194
  • 9
  • 13
0

You are right, you can think of one_array as an array with 20 elements, in which is element in another array with shape (48, 240, 240). However, usually is it better to think that one_array is a 4 dimensional array, that has a total of 20x48x240x240 = 55296000 elements.

Diego Palacios
  • 1,096
  • 6
  • 22