From: Michael Orlitzky Date: Wed, 14 Sep 2011 13:30:44 +0000 (-0400) Subject: Add transpose_zx and z_slice3 functions to MRI. X-Git-Tag: 0.0.1~135 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=97117af7a6b89e64b84ac0d1a74734dd6ee9fa6c;p=spline3.git Add transpose_zx and z_slice3 functions to MRI. --- diff --git a/src/MRI.hs b/src/MRI.hs index 2dd6f65..52be3f7 100644 --- a/src/MRI.hs +++ b/src/MRI.hs @@ -139,3 +139,22 @@ blue_dbl_data = 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)