fn idx3d(i: usize, j: usize, k: usize, nx: usize, ny: usize) -> usize
Convert 3D index to flat index (Fortran order / column-major, matches NIfTI) For array shape (nx, nx, ny), index [i,j,k] maps to: i + jnx + knx*ny