Similar questions have been asked on SO, but never in the form that I needed.
I seem to be having trouble understanding NumPy slicing behavior.
Lets say I have an Numpy Array of shape 512x512x120
vol1=some_numpy_array
print(x.shape) #result: (512,512,120)
I want to take a "z-slice" of this array, however I end up with a 512x120 array instead of a 512x512 one I try the following code for instance
zSlice=(vol1[:][:][2]).squeeze()
print(zSlice.shape()) #result: (512,120)
Why is the resulting array shape (512,120)
and not (512,512)
? How can I fix this problem?