[ismrmrd] 25/177: Reorganized examples. All examples should be standalone.

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


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

ghisvail-guest pushed a commit to annotated tag v1.1.0.beta.1
in repository ismrmrd.

commit 0439910dd9f017a45a975b4ca0b2d7e460ab2243
Author: Souheil Inati <souheil.inati at nih.gov>
Date:   Tue Aug 26 11:09:51 2014 -0400

    Reorganized examples.  All examples should be standalone.
---
 CMakeLists.txt                               |   9 +-
 cmake/FindIsmrmrd.cmake                      |  15 +--
 examples/c++/CMakeLists-Standalone.txt       |  43 -------
 examples/c++/CMakeLists.txt                  |  19 ++-
 examples/c++/cmake/FindFFTW3.cmake           |  93 --------------
 examples/c++/cmake/FindIsmrmrd.cmake         |  29 -----
 examples/c/CMakeLists.txt                    |  19 ++-
 examples/c/README.txt                        |  11 ++
 examples/matlab/old/ismrmrd_header2struct.m  |  25 ----
 examples/matlab/old/simple_cartesian_recon.m | 127 -------------------
 examples/matlab/old/simple_gridder.m         | 100 ---------------
 examples/matlab/old/simple_spiral_recon.m    |  78 ------------
 examples/matlab/old/testsynth.m              |  85 -------------
 examples/matlab/old/xml2struct.m             | 183 ---------------------------
 examples/matlab/todo.txt                     |   1 +
 tests/CMakeLists.txt                         |   6 +-
 {xml => tests/xml}/CMakeLists.txt            |   0
 {xml => tests/xml}/test_meta.cpp             |   0
 {xml => tests/xml}/test_xml.cpp              |   0
 19 files changed, 53 insertions(+), 790 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cae7cc..19d40b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,9 +7,6 @@ set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/ismrmrd)
 # add project specific cmake find modules
 list(APPEND CMAKE_MODULE_PATH cmake)
 
-# enable ctest
-enable_testing()
-
 # set the build type to Release if not specified
 IF(NOT CMAKE_BUILD_TYPE)
   SET(CMAKE_BUILD_TYPE Release CACHE STRING
@@ -73,11 +70,11 @@ install(FILES
     cmake/FindNumPy.cmake
     DESTINATION cmake)
 
+# copy the examples directory
+install(DIRECTORY examples DESTINATION .)
+
 #add_subdirectory(doc)
-add_subdirectory(examples/c)
-add_subdirectory(examples/c++)
 #add_subdirectory(utilities)
 #add_subdirectory(tests)
 #add_subdirectory(matlab)
 #add_subdirectory(bindings)
-add_subdirectory(xml)
diff --git a/cmake/FindIsmrmrd.cmake b/cmake/FindIsmrmrd.cmake
index af38720..649fbaf 100644
--- a/cmake/FindIsmrmrd.cmake
+++ b/cmake/FindIsmrmrd.cmake
@@ -2,16 +2,11 @@
 #   ISMRMRD_FOUND            - true if an ISMRMRD installation is found.
 #   ISMRMRD_INCLUDE_DIR      - where to find ismrmrd.h, etc.
 #   ISMRMRD_LIBRARIES        - libismrmrd.so and libismrmrd_xml.so
-#   ISMRMRD_XSD_INCLUDE_DIR  - folder containing ismrmrd.hxx (autogenerated from xsd schema)
-#   ISMRMRD_XSD_SOURCE       - full path to ismrmrd.cxx (autogenerated from xsd schema)
 #   ISMRMRD_SCHEMA_DIR       - where to find ismrmrd.xsd       
 
 FIND_PATH( ISMRMRD_INCLUDE_DIR ismrmrd.h 
 HINTS $ENV{ISMRMRD_HOME} PATHS /usr/local /usr PATH_SUFFIXES include ismrmrd ismrmrd/include)
 
-FIND_PATH( ISMRMRD_XSD_INCLUDE_DIR ismrmrd.hxx
-HINTS $ENV{ISMRMRD_HOME} PATHS /usr/local /usr PATH_SUFFIXES schema ismrmrd ismrmrd/schema)
-
 FIND_PATH( ISMRMRD_SCHEMA_DIR ismrmrd.xsd 
 HINTS $ENV{ISMRMRD_HOME} PATHS /usr/local /usr PATH_SUFFIXES schema ismrmrd ismrmrd/schema)
 
@@ -19,15 +14,7 @@ FIND_LIBRARY( ISMRMRD_LIBRARY
               NAMES ismrmrd
               PATHS  /usr/local/lib ${ISMRMRD_INCLUDE_DIR}/../lib /usr/lib )
 
-FIND_LIBRARY( ISMRMRD_XML_LIBRARY
-              NAMES ismrmrd_xml
-              PATHS  /usr/local/lib ${ISMRMRD_INCLUDE_DIR}/../lib /usr/lib )
-
-SET(ISMRMRD_LIBRARIES ${ISMRMRD_LIBRARY} ${ISMRMRD_XML_LIBRARY})
-
-FIND_FILE( ISMRMRD_XSD_SOURCE
-           NAMES "ismrmrd.cxx"
-           HINTS $ENV{ISMRMRD_HOME} PATHS /usr/local /usr PATH_SUFFIXES schema ismrmrd ismrmrd/schema)
+SET(ISMRMRD_LIBRARIES ${ISMRMRD_LIBRARY})
 
 INCLUDE( "FindPackageHandleStandardArgs" )
 FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Ismrmrd" DEFAULT_MSG ISMRMRD_INCLUDE_DIR ISMRMRD_LIBRARIES ISMRMRD_SCHEMA_DIR)
diff --git a/examples/c++/CMakeLists-Standalone.txt b/examples/c++/CMakeLists-Standalone.txt
deleted file mode 100644
index dbf50bc..0000000
--- a/examples/c++/CMakeLists-Standalone.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-project(ISMRMRD_EXAMPLES)
-
-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-
-if (WIN32)
-ADD_DEFINITIONS(-DWIN32 -D_WIN32 -D_WINDOWS)
-ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
-ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
-SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
-SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
-endif (WIN32)
-
-set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/ismrmrd)
-
-find_package(Ismrmrd REQUIRED)
-find_package(FFTW3 COMPONENTS single REQUIRED)
-
-include_directories (
-    ${CMAKE_CURRENT_SOURCE_DIR}
-    ${ISMRMRD_INCLUDE_DIR}
-    ${FFTW3_INCLUDE_DIR}
-)
-
-add_executable(ismrmrd_create_dataset test_create_dataset.cpp)
-target_link_libraries(
-    ismrmrd_create_dataset
-    ${ISMRMRD_LIBRARIES}
-    ${ISMRMRD_XSD_LIBRARIES}
-    ${FFTW3_LIBRARIES}
-)
-INSTALL(TARGETS ismrmrd_create_dataset DESTINATION bin)
-
-add_executable(ismrmrd_recon_dataset test_recon_dataset.cpp)
-target_link_libraries(
-    ismrmrd_recon_dataset
-    ${ISMRMRD_LIBRARIES}
-    ${ISMRMRD_XSD_LIBRARIES}
-    ${FFTW3_LIBRARIES}
-)
-INSTALL(TARGETS ismrmrd_recon_dataset DESTINATION bin)
-
-
diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt
index be36a04..ee1f6a6 100644
--- a/examples/c++/CMakeLists.txt
+++ b/examples/c++/CMakeLists.txt
@@ -1,7 +1,20 @@
-add_executable(ismrmrd_basic_test basic_test.cpp)
-target_link_libraries(ismrmrd_basic_test ismrmrd)
+cmake_minimum_required(VERSION 2.8)
+project(ISMRMRD_C++_EXAMPLES)
+
+if (NOT DEFINED ENV{ISMRMRD_HOME})
+    message(FATAL_ERROR "Environment variable $ISMRMRD_HOME not set")
+endif()
+# for finding Ismrmrd
+list (APPEND CMAKE_MODULE_PATH "$ENV{ISMRMRD_HOME}/cmake")
+
+find_package(Ismrmrd REQUIRED)
 
-install(TARGETS ismrmrd_basic_test DESTINATION bin)
+include_directories (
+    ${ISMRMRD_INCLUDE_DIR}
+)
+
+add_executable(ismrmrd_basic_test basic_test.cpp)
+target_link_libraries(ismrmrd_basic_test ${ISMRMRD_LIBRARIES})
 
 #find_package(FFTW3 COMPONENTS single)
 #if(FFTW3_FOUND)
diff --git a/examples/c++/cmake/FindFFTW3.cmake b/examples/c++/cmake/FindFFTW3.cmake
deleted file mode 100644
index eccfe9f..0000000
--- a/examples/c++/cmake/FindFFTW3.cmake
+++ /dev/null
@@ -1,93 +0,0 @@
-# - 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/examples/c++/cmake/FindIsmrmrd.cmake b/examples/c++/cmake/FindIsmrmrd.cmake
deleted file mode 100644
index 3defaf4..0000000
--- a/examples/c++/cmake/FindIsmrmrd.cmake
+++ /dev/null
@@ -1,29 +0,0 @@
-# - Find ISMRMRRD
-#   ISMRMRD_FOUND        - True if ISMRMRD found.
-#   ISMRMRD_INCLUDE_DIR  - where to find ismrmrd.h, etc.
-#   ISMRMRD_LIBRARIES    - libismrmrd.so.
-#   ISMRMRD_XSD_LIBRARIES    - libismrmrd.so.
-#   ISMRMRD_SCHEMA_DIR   - Where to find ismrmrd.xsd
-
-FIND_PATH( ISMRMRD_INCLUDE_DIR ismrmrd.h
-    HINTS $ENV{ISMRMRD_HOME}
-    PATHS /usr/local/ /usr/include /usr/local/include
-    PATH_SUFFIXES ismrmrd ismrmrd/include include)
-
-FIND_PATH( ISMRMRD_SCHEMA_DIR ismrmrd.xsd
-    HINTS $ENV{ISMRMRD_HOME}
-    PATHS /usr/local/ /usr/include /usr/local/include
-    PATH_SUFFIXES ismrmrd ismrmrd/schema schema)
-
-FIND_LIBRARY( ISMRMRD_LIBRARIES
-              NAMES "ismrmrd"
-              PATHS  /usr/local/lib ${ISMRMRD_INCLUDE_DIR}/../lib /usr/lib )
-
-FIND_LIBRARY( ISMRMRD_XSD_LIBRARIES
-              NAMES "ismrmrd_xsd"
-              PATHS  /usr/local/lib ${ISMRMRD_INCLUDE_DIR}/../lib /usr/lib )
-
-INCLUDE( "FindPackageHandleStandardArgs" )
-FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Ismrmrd" DEFAULT_MSG ISMRMRD_INCLUDE_DIR ISMRMRD_LIBRARIES ISMRMRD_SCHEMA_DIR)
-
-MARK_AS_ADVANCED( ISMRMRD_INCLUDE_DIR ISMRMRD_LIBRARIES ISMRMRD_SCHEMA_DIR)
diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt
index 0228828..2325fbf 100644
--- a/examples/c/CMakeLists.txt
+++ b/examples/c/CMakeLists.txt
@@ -1,4 +1,17 @@
-add_executable(ismrmrd_c_demo main.c)
-target_link_libraries(ismrmrd_c_demo ismrmrd)
+cmake_minimum_required(VERSION 2.8)
+project(ISMRMRD_C_EXAMPLE)
+
+if (NOT DEFINED ENV{ISMRMRD_HOME})
+    message(FATAL_ERROR "Environment variable $ISMRMRD_HOME not set")
+endif()
+# for finding Ismrmrd
+list (APPEND CMAKE_MODULE_PATH "$ENV{ISMRMRD_HOME}/cmake")
+
+find_package(Ismrmrd REQUIRED)
 
-install(TARGETS ismrmrd_c_demo DESTINATION bin)
+include_directories (
+    ${ISMRMRD_INCLUDE_DIR}
+)
+
+add_executable(ismrmrd_c_demo main.c)
+target_link_libraries(ismrmrd_c_demo ${ISMRMRD_LIBRARIES})
diff --git a/examples/c/README.txt b/examples/c/README.txt
new file mode 100644
index 0000000..e430630
--- /dev/null
+++ b/examples/c/README.txt
@@ -0,0 +1,11 @@
+This is an example of a simple C project that is built on ISMRMRD.
+
+Instructions for building:
+1. Install ISMRMRD
+2. Define the environment variable ISMRMRD_HOME,
+   e.g. ISMRMRD_HOME=/usr/local/ismrmrd
+3. In a directory of your choosing:
+   mkdir buildcdemo
+   cmake ${ISMRMRD_HOME}/examples/c
+   make
+   ./ismrmrd_c_demo
\ No newline at end of file
diff --git a/examples/matlab/old/ismrmrd_header2struct.m b/examples/matlab/old/ismrmrd_header2struct.m
deleted file mode 100644
index 34e2370..0000000
--- a/examples/matlab/old/ismrmrd_header2struct.m
+++ /dev/null
@@ -1,25 +0,0 @@
-function s = ismrmrd_header2struct(header)
-%
-%
-%  s = ismrmrd_header2struct(header)
-%
-%  Converts and ISMRMRD xml header to a struct.
-%
-
-    if (iscell(header)),
-        header_string = header{1};
-    else
-        header_string = header;
-    end
-
-    if (ischar(header_string) < 1),
-        error('Malformed input header. Is not a character string.');
-    end
-
-    tmp_nam = tempname;
-    f=fopen(tmp_nam,'w');
-    fwrite(f,header_string);
-    fclose(f);
-
-    s = xml2struct(tmp_nam);
-return
\ No newline at end of file
diff --git a/examples/matlab/old/simple_cartesian_recon.m b/examples/matlab/old/simple_cartesian_recon.m
deleted file mode 100644
index 08913f7..0000000
--- a/examples/matlab/old/simple_cartesian_recon.m
+++ /dev/null
@@ -1,127 +0,0 @@
-function [images] = simple_cartesian_recon(ismrmrdfile, dataset)
-%
-%   [images] = simple_cartesian_recon(ismrmrdfile, dataset)
-%
-%   Simple example of how to reconstruct a 2D/3D cartesian dataset stored
-%   in ISMRMRD dataformat. Reconstruction handles partial fourier,
-%   oversampling, etc. 
-%
-%   Michael S. Hansen (michael.hansen at nih.gov), 2012
-%   Souheil J. Inati  (souheil.inati at nih.gov),  2013
-%
-%   Usage notes:
-%     ismrmrdfile: string, required.
-%     dataset:     string, optional, default='dataset'
-%
-
-switch nargin
-    case 1
-        dset = 'dataset';
-    case 2
-        dset = dataset;
-    otherwise
-        error('Wrong number of input arguments.')
-end
-
-% Open the dataset
-f = ismrmrd.IsmrmrdDataset(ismrmrdfile, dset);
-
-% Is this a cartesian acquisition
-traj = f.xmlhdr.getEncoding.get(0).getTrajectory();
-if (~traj.equals(traj.CARTESIAN))
-   error('This is not a cartesian dataset'); 
-end
-
-% Get the matrix sizes and the number of slices and channels
-matrix_size = [f.xmlhdr.getEncoding.get(0).getEncodedSpace.getMatrixSize.getX, ...
-               f.xmlhdr.getEncoding.get(0).getEncodedSpace.getMatrixSize.getY, ...
-               f.xmlhdr.getEncoding.get(0).getEncodedSpace.getMatrixSize.getZ];
-
-recon_size = [f.xmlhdr.getEncoding.get(0).getReconSpace.getMatrixSize.getX, ...
-              f.xmlhdr.getEncoding.get(0).getReconSpace.getMatrixSize.getY, ...
-              f.xmlhdr.getEncoding.get(0).getReconSpace.getMatrixSize.getZ];
-
-if ~isempty(f.xmlhdr.getEncoding.get(0).getEncodingLimits.getSlice)
-    slices = f.xmlhdr.getEncoding.get(0).getEncodingLimits.getSlice;
-else
-    slices = 1;
-end
-
-channels = f.xmlhdr.getAcquisitionSystemInformation.getReceiverChannels.doubleValue;
-
-
-% Get the encoding centers
-center_line = f.xmlhdr.getEncoding.get(0).getEncodingLimits.getKspaceEncodingStep1.getCenter;
-if (matrix_size(3) > 1)
-    % 3D
-    center_partition = f.xmlhdr.getEncoding.get(0).getEncodingLimits.getKspaceEncodingStep2.getCenter;
-else
-    % 2D
-    center_partition = 0;
-end
-
-% Allocate a buffer for storing 1 repetition's worth of data
-buffer = zeros([matrix_size(1),matrix_size(2),matrix_size(3),slices,channels],'single');
-
-% Initalize the output
-images = [];
-
-% read all the acquisitions
-acq = f.readAcquisition();
-
-% Loop over all the acquisitions
-counter = 0;
-for p = 1:acq.getNumber()
-    
-    % ignore the noise scans
-    if acq.head.flagIsSet(acq.head.FLAGS.ACQ_IS_NOISE_MEASUREMENT,p)
-        continue
-    end
-
-    % stuff the data in the buffer
-    line_number      = int32(acq.head.idx.kspace_encode_step_1(p)) - center_line + matrix_size(2)/2 + 1;
-    if matrix_size(3) > 1
-        partition_number = int32(acq.head.idx.kspace_encode_step_2(p)) - center_partition + matrix_size(3)/2 + 1;
-    else
-        partition_number = 1;
-    end
-    slice_number     = acq.head.idx.slice(p) + 1;
-    buffer(:,line_number,partition_number,slice_number,:) = acq.data{p};
-    
-    % Is this the last in slice? We should make an image
-    if acq.head.flagIsSet(acq.head.FLAGS.ACQ_LAST_IN_SLICE,p)
-        counter = counter + 1;
-        fprintf('Reconstructing image %d\n', counter); 
-        fprintf('   slice: %d\n', slice_number); 
-        fprintf('   rep:   %d\n', acq.head.idx.repetition(p)+1); 
-
-        % FFT
-        img = fftshift(ifft(ifftshift(buffer(:,:,:,slice_number,:)),[],1)) ./ sqrt(size(buffer,1));
-        img = fftshift(ifft(ifftshift(img),[],2)) ./ sqrt(size(img,2));
-        if (matrix_size(3) > 1), 
-            img = fftshift(ifft(ifftshift(img),[],3)) ./ sqrt(size(img,3));
-        end
-
-        % Handle over-sampling
-        if matrix_size(3) > 1
-            img = img((1:recon_size(1)) + (matrix_size(1)-recon_size(1))/2, ...
-                      (1:recon_size(2)) + (matrix_size(2)-recon_size(2))/2, ...
-                      (1:recon_size(3)) + (matrix_size(3)-recon_size(3))/2, :);
-        else
-            img = img((1:recon_size(1)) + (matrix_size(1)-recon_size(1))/2, ...
-                      (1:recon_size(2)) + (matrix_size(2)-recon_size(2))/2, ...
-                      1, :);
-        end
-
-        % RMS coil combination
-        img = sqrt(sum(abs(img).^2,4));
-        
-        % Append to the output buffer
-        images(:,:,:,counter) = img;
-    end
-
-end
-fprintf('done\n'); 
-
-% Display the middle slice image
-% imagesc(images(:,:,bitshift(size(images,3),-1)+1, 1));colormap(gray);axis image;
diff --git a/examples/matlab/old/simple_gridder.m b/examples/matlab/old/simple_gridder.m
deleted file mode 100644
index cb65fb5..0000000
--- a/examples/matlab/old/simple_gridder.m
+++ /dev/null
@@ -1,100 +0,0 @@
-function img = simple_gridder(co,data,weight,matrix_size)
-%
-%   img = simple_gridder(co,data,weight,matrix_size)
-%
-%   A very simple gridder written purely in Matlab. 
-%   Only tested for 2D
-%
-%   Input arguments:
-%     - co [N,2], k-space coordinates in the range [-0.5:0.5]
-%     - data, vector of N complex data points
-%     - weight, vector of N data weights (density compensation)
-%     - matrix_size, 2-element vector, e.g. [128 128]
-%
-%   Michael S. Hansen (michael.hansen at nih.gov), 2012
-%
-%
-
-over_sampling = 2.0;
-kernel_width = 8;
-kernel_samples = 100000;
-kernel_beta = 18.5547;
-matrix_size_oversampled = matrix_size*over_sampling;
-
-kernel_table = 1.0-(2.0*[-bitshift(kernel_samples,-1):(bitshift(kernel_samples,-1)-1)]/kernel_samples).^2;
-
-kernel_table(kernel_table<0) = 0;
-kernel_table=sqrt(kernel_table);
-kernel_table = bessi0(kernel_beta .* kernel_table);
-knorm = sum(kernel_table(:))/numel(kernel_table);
-kernel_table = kernel_table ./ knorm;
-
-grid_cells = ceil(co .* repmat(matrix_size_oversampled,size(co,1),1)-(kernel_width/2));
-kernel_idx = grid_cells-(co .* repmat(matrix_size_oversampled,size(co,1),1));
-grid_cells = uint32(grid_cells+repmat(bitshift(matrix_size_oversampled+kernel_width,-1),size(co,1),1));
-kernel_idx = uint32(floor(((kernel_idx + kernel_width/2)/kernel_width)*kernel_samples));
-kernel_step = uint32(floor(kernel_samples/kernel_width));
-
-%Calculate deapodization
-kern = -bitshift(kernel_width,-1):(-bitshift(kernel_width,-1)+kernel_width-1);
-kern = 1.0-(2.0*kern/kernel_width).^2;
-kern = bessi0(kernel_beta .* kern);
-kern = repmat(kern,kernel_width,1) .* repmat(kern',1,kernel_width);
-deapodization = zeros(matrix_size_oversampled);
-deapodization((1:kernel_width) + bitshift(matrix_size_oversampled(1)-kernel_width,-1), ...
-              (1:kernel_width) + bitshift(matrix_size_oversampled(2)-kernel_width,-1)) = kern;  
-deapodization = fftshift(ifftn(ifftshift(deapodization))) ./ sqrt(numel(deapodization));
-
-%Do convolution
-oversampled_grid_padded = zeros(matrix_size_oversampled+kernel_width);
-for y=1:(kernel_width),
-    for x=1:(kernel_width),       
-        oversampled_grid_padded = oversampled_grid_padded + ...
-            accumarray([grid_cells(:,1)+(x-1),grid_cells(:,2)+(y-1)], ...
-            weight(:).*data(:).*(kernel_table(kernel_idx(:,1)+(x-1)*kernel_step+1).*kernel_table(kernel_idx(:,2)+(y-1).*kernel_step+1))', ...
-            matrix_size_oversampled+kernel_width);
-    end
-end
-
-osps = size(oversampled_grid_padded);
-oss = matrix_size_oversampled;
-
-%Let's just get rid of the padding, it should really be folded in
-oversampled_grid = oversampled_grid_padded(bitshift(osps(1)-oss(1),-1):bitshift(osps(1)-oss(1),-1)+matrix_size_oversampled(1)-1, ...
-                                           bitshift(osps(2)-oss(2),-1):bitshift(osps(1)-oss(2),-1)+matrix_size_oversampled(2)-1); 
-
-%FFT to image space                                       
-img = fftshift(ifftn(ifftshift(oversampled_grid))) ./ sqrt(numel(oversampled_grid));
-
-%Deapodization
-img = img ./ deapodization;
-
-%Remove oversampling
-img = img((1:matrix_size(1))+bitshift(matrix_size_oversampled(1)-matrix_size(1),-1), ...
-          (1:matrix_size(2))+bitshift(matrix_size_oversampled(2)-matrix_size(2),-1));
-
-%TODO
-% - fold padding back in
-
-return
-
-function ans = bessi0(x)
-
-ax = abs(x);
-ans = zeros(size(x));
-
-% ax<3.75
-k = find(ax<3.75);
-y=x(k)./3.75;
-y=y.^2;
-ans(k)=1.0+y.*(3.5156229+y.*(3.0899424+y.*(1.2067492 ...
-    +y.*(0.2659732+y.*(0.360768e-1+y.*0.45813e-2)))));
-
-% ax>=3.75
-k = find(ax>=3.75);
-y=3.75./ax(k);
-ans(k)=(exp(ax(k))./sqrt(ax(k))).*(0.39894228+y.*(0.1328592e-1 ...
-    +y.*(0.225319e-2+y.*(-0.157565e-2+y.*(0.916281e-2 ...
-    +y.*(-0.2057706e-1+y.*(0.2635537e-1+y.*(-0.1647633e-1 ...
-    +y.*0.392377e-2))))))));
-return
\ No newline at end of file
diff --git a/examples/matlab/old/simple_spiral_recon.m b/examples/matlab/old/simple_spiral_recon.m
deleted file mode 100644
index 3815580..0000000
--- a/examples/matlab/old/simple_spiral_recon.m
+++ /dev/null
@@ -1,78 +0,0 @@
-function [images] = simple_spiral_recon(ismrmrdfile)
-%
-%   [images] = simple_spiral_recon(ismrmrdfile)
-%
-%   Simple example of how to reconstruct a 2D spiral dataset stored
-%   in ISMRMRD dataformat
-%
-%   Michael S. Hansen (michael.hansen at nih.gov), 2012
-%
-
-header = ismrmrd_header2struct(h5read(ismrmrdfile,'/dataset/xml'));
-
-%Is this a spiral acquisition
-if (~strcmp(header.ismrmrdHeader.encoding.trajectory.Text,'spiral')),
-   error('This is not a spiral dataset'); 
-end
-
-%Let's get the matrix size
-matrix_size = [str2num(header.ismrmrdHeader.encoding.encodedSpace.matrixSize.x.Text), ...
-               str2num(header.ismrmrdHeader.encoding.encodedSpace.matrixSize.y.Text)];
-
-%Let's load the data
-raw_data = h5read(ismrmrdfile,'/dataset/data');
-
-interleaves = max(raw_data.head.idx.kspace_encode_step_1)+1;
-repetitions = max(raw_data.head.idx.repetition)+1;
-samples = max(raw_data.head.number_of_samples);
-samples_to_skip_end = max(raw_data.head.discard_post);
-samples_to_skip_start = max(raw_data.head.discard_pre);
-net_samples = samples-samples_to_skip_end-samples_to_skip_start;
-channels = max(raw_data.head.active_channels);
-
-trajectory = zeros(2,net_samples,interleaves);
-data = zeros(net_samples,interleaves,channels);
-
-images = [];
-
-counter = 0;
-for p=1:length(raw_data.head.flags),
-
-   if (bitget(uint64(raw_data.head.flags(p)),19)), %if this is noise, we will skip it
-      continue; 
-   end
-   
-   d = reshape(complex(raw_data.data{p}(1:2:end), raw_data.data{p}(2:2:end)), samples, channels);
-   t = reshape(raw_data.traj{p}, raw_data.head.trajectory_dimensions(p), samples);
-   current_interleave = raw_data.head.idx.kspace_encode_step_1(p)+1;
-   start_sample = samples_to_skip_start+1;
-   end_sample = samples-samples_to_skip_end;
-
-   data(:,current_interleave,:) = reshape(d(start_sample:end_sample,:), net_samples, 1, channels);
-   trajectory(:,:,current_interleave) = t(:,start_sample:end_sample);
-   
-   if (bitget(uint64(raw_data.head.flags(p)),8)), %Is this the last in slice? We should make an image
-      fprintf('Reconstructing image %d....', counter+1); 
-      co = permute(trajectory(:,:),[2 1]);
-
-      %Some simple density compensation
-      k = complex(co(:,1),co(:,2));
-      g = complex(diff(co(:,1)),diff(co(:,2)));
-      g(end+1) = g(end);
-      weights = abs(g(:)) .* abs(sin(angle(g(:))-angle(k(:)))); %Estimating weights from Meyer et al. Magn Reson Med. 1992 Dec;28(2):202-13.
-      
-      %Loop over coils and grid images
-      for c=1:size(data,3), 
-           img(:,:,c) = simple_gridder(co,data(:,:,c),weights, matrix_size); 
-      end;
-      images(:,:,counter+1) = sqrt(sum(abs(img).^2,3)); %RMS coil combination
-      counter = counter + 1;
-      fprintf('done\n'); 
-   end
-   
-end
-
-%Let's just display the first image
-imagesc(images(:,:,1));colormap(gray);axis image;
-
-return
diff --git a/examples/matlab/old/testsynth.m b/examples/matlab/old/testsynth.m
deleted file mode 100644
index ee8ed5c..0000000
--- a/examples/matlab/old/testsynth.m
+++ /dev/null
@@ -1,85 +0,0 @@
-%% ISMRM Raw Data Matlab Interface
-% Tutorial introduction to the MATLAB interface of the ISMRM Raw Data
-% file format.
-
-%% Overview
-% For a detailed description of the ISMRM Raw Data file format, please
-% consult the documentation on the project home page:
-% <http://ismrmrd.sourceforge.com>
-%
-% The ISMRM Raw Data Matlab interface is distributed as a package folder
-% (+ismrmrd) containing a set of Matlab classes and functions and a Java
-% interface to the XML header.
-%
-% Install the package folder and add it to your Matlab path.
-% Change the path below to match your install location.
-%addpath('/usr/local/ismrmd/matlab');
-
-%% Creating an ISMRMRD file with synthetic data
-%
-
-% A simulated object: a square in the middle of an image with value 1.
-nx = 256; ny = 256;
-rho = zeros(nx,ny,'single');
-rho(nx/4+1:3*nx/4,ny/4+1:3*ny/4) = 1;
-
-% The synthetic k-space signal from a conventional evenly sampled MR experiment
-kdata = fftshift(fft2(fftshift(rho)));
-
-% Create a new ISMRMRD file
-g = ismrmrd.file('synthetic.h5');
-
-% Construct the XML header
-
-% Write the XML header
-g.writexml(xmlhdr);
-
-% Initialize the acquisition object
-acq = ismrmrd.Acquisition;
-acq.head.available_channels = 1;
-acq.head.active_channels = 1;
-acq.head.number_of_samples = nx;
-acq.head.center_sample = nx/2;
-
-% Loop over the acquisitions, set the looping variables, 
-% stuff the data, and append.  For this example, read ky from top to bottom.
-for p = ny:-1:1
-    acq.head.idx.kspace_encode_step_1 = p-1;
-    acq.data = kdata(:,p);
-    f.appendAcquisition(acq);
-end
-
-% close
-f.close();
-
-%% Reconstruct an image from an existing ISMRMRD file
-%
-% Open the ISMRMRD file
-g = ismrmrd.file(synthfile);
-
-% Read the XML header
-xml = g.readxml();
-
-% Read the number of acquisitions
-nky = g.getNumberOfAcquisitions();
-
-% Read the first acquisition
-acq1 = g.readAcquisition(1);
-nx = acq1.head.number_of_samples;
-
-% Loop over the acquisitions and read them in
-% stuffing into the correct part of the k-space data array
-kdata = zeros(nx,nky);
-for p = 1:nky
-    acq = f.readAcquisition(p);
-    kdata(:,acq.head.idx.kspace_encode_step_1+1) = acq.data;
-end
-
-% Simple reconstruction
-rhohat = fftshift(ifft2(fftshift(kdata)));
-
-imagesc(abs(rhohat)); axis image; axis off; colorbar
-title('Reconstructed image');
-
-% close the original dataset
-f.close();
diff --git a/examples/matlab/old/xml2struct.m b/examples/matlab/old/xml2struct.m
deleted file mode 100644
index dcd85a2..0000000
--- a/examples/matlab/old/xml2struct.m
+++ /dev/null
@@ -1,183 +0,0 @@
-function [ s ] = xml2struct( file )
-%Convert xml file into a MATLAB structure
-% [ s ] = xml2struct( file )
-%
-% A file containing:
-% <XMLname attrib1="Some value">
-%   <Element>Some text</Element>
-%   <DifferentElement attrib2="2">Some more text</Element>
-%   <DifferentElement attrib3="2" attrib4="1">Even more text</DifferentElement>
-% </XMLname>
-%
-% Will produce:
-% s.XMLname.Attributes.attrib1 = "Some value";
-% s.XMLname.Element.Text = "Some text";
-% s.XMLname.DifferentElement{1}.Attributes.attrib2 = "2";
-% s.XMLname.DifferentElement{1}.Text = "Some more text";
-% s.XMLname.DifferentElement{2}.Attributes.attrib3 = "2";
-% s.XMLname.DifferentElement{2}.Attributes.attrib4 = "1";
-% s.XMLname.DifferentElement{2}.Text = "Even more text";
-%
-% Please note that the following characters are substituted
-% '-' by '_dash_', ':' by '_colon_' and '.' by '_dot_'
-%
-% Written by W. Falkena, ASTI, TUDelft, 21-08-2010
-% Attribute parsing speed increased by 40% by A. Wanner, 14-6-2011
-% Added CDATA support by I. Smirnov, 20-3-2012
-%
-% Modified by X. Mo, University of Wisconsin, 12-5-2012
-
-    if (nargin < 1)
-        clc;
-        help xml2struct
-        return
-    end
-    
-    if isa(file, 'org.apache.xerces.dom.DeferredDocumentImpl') || isa(file, 'org.apache.xerces.dom.DeferredElementImpl')
-        % input is a java xml object
-        xDoc = file;
-    else
-        %check for existance
-        if (exist(file,'file') == 0)
-            %Perhaps the xml extension was omitted from the file name. Add the
-            %extension and try again.
-            if (isempty(strfind(file,'.xml')))
-                file = [file '.xml'];
-            end
-            
-            if (exist(file,'file') == 0)
-                error(['The file ' file ' could not be found']);
-            end
-        end
-        %read the xml file
-        xDoc = xmlread(file);
-    end
-    
-    %parse xDoc into a MATLAB structure
-    s = parseChildNodes(xDoc);
-    
-end
-
-% ----- Subfunction parseChildNodes -----
-function [children,ptext,textflag] = parseChildNodes(theNode)
-    % Recurse over node children.
-    children = struct;
-    ptext = struct; textflag = 'Text';
-    if hasChildNodes(theNode)
-        childNodes = getChildNodes(theNode);
-        numChildNodes = getLength(childNodes);
-
-        for count = 1:numChildNodes
-            theChild = item(childNodes,count-1);
-            [text,name,attr,childs,textflag] = getNodeData(theChild);
-            
-            if (~strcmp(name,'#text') && ~strcmp(name,'#comment') && ~strcmp(name,'#cdata_dash_section'))
-                %XML allows the same elements to be defined multiple times,
-                %put each in a different cell
-                if (isfield(children,name))
-                    if (~iscell(children.(name)))
-                        %put existsing element into cell format
-                        children.(name) = {children.(name)};
-                    end
-                    index = length(children.(name))+1;
-                    %add new element
-                    children.(name){index} = childs;
-                    if(~isempty(fieldnames(text)))
-                        children.(name){index} = text; 
-                    end
-                    if(~isempty(attr)) 
-                        children.(name){index}.('Attributes') = attr; 
-                    end
-                else
-                    %add previously unknown (new) element to the structure
-                    children.(name) = childs;
-                    if(~isempty(text) && ~isempty(fieldnames(text)))
-                        children.(name) = text; 
-                    end
-                    if(~isempty(attr)) 
-                        children.(name).('Attributes') = attr; 
-                    end
-                end
-            else
-                ptextflag = 'Text';
-                if (strcmp(name, '#cdata_dash_section'))
-                    ptextflag = 'CDATA';
-                elseif (strcmp(name, '#comment'))
-                    ptextflag = 'Comment';
-                end
-                
-                %this is the text in an element (i.e., the parentNode) 
-                if (~isempty(regexprep(text.(textflag),'[\s]*','')))
-                    if (~isfield(ptext,ptextflag) || isempty(ptext.(ptextflag)))
-                        ptext.(ptextflag) = text.(textflag);
-                    else
-                        %what to do when element data is as follows:
-                        %<element>Text <!--Comment--> More text</element>
-                        
-                        %put the text in different cells:
-                        % if (~iscell(ptext)) ptext = {ptext}; end
-                        % ptext{length(ptext)+1} = text;
-                        
-                        %just append the text
-                        ptext.(ptextflag) = [ptext.(ptextflag) text.(textflag)];
-                    end
-                end
-            end
-            
-        end
-    end
-end
-
-% ----- Subfunction getNodeData -----
-function [text,name,attr,childs,textflag] = getNodeData(theNode)
-    % Create structure of node info.
-    
-    %make sure name is allowed as structure name
-    name = toCharArray(getNodeName(theNode))';
-    name = strrep(name, '-', '_dash_');
-    name = strrep(name, ':', '_colon_');
-    name = strrep(name, '.', '_dot_');
-
-    attr = parseAttributes(theNode);
-    if (isempty(fieldnames(attr))) 
-        attr = []; 
-    end
-    
-    %parse child nodes
-    [childs,text,textflag] = parseChildNodes(theNode);
-    
-    if (isempty(fieldnames(childs)) && isempty(fieldnames(text)))
-        %get the data of any childless nodes
-        % faster than if any(strcmp(methods(theNode), 'getData'))
-        % no need to try-catch (?)
-        % faster than text = char(getData(theNode));
-        text.(textflag) = toCharArray(getTextContent(theNode))';
-    end
-    
-end
-
-% ----- Subfunction parseAttributes -----
-function attributes = parseAttributes(theNode)
-    % Create attributes structure.
-
-    attributes = struct;
-    if hasAttributes(theNode)
-       theAttributes = getAttributes(theNode);
-       numAttributes = getLength(theAttributes);
-
-       for count = 1:numAttributes
-            %attrib = item(theAttributes,count-1);
-            %attr_name = regexprep(char(getName(attrib)),'[-:.]','_');
-            %attributes.(attr_name) = char(getValue(attrib));
-
-            %Suggestion of Adrian Wanner
-            str = toCharArray(toString(item(theAttributes,count-1)))';
-            k = strfind(str,'='); 
-            attr_name = str(1:(k(1)-1));
-            attr_name = strrep(attr_name, '-', '_dash_');
-            attr_name = strrep(attr_name, ':', '_colon_');
-            attr_name = strrep(attr_name, '.', '_dot_');
-            attributes.(attr_name) = str((k(1)+2):(end-1));
-       end
-    end
-end
\ No newline at end of file
diff --git a/examples/matlab/todo.txt b/examples/matlab/todo.txt
new file mode 100644
index 0000000..50b1078
--- /dev/null
+++ b/examples/matlab/todo.txt
@@ -0,0 +1 @@
+Put Michaels spiral and gridder example back.
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5f8644d..8af4d25 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,2 +1,6 @@
-add_subdirectory(c++)
+# enable ctest
+enable_testing()
+
 add_subdirectory(c)
+add_subdirectory(c++)
+add_subdirectory(xml)
diff --git a/xml/CMakeLists.txt b/tests/xml/CMakeLists.txt
similarity index 100%
rename from xml/CMakeLists.txt
rename to tests/xml/CMakeLists.txt
diff --git a/xml/test_meta.cpp b/tests/xml/test_meta.cpp
similarity index 100%
rename from xml/test_meta.cpp
rename to tests/xml/test_meta.cpp
diff --git a/xml/test_xml.cpp b/tests/xml/test_xml.cpp
similarity index 100%
rename from xml/test_xml.cpp
rename to tests/xml/test_xml.cpp

-- 
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