z_slice :: Elt a => Int -> Array DIM3 a -> Array DIM2 a
z_slice n arr =
slice arr (Any :. n :. All :. All)
+
+
+transpose_zx :: Elt a => Array DIM3 a -> Array DIM3 a
+transpose_zx arr =
+ traverse arr
+ (\(Z :. zdim :. ydim :. xdim) -> (Z :. xdim :. ydim :. zdim))
+ (\_ -> (\(Z :. z :. y :. x) -> arr ! (Z :. x :. y :. z)))
+
+
+z_slice3 :: Elt a => Int -> Array DIM3 a -> Array DIM3 a
+z_slice3 n arr
+ | n == 0 = transpose_zx $ current R.++ next
+ | n == zdim-1 = transpose_zx $ previous R.++ current
+ | otherwise = transpose_zx $ previous R.++ current R.++ next
+ where
+ (Z :. zdim :. _ :. _) = extent arr
+ previous = transpose_zx $ reshape mri_slice3d (z_slice (n-1) arr)
+ current = transpose_zx $ reshape mri_slice3d (z_slice n arr)
+ next = transpose_zx $ reshape mri_slice3d (z_slice (n+1) arr)