Skip to content

Commit

Permalink
Merge pull request #3016 from dzenanz/updateMINC
Browse files Browse the repository at this point in the history
MINC 2021-12-23 (728d19e8)
  • Loading branch information
hjmjohnson authored Jan 3, 2022
2 parents bf36ae4 + da25355 commit ec6849f
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 86 deletions.
34 changes: 21 additions & 13 deletions Modules/ThirdParty/MINC/UpdateFromUpstream.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env bash

thirdparty_module_name='MINC'
set -e
set -x
shopt -s dotglob

upstream_git_url='https://github.com/BIC-MNI/libminc.git'
upstream_git_branch='develop'

snapshot_author_name='Vladimir S. FONOV'
snapshot_author_email='vladimir.fonov@gmail.com'

snapshot_redact_cmd='chmod u-x volume_io/Geometry/tensors.c'
snapshot_relative_path='src/libminc'
snapshot_paths='
readonly name="MINC"
readonly ownership="Vladimir S. FONOV <vladimir.fonov@gmail.com>"
readonly subtree="Modules/ThirdParty/MINC/src/libminc"
readonly repo="https://github.com/BIC-MNI/libminc.git"
readonly tag="develop"
readonly paths="
./ChangeLog
./volume_io
./libsrc
Expand Down Expand Up @@ -85,7 +84,16 @@ snapshot_paths='
./INSTALL
./config.h.cmake
./README
./check_clock_gettime.c'
./check_clock_gettime.c
"


extract_source () {
git_archive
pushd "${extractdir}/${name}-reduced"
git update-index --chmod=+x 'src/libminc/libsrc/Make.com'
# chmod u-x volume_io/Geometry/tensors.c
popd
}

source "${BASH_SOURCE%/*}/../../../Utilities/Maintenance/UpdateThirdPartyFromUpstream.sh"
update_from_upstream
. "${BASH_SOURCE%/*}/../../../Utilities/Maintenance/update-third-party.bash"
35 changes: 26 additions & 9 deletions Modules/ThirdParty/MINC/src/libminc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INCLUDE(CTest)

ENABLE_TESTING()

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
CMAKE_MINIMUM_REQUIRED(VERSION 3.6)

IF( POLICY CMP0063 )
CMAKE_POLICY(SET CMP0063 NEW)
Expand All @@ -49,7 +49,9 @@ IF(NOT LIBMINC_EXTERNALLY_CONFIGURED)


OPTION(LIBMINC_MINC1_SUPPORT "Support minc1 file format, requires NETCDF" OFF)
OPTION(LIBMINC_BUILD_EZMINC "Build C++ EMINC library based on libminc1" OFF)
OPTION(LIBMINC_BUILD_EZMINC_EXAMPLES "Build EZminc examples" OFF)
OPTION(LIBMINC_USE_NIFTI "Build with NIfTI support" OFF)
OPTION(LIBMINC_USE_SYSTEM_NIFTI "Use system NIfTI-1 library" OFF)

SET (LIBMINC_EXPORTED_TARGETS "LIBMINC-targets")
Expand All @@ -67,13 +69,17 @@ IF(NOT LIBMINC_EXTERNALLY_CONFIGURED)
SET(HDF5_NO_FIND_PACKAGE_CONFIG_FILE ON)
FIND_PACKAGE(HDF5 REQUIRED COMPONENTS C )

IF(LIBMINC_USE_NIFTI)
IF (LIBMINC_USE_SYSTEM_NIFTI)
FIND_PACKAGE(NIFTI)
ELSE(LIBMINC_USE_SYSTEM_NIFTI)
INCLUDE(ExternalProject)
INCLUDE(BuildNIFTI)
build_nifti(${CMAKE_INSTALL_PREFIX} ${CMAKE_BINARY_DIR}/external)
ENDIF(LIBMINC_USE_SYSTEM_NIFTI)
ELSE()
SET(NIFTI_FOUND OFF)
ENDIF()

SET(HAVE_ZLIB ON)
ELSE(NOT LIBMINC_EXTERNALLY_CONFIGURED)
Expand Down Expand Up @@ -132,6 +138,7 @@ set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1 )
CHECK_SYMBOL_EXISTS(rint "math.h" HAVE_RINT)
CHECK_SYMBOL_EXISTS(copysign "math.h" HAVE_COPYSIGN)
CHECK_SYMBOL_EXISTS(round "math.h" HAVE_ROUND)
CHECK_SYMBOL_EXISTS(fabsf "math.h" HAVE_FABSF)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_DEFINITIONS)

Expand Down Expand Up @@ -237,10 +244,13 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/libsrc2
${CMAKE_CURRENT_SOURCE_DIR}/libsrc
${CMAKE_CURRENT_SOURCE_DIR}/volume_io/Include
${CMAKE_CURRENT_SOURCE_DIR}/ezminc
${HDF5_INCLUDE_DIRS}
)

IF(LIBMINC_BUILD_EZMINC AND LIBMINC_MINC1_SUPPORT)
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/ezminc )
ENDIF()

IF(LIBMINC_NIFTI_SUPPORT)
INCLUDE_DIRECTORIES(
${NIFTI_INCLUDE_DIR}
Expand Down Expand Up @@ -456,9 +466,9 @@ ELSE(LIBMINC_MINC1_SUPPORT)
SET(NETCDF_LIBRARY_NAME )
ENDIF(LIBMINC_MINC1_SUPPORT)

IF(NOT LIBMINC_USE_SYSTEM_NIFTI AND NOT LIBMINC_EXTERNALLY_CONFIGURED)
IF(NOT LIBMINC_USE_SYSTEM_NIFTI AND NOT LIBMINC_EXTERNALLY_CONFIGURED AND NIFTI_FOUND)
ADD_DEPENDENCIES(minc2 NIFTI)
ENDIF(NOT LIBMINC_USE_SYSTEM_NIFTI AND NOT LIBMINC_EXTERNALLY_CONFIGURED)
ENDIF()

#EXPORT(TARGETS ${LIBMINC_LIBRARY} FILE "${LIBMINC_EXPORTED_TARGETS}.cmake")

Expand Down Expand Up @@ -507,12 +517,15 @@ IF(LIBMINC_INSTALL_INCLUDE_DIR AND NOT LIBMINC_INSTALL_NO_DEVELOPMENT)
INSTALL(FILES ${volume_io_HEADERS} DESTINATION ${LIBMINC_INSTALL_INCLUDE_DIR}/volume_io COMPONENT headers)
ENDIF(LIBMINC_INSTALL_INCLUDE_DIR AND NOT LIBMINC_INSTALL_NO_DEVELOPMENT)

IF(LIBMINC_MINC1_SUPPORT)
IF(LIBMINC_BUILD_EZMINC AND LIBMINC_MINC1_SUPPORT)
ADD_SUBDIRECTORY( ezminc )
ENDIF(LIBMINC_MINC1_SUPPORT)
SET(EZMINC_LIBRARIES minc_io ${LIBMINC_LIBRARIES})
SET(EZMINC_LIBRARIES_CONFIG minc_io ${LIBMINC_LIBRARIES_CONFIG})
ELSE()
SET(EZMINC_LIBRARIES "")
SET(EZMINC_LIBRARIES_CONFIG "")
ENDIF()

SET(EZMINC_LIBRARIES minc_io ${LIBMINC_LIBRARIES})
SET(EZMINC_LIBRARIES_CONFIG minc_io ${LIBMINC_LIBRARIES_CONFIG})

# config for install dir
SET(LIBMINC_USE_FILE_CONFIG "\${LIBMINC_INSTALL_PREFIX}/lib/cmake/Use${LIBMINC_EXTERNAL_LIB_PREFIX}LIBMINC.cmake" )
Expand Down Expand Up @@ -540,8 +553,12 @@ IF(LIBMINC_MINC1_SUPPORT)
SET(LIBMINC_INCLUDE_DIRS_CONFIG
${LIBMINC_INCLUDE_DIRS_CONFIG}
${CMAKE_CURRENT_SOURCE_DIR}/libsrc
${CMAKE_CURRENT_SOURCE_DIR}/ezminc
)

IF(LIBMINC_BUILD_EZMINC)
SET(LIBMINC_INCLUDE_DIRS_CONFIG ${LIBMINC_INCLUDE_DIRS_CONFIG}
${CMAKE_CURRENT_SOURCE_DIR}/ezminc )
ENDIF()
ENDIF(LIBMINC_MINC1_SUPPORT)

SET(LIBMINC_LIBRARY_DIRS_CONFIG ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
4 changes: 2 additions & 2 deletions Modules/ThirdParty/MINC/src/libminc/libcommon/restructure.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ void restructure_array(size_t ndims, /* Dimension count */
#ifdef _DEBUG
if (offset_next >= total) {
printf("Fatal - offset %ld out of bounds!\n", offset_next);
printf("lengths %lld,%lld,%lld\n",
printf("lengths %zu,%zu,%zu\n",
lengths[0],lengths[1],lengths[2]);
printf("index %lld,%lld,%lld\n",
printf("index %zu,%zu,%zu\n",
index_perm[0], index_perm[0], index_perm[2]);
//TODO: report MEMORY error somehow
exit(-1);
Expand Down
8 changes: 8 additions & 0 deletions Modules/ThirdParty/MINC/src/libminc/libsrc2/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ int miconvert_voxel_to_real(mihandle_t volume,
double voxel_range, voxel_offset;
double real_range, real_offset;

if( volume->volume_type==MI_TYPE_FLOAT || volume->volume_type==MI_TYPE_DOUBLE ||
volume->volume_type==MI_TYPE_FCOMPLEX || volume->volume_type==MI_TYPE_DCOMPLEX ){
// If floating values voxel_value is the real value
*real_value_ptr = voxel_value;
return 0;
}


/* get valid min/max, image min/max
*/
miget_volume_valid_range(volume, &valid_max, &valid_min);
Expand Down
6 changes: 3 additions & 3 deletions Modules/ThirdParty/MINC/src/libminc/libsrc2/hyper.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ static int mirw_hyperslab_icv(int opcode,
scaling_needed=0;
}
#ifdef _DEBUG
printf("mirw_hyperslab_icv:Slice_ndim:%d total_number_of_slices:%d image_slice_length:%d scaling_needed:%d\n",slice_ndims,total_number_of_slices,image_slice_length,scaling_needed);
printf("mirw_hyperslab_icv:Slice_ndim:%zu total_number_of_slices:%zu image_slice_length:%zu scaling_needed:%zu\n",(size_t)slice_ndims,(size_t)total_number_of_slices,(size_t)image_slice_length,(size_t)scaling_needed);
#endif

if (opcode == MIRW_OP_READ)
Expand Down Expand Up @@ -952,7 +952,7 @@ static int mirw_hyperslab_normalized(int opcode,
miget_volume_valid_range( volume, &volume_valid_max, &volume_valid_min);

#ifdef _DEBUG
printf("mirw_hyperslab_normalized:Volume:%x valid_max:%f valid_min:%f scaling:%d\n",volume,volume_valid_max,volume_valid_min,volume->has_slice_scaling);
printf("mirw_hyperslab_normalized:Volume:%p valid_max:%f valid_min:%f scaling:%d\n",volume,volume_valid_max,volume_valid_min,volume->has_slice_scaling);
#endif

if(volume->has_slice_scaling &&
Expand Down Expand Up @@ -1047,7 +1047,7 @@ static int mirw_hyperslab_normalized(int opcode,
}

#ifdef _DEBUG
printf("mirw_hyperslab_normalized:Slice_ndim:%d total_number_of_slices:%d image_slice_length:%d\n",slice_ndims,total_number_of_slices,image_slice_length);
printf("mirw_hyperslab_normalized:Slice_ndim:%d total_number_of_slices:%zu image_slice_length:%zu\n",slice_ndims,(size_t)total_number_of_slices,(size_t)image_slice_length);
printf("mirw_hyperslab_normalized:data min:%f data max:%f buffer_data_type:%d\n",data_min,data_max,buffer_data_type);
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
#include <volume_io/basic.h>
#include <stdlib.h>

#define _ALLOC_SOURCE_LINE
#define _ALLOC_SOURCE_LINE_ARG_DEF
#define _ALLOC_SOURCE_LINE_ARGUMENTS
#define ALLOC_SOURCE_LINE
#define ALLOC_SOURCE_LINE_ARG_DEF
#define ALLOC_SOURCE_LINE_ARGUMENTS
#define PRINT_ALLOC_SOURCE_LINE

#if 0
#define _ALLOC_SOURCE_LINE , __FILE__, __LINE__
#define _ALLOC_SOURCE_LINE_ARG_DEF , char filename[], int line_number
#define _ALLOC_SOURCE_LINE_ARGUMENTS , filename, line_number
#define ALLOC_SOURCE_LINE , __FILE__, __LINE__
#define ALLOC_SOURCE_LINE_ARG_DEF , char filename[], int line_number
#define ALLOC_SOURCE_LINE_ARGUMENTS , filename, line_number
#define PRINT_ALLOC_SOURCE_LINE print_alloc_source_line( filename, line_number );
#endif

Expand All @@ -62,7 +62,7 @@
#define ALLOC( ptr, n_items ) \
ASSIGN_PTR(ptr) = \
alloc_memory_1d( (size_t) (n_items), \
sizeof(*(ptr)) _ALLOC_SOURCE_LINE )
sizeof(*(ptr)) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : FREE
Expand All @@ -78,7 +78,7 @@
---------------------------------------------------------------------------- */

#define FREE( ptr ) \
free_memory_1d( (void **) &(ptr) _ALLOC_SOURCE_LINE )
free_memory_1d( (void **) &(ptr) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : REALLOC
Expand All @@ -97,7 +97,7 @@

#define REALLOC( ptr, n_items ) \
realloc_memory( (void **) &(ptr), (size_t) (n_items), \
sizeof(*(ptr)) _ALLOC_SOURCE_LINE )
sizeof(*(ptr)) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : ALLOC_VAR_SIZED_STRUCT
Expand Down Expand Up @@ -139,7 +139,7 @@
#define ALLOC_VAR_SIZED_STRUCT( ptr, element_type, n_elements ) \
ASSIGN_PTR(ptr) = alloc_memory_in_bytes( \
(size_t) (sizeof(*(ptr))+((size_t)(n_elements)-1) * sizeof(element_type)) \
_ALLOC_SOURCE_LINE )
ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : VIO_ALLOC2D
Expand All @@ -160,7 +160,7 @@

#define VIO_ALLOC2D( ptr, n1, n2 ) \
ASSIGN_PTR(ptr) = alloc_memory_2d( (size_t) (n1), (size_t) (n2), \
sizeof(**(ptr)) _ALLOC_SOURCE_LINE )
sizeof(**(ptr)) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : VIO_FREE2D
Expand All @@ -176,7 +176,7 @@
---------------------------------------------------------------------------- */

#define VIO_FREE2D( ptr ) \
free_memory_2d( (void ***) &(ptr) _ALLOC_SOURCE_LINE )
free_memory_2d( (void ***) &(ptr) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : VIO_ALLOC3D
Expand All @@ -196,7 +196,7 @@

#define VIO_ALLOC3D( ptr, n1, n2, n3 ) \
ASSIGN_PTR(ptr) = alloc_memory_3d( (size_t) (n1), (size_t) (n2), \
(size_t) (n3), sizeof(***(ptr)) _ALLOC_SOURCE_LINE )
(size_t) (n3), sizeof(***(ptr)) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : VIO_FREE3D
Expand All @@ -212,7 +212,7 @@
---------------------------------------------------------------------------- */

#define VIO_FREE3D( ptr ) \
free_memory_3d( (void ****) &(ptr) _ALLOC_SOURCE_LINE )
free_memory_3d( (void ****) &(ptr) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : ALLOC4D
Expand All @@ -234,7 +234,7 @@
#define VIO_ALLOC4D( ptr, n1, n2, n3, n4 ) \
ASSIGN_PTR(ptr) = alloc_memory_4d( (size_t) (n1), (size_t) (n2), \
(size_t) (n3), (size_t) (n4), \
sizeof(****(ptr)) _ALLOC_SOURCE_LINE )
sizeof(****(ptr)) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : FREE4D
Expand All @@ -250,7 +250,7 @@
---------------------------------------------------------------------------- */

#define VIO_FREE4D( ptr ) \
free_memory_4d( (void *****) &(ptr) _ALLOC_SOURCE_LINE )
free_memory_4d( (void *****) &(ptr) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : ALLOC5D
Expand All @@ -274,7 +274,7 @@
#define VIO_ALLOC5D( ptr, n1, n2, n3, n4, n5 ) \
ASSIGN_PTR(ptr) = alloc_memory_5d( (size_t) (n1), (size_t) (n2), \
(size_t) (n3), (size_t) (n4), (size_t) (n5), \
sizeof(*****(ptr)) _ALLOC_SOURCE_LINE )
sizeof(*****(ptr)) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : FREE5D
Expand All @@ -290,6 +290,6 @@
---------------------------------------------------------------------------- */

#define VIO_FREE5D( ptr ) \
free_memory_5d( (void ******) &(ptr) _ALLOC_SOURCE_LINE )
free_memory_5d( (void ******) &(ptr) ALLOC_SOURCE_LINE )

#endif /*VOL_IO_ALLOC_H*/
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
set_array_size( (void **) (&(array)), sizeof(*(array)), \
(size_t) (previous_n_elems), \
(size_t) (new_n_elems), \
(size_t) (chunk_size) _ALLOC_SOURCE_LINE )
(size_t) (chunk_size) ALLOC_SOURCE_LINE )

/* ----------------------------- MNI Header -----------------------------------
@NAME : ADD_ELEMENT_TO_ARRAY
Expand Down
Loading

0 comments on commit ec6849f

Please sign in to comment.