[ismrmrd] 27/281: Started work on test applications

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:00:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag ismrmrd0.5
in repository ismrmrd.

commit b8433d50a35f9b7867d105a8d82180503ad6918d
Author: Michael Hansen <michael.hansen at nih.gov>
Date:   Tue Sep 4 22:39:32 2012 -0400

    Started work on test applications
---
 CMakeLists.txt          | 10 ++++++
 cmake/FindFFTW3.cmake   | 93 +++++++++++++++++++++++++++++++++++++++++++++++++
 test_create_dataset.cpp | 68 ++++++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 31f8445..3eff982 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,10 +52,20 @@ ENDIF(WIN32)
 add_executable(ismrmrd_test main.cpp)
 target_link_libraries(ismrmrd_test ${XERCESC_LIBRARIES} ismrmrd)
 
+find_package(FFTW3 COMPONENTS single)
+IF(FFTW3_FOUND)
+	MESSAGE("FFTW3 Found, building test applications")
+	add_executable(ismrmrd_create_dataset test_create_dataset.cpp)
+	target_link_libraries(ismrmrd_create_dataset ${XERCESC_LIBRARIES} ismrmrd)
+ELSE(FFTW3_FOUND)
+	MESSAGE("FFTW3 NOT Found....cannot build test applications")
+ENDIF(FFTW3_FOUND)
+
 INSTALL(FILES ismrmrd.h ${XSDS_SOURCES} ismrmrd_hdf5.h ismrmrd_hdf5_datatypes.h ismrmrd_export.h DESTINATION include)
 INSTALL(FILES schema/ismrmrd.xsd DESTINATION schema)
 INSTALL(FILES cmake/FindIsmrmrd.cmake DESTINATION cmake)
 INSTALL(TARGETS ismrmrd DESTINATION lib)
 INSTALL(TARGETS ismrmrd_test DESTINATION bin)
+INSTALL(TARGETS ismrmrd_create_dataset DESTINATION bin)
 
 add_subdirectory(doc)
diff --git a/cmake/FindFFTW3.cmake b/cmake/FindFFTW3.cmake
new file mode 100644
index 0000000..eccfe9f
--- /dev/null
+++ b/cmake/FindFFTW3.cmake
@@ -0,0 +1,93 @@
+# - Try to find FFTW3.
+# Usage: find_package(FFTW3 [COMPONENTS [single double long-double threads]])
+#
+# Variables used by this module:
+#  FFTW3_ROOT_DIR             - FFTW3 root directory
+# Variables defined by this module:
+#  FFTW3_FOUND                - system has FFTW3
+#  FFTW3_INCLUDE_DIR          - the FFTW3 include directory (cached)
+#  FFTW3_INCLUDE_DIRS         - the FFTW3 include directories
+#                               (identical to FFTW3_INCLUDE_DIR)
+#  FFTW3[FL]?_LIBRARY         - the FFTW3 library - double, single(F), 
+#                               long-double(L) precision (cached)
+#  FFTW3[FL]?_THREADS_LIBRARY - the threaded FFTW3 library - double, single(F), 
+#                               long-double(L) precision (cached)
+#  FFTW3_LIBRARIES            - list of all FFTW3 libraries found
+
+# Copyright (C) 2009-2010
+# ASTRON (Netherlands Institute for Radio Astronomy)
+# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+#
+# This file is part of the LOFAR software suite.
+# The LOFAR software suite is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# The LOFAR software suite is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
+#
+# $Id: FindFFTW3.cmake 15918 2010-06-25 11:12:42Z loose $
+
+# Use double precision by default.
+if(FFTW3_FIND_COMPONENTS MATCHES "^$")
+  set(_components double)
+else()
+  set(_components ${FFTW3_FIND_COMPONENTS})
+endif()
+
+# Loop over each component.
+set(_libraries)
+foreach(_comp ${_components})
+  if(_comp STREQUAL "single")
+    list(APPEND _libraries fftw3f)
+  elseif(_comp STREQUAL "double")
+    list(APPEND _libraries fftw3)
+  elseif(_comp STREQUAL "long-double")
+    list(APPEND _libraries fftw3l)
+  elseif(_comp STREQUAL "threads")
+    set(_use_threads ON)
+  else(_comp STREQUAL "single")
+    message(FATAL_ERROR "FindFFTW3: unknown component `${_comp}' specified. "
+      "Valid components are `single', `double', `long-double', and `threads'.")
+  endif(_comp STREQUAL "single")
+endforeach(_comp ${_components})
+
+# If using threads, we need to link against threaded libraries as well.
+if(_use_threads)
+  set(_thread_libs)
+  foreach(_lib ${_libraries})
+    list(APPEND _thread_libs ${_lib}_threads)
+  endforeach(_lib ${_libraries})
+  set(_libraries ${_thread_libs} ${_libraries})
+endif(_use_threads)
+
+# Keep a list of variable names that we need to pass on to
+# find_package_handle_standard_args().
+set(_check_list)
+
+# Search for all requested libraries.
+foreach(_lib ${_libraries})
+  string(TOUPPER ${_lib} _LIB)
+  find_library(${_LIB}_LIBRARY ${_lib}
+    HINTS ${FFTW3_ROOT_DIR} PATH_SUFFIXES lib)
+  mark_as_advanced(${_LIB}_LIBRARY)
+  list(APPEND FFTW3_LIBRARIES ${${_LIB}_LIBRARY})
+  list(APPEND _check_list ${_LIB}_LIBRARY)
+endforeach(_lib ${_libraries})
+
+# Search for the header file.
+find_path(FFTW3_INCLUDE_DIR fftw3.h 
+  HINTS ${FFTW3_ROOT_DIR} PATH_SUFFIXES include)
+mark_as_advanced(FFTW3_INCLUDE_DIR)
+list(APPEND _check_list FFTW3_INCLUDE_DIR)
+
+# Handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(FFTW3 DEFAULT_MSG ${_check_list})
diff --git a/test_create_dataset.cpp b/test_create_dataset.cpp
new file mode 100644
index 0000000..aa051c0
--- /dev/null
+++ b/test_create_dataset.cpp
@@ -0,0 +1,68 @@
+/*
+ * test_create_dataset.cpp
+ *
+ *  Created on: Sep 4, 2012
+ *      Author: Michael S. Hansen (michael.hansen at nih.gov)
+ */
+
+#include <iostream>
+#include "ismrmrd_hdf5.h"
+
+using namespace ISMRMRD;
+
+template <typename T, int size_x, int size_y> int appendImageArray(IsmrmrdDataset& d, const char* varname)
+{
+	T a[size_x*size_y];
+	std::vector<unsigned int> dims(2,0);
+	dims[0] = size_x;
+	dims[1] = size_y;
+
+	//Let's make a simple square (rectangle depending on dimensions)
+	for (int y = 0; y < size_y; y++) {
+		for (int x = 0; x < size_x; x++) {
+			if ( (x > (size_x>>2)) && (x < (size_x-(size_x>>2))) &&
+				 (y > (size_y>>3)) && (y < (size_y-(size_y>>3)))) {
+				a[y*size_x + x] = 1.0;
+			} else {
+				a[y*size_x + x] = 0.0;
+			}
+		}
+	}
+
+	NDArrayContainer<T> tmp(dims,a);
+
+	return d.appendArray(tmp, varname);
+}
+
+
+int main(int argc, char** argv)
+{
+	std::cout << "ISMRMRD Test Dataset Creation App" << std::endl;
+
+	IsmrmrdDataset d("testdata.h5","dataset");
+
+	//Let's create the "original" image in the file for reference
+	if (appendImageArray< std::complex<float>, 256, 128 >(d, "the_square") < 0) {
+		std::cout << "Error adding image to dataset" << std::endl;
+		return -1;
+	}
+
+	//Read it back from the file
+	boost::shared_ptr< NDArrayContainer<std::complex<float> > > img_test =
+			d.readArray< std::complex<float> >("the_square", 0);
+
+	if (img_test.get() == 0) {
+		std::cout << "Error reading image array from file" << std::endl;
+		return -1;
+	}
+
+	std::cout << "Image Array dimensions: ";
+	for (int di = 0; di < img_test->dimensions_.size(); di++) {
+		std::cout << img_test->dimensions_[di] << " ";
+	}
+	std::cout << std::endl;
+
+	return 0;
+}
+
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ismrmrd.git



More information about the debian-science-commits mailing list