From: Michael Orlitzky Date: Tue, 23 Aug 2011 16:54:19 +0000 (-0400) Subject: Add the Values module, wrapping the Repa stuff. X-Git-Tag: 0.0.1~232 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=5a878334c2ca29fcaf7b5e5c8c9700d866134a22;p=spline3.git Add the Values module, wrapping the Repa stuff. --- diff --git a/src/Main.hs b/src/Main.hs index 4b375cf..bc63265 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -2,33 +2,22 @@ module Main where import Data.Array.Repa ( - Array, - DIM1, DIM3, - Shape, Z(..), (:.)(..), - index, - reshape, toList ) -import Data.Array.Repa.IO.Vector (readVectorFromTextFile) - +import Values --import Grid(make_grid, zoom) - -read_mri_data :: IO (Array DIM1 Int) -read_mri_data = readVectorFromTextFile "./data/mridata.txt" - mri_shape :: DIM3 mri_shape = (Z :. 256 :. 256 :. 109) main :: IO () main = do - mridata <- read_mri_data - let mridata2 = reshape mri_shape mridata - let tmp = Data.Array.Repa.toList mridata2 + mridata <- read_values_3d mri_shape "./data/mridata.txt" + let tmp = Data.Array.Repa.toList mridata print tmp -- let g = make_grid 1 (Data.Array.Repa.toList mridata2) -- let output = zoom g 2 diff --git a/src/Values.hs b/src/Values.hs new file mode 100644 index 0000000..10d7fb9 --- /dev/null +++ b/src/Values.hs @@ -0,0 +1,24 @@ +module Values +where + +import Data.Array.Repa ( + Array, + DIM1, + DIM3, + reshape, + ) + +import Data.Array.Repa.IO.Vector (readVectorFromTextFile) +import System.FilePath () + + +type Values1D = Array DIM1 Double +type Values3D = Array DIM3 Double + +read_values_1d :: FilePath -> IO Values1D +read_values_1d path = readVectorFromTextFile path + +read_values_3d :: DIM3 -> FilePath -> IO Values3D +read_values_3d sh path = do + one_d <- read_values_1d path + return $ reshape sh one_d