From: Michael Orlitzky Date: Tue, 17 Apr 2012 01:31:41 +0000 (-0400) Subject: Make the minimum number of changes necessary to work with repa-3.1.1.1. Unfortunately... X-Git-Tag: 0.0.1~52 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=3544d15ebbd0176c9aac2fd0e0e94468abc56879;p=spline3.git Make the minimum number of changes necessary to work with repa-3.1.1.1. Unfortunately, to do so, we compute some things sequentially. --- diff --git a/src/Grid.hs b/src/Grid.hs index 26f4425..192bbaf 100644 --- a/src/Grid.hs +++ b/src/Grid.hs @@ -10,6 +10,7 @@ module Grid ( where import qualified Data.Array.Repa as R +import qualified Data.Array.Repa.Operators.Traversal as R (unsafeTraverse) import Test.HUnit (Assertion, assertEqual) import Test.Framework (Test, testGroup) import Test.Framework.Providers.HUnit (testCase) @@ -121,7 +122,7 @@ zoom :: Values3D -> ScaleFactor -> Values3D zoom v3d scale_factor | xsize == 0 || ysize == 0 || zsize == 0 = empty3d | otherwise = - R.compute $ R.unsafeTraverse v3d transExtent f + R.computeS $ R.unsafeTraverse v3d transExtent f where (xsize, ysize, zsize) = dims v3d transExtent = zoom_shape scale_factor diff --git a/src/MRI.hs b/src/MRI.hs index a246bf5..094991c 100644 --- a/src/MRI.hs +++ b/src/MRI.hs @@ -20,11 +20,13 @@ where import Data.Word import Data.Bits -import Data.Array.Repa as R -import Data.Array.Repa.Repr.Unboxed as R -import Data.Array.Repa.IO.Binary as R +import Data.Array.Repa as R +import Data.Array.Repa.Eval as R (now) +import Data.Array.Repa.Repr.Unboxed as R +import Data.Array.Repa.IO.Binary as R import Data.Array.Repa.Algorithms.ColorRamp as R -import Data.Array.Repa.IO.BMP as R (writeImageToBMP) +import Data.Array.Repa.Operators.Traversal as R (unsafeTraverse) +import Data.Array.Repa.IO.BMP as R (writeImageToBMP) import Values @@ -64,7 +66,7 @@ type ColorData sh = Array U sh RGB read_word16s :: FilePath -> IO RawData3D read_word16s path = do arr <- R.readArrayFromStorableFile path mri_shape - now $ R.copy arr + now $ R.copyS arr @@ -123,7 +125,7 @@ write_word16s = R.writeArrayToStorableFile values_to_colors :: (Shape sh) => (Values sh) -> (ColorData sh) values_to_colors arr = - R.compute $ R.map (truncate_rgb . ramp_it) arr + R.computeS $ R.map (truncate_rgb . ramp_it) arr where ramp_it :: Double -> (Double, Double, Double) ramp_it x = @@ -151,4 +153,4 @@ write_values_slice_to_bitmap v3d path = R.writeImageToBMP path colors where arr_bracketed = bracket_array v3d - colors = values_to_colors $ R.compute $ R.map fromIntegral arr_bracketed + colors = values_to_colors $ R.computeS $ R.map fromIntegral arr_bracketed diff --git a/src/Main.hs b/src/Main.hs index cfd1724..c1456f4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -34,9 +34,9 @@ main3d = do arr <- read_word16s in_file let arr' = swap_bytes arr let arrMRI = R.reshape mri_shape arr' - let dbl_data = R.compute $ R.map fromIntegral arrMRI + let dbl_data = R.computeS $ R.map fromIntegral arrMRI let output = zoom dbl_data zoom_factor - let word16_output = R.compute $ round_array output + let word16_output = R.computeS $ round_array output write_word16s out_file word16_output @@ -47,13 +47,13 @@ main2d = do let zoom_factor = (1, scale, scale) let out_file = "output.bmp" arr <- read_word16s in_file - let arrSlice = R.computeUnboxed $ z_slice 50 $ flip_x $ flip_y $ swap_bytes arr + let arrSlice = R.computeUnboxedS $ z_slice 50 $ flip_x $ flip_y $ swap_bytes arr let arrSlice' = R.reshape mri_slice3d arrSlice -- If zoom isn't being inlined we need to extract the slice before hand, -- and convert it to the require formed. - let dbl_data = R.compute $ R.map fromIntegral arrSlice' + let dbl_data = R.computeS $ R.map fromIntegral arrSlice' let output = zoom dbl_data zoom_factor - let arrSlice0 = R.computeUnboxed $ z_slice 0 output + let arrSlice0 = R.computeUnboxedS $ z_slice 0 output write_values_slice_to_bitmap arrSlice0 out_file