From 97117af7a6b89e64b84ac0d1a74734dd6ee9fa6c Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 14 Sep 2011 09:30:44 -0400 Subject: [PATCH] Add transpose_zx and z_slice3 functions to MRI. --- src/MRI.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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) -- 2.43.2