Jaime's answer is correct and np.transpose is the solution. but he did not explain how to calculate permutation argument. So, I want to explain how to calculate it correctly here:
If you have a 4 dimensional axis array like: (i, j, k, l), and you want to transpose them into (k, l, i, j), first you must number each axis pythonically, so in given example: "i" is axis=0, "j" is axis =1, "k" is axis=2, and "l" is axis=3. Then you should maintain original axis numbers and arrange those numbers into final desired axes arrangement, as in: k should be placed in axis=0 and k was represented by number 2 so 2 sits in position of axis=0 which gives => (2, , , )... and by maintaining the same condition for other axes the permutation argument of (2,3,0,1) will be obtained. However, It is easy to mistake final axis numbers instead of the original ones in calculating the permutation argument, like mistakenly considering: "i" should become axis=2, "j" should become axis=3, "k" should become axis=0, and "l" should become axis=1, which surprisingly gives (2,3,0,1) correctly again but this manner of calculation can give a wrong answer in other cases. For example, if you were to transpose (i, j, k, l) into (i, k, l, j), the first method calculates the permutation argument correctly as (0,2,3,1) but the second method calculates it mistakenly as (0,3,1,2), as it is shown in below:
import numpy as np
A = np.ones((500,3,512,512))
# Changing A dimensions into (500,512,512,3)
B = np.transpose(A, (0,2,3,1))
C = np.transpose(A, (0,3,1,2))
print(np.shape(B)) # permutation is correct
print(np.shape(C)) # permutation is wrong
which prints:
size of B is: (500, 512, 512, 3)
size of C is: (500, 512, 3, 512)
dimension
variables? Did you miss somerange
calls?