From 69165393cb767037a78b1bae0ce5357d8b6cc3fd Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sat, 5 Dec 2015 14:48:16 +0100 Subject: [PATCH] allow nifti, openjpeg2 be system Signed-off-by: Igor Gnatenko --- CMakeLists.txt | 11 +++- cmake/Modules/FindNIFTI.cmake | 20 +++++++ console/CMakeLists.txt | 26 ++++++-- console/config.h.in | 6 ++ console/nifti1_io_core.cpp | 135 +----------------------------------------- console/nifti1_io_core.h | 51 ++++------------ console/nifti1_io_ext.cpp | 127 +++++++++++++++++++++++++++++++++++++++ console/nifti1_io_ext.h | 39 ++++++++++++ console/nii_dicom.cpp | 4 +- console/nii_dicom_batch.cpp | 2 +- console/nii_io.mm | 4 ++ 11 files changed, 241 insertions(+), 184 deletions(-) create mode 100644 cmake/Modules/FindNIFTI.cmake create mode 100644 console/config.h.in create mode 100644 console/nifti1_io_ext.cpp create mode 100644 console/nifti1_io_ext.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ef8324d..85dc6a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,15 @@ project(dcm2niix) cmake_minimum_required(VERSION 2.6) -# -# Zlib -# + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + find_package(ZLIB) +find_package(NIFTI) +find_package(PkgConfig) +if(PKG_CONFIG_FOUND) + pkg_check_modules(OpenJPEG2 libopenjp2) +endif() # Predefined permission set to enforce proper permissions # during install even if files in the sources have different diff --git a/cmake/Modules/FindNIFTI.cmake b/cmake/Modules/FindNIFTI.cmake new file mode 100644 index 0000000..8653975 --- /dev/null +++ b/cmake/Modules/FindNIFTI.cmake @@ -0,0 +1,20 @@ +# - Try to find NIFTI +# Once done this will define +# NIFTI_FOUND - System has NIFTI +# NIFTI_INCLUDE_DIRS - The NIFTI include directories +# NIFTI_LIBRARIES - The libraries needed to use NIFTI +# NIFTI_DEFINITIONS - Compiler switches required for using NIFTI + +find_path(NIFTI_INCLUDE_DIR nifti1.h nifti1_io.h + PATH_SUFFIXES nifti) + +find_library(NIFTI_LIBRARY NAMES niftiio) + +set(NIFTI_LIBRARIES ${NIFTI_LIBRARY}) +set(NIFTI_INCLUDE_DIRS ${NIFTI_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NIFTI DEFAULT_MSG + NIFTI_LIBRARY NIFTI_INCLUDE_DIR) + +mark_as_advanced(NIFTI_INCLUDE_DIR NIFTI_LIBRARY) diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt index fc82984..24d3613 100755 --- a/console/CMakeLists.txt +++ b/console/CMakeLists.txt @@ -1,12 +1,16 @@ project(console) set(PROGRAMS dcm2niix) +CONFIGURE_FILE(config.h.in config.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + add_executable(dcm2niix main_console.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp + nifti1_io_ext.cpp nii_ortho.cpp nii_dicom_batch.cpp) @@ -23,12 +27,22 @@ endif() #We now use miniz, removing zlib dependency -#if(ZLIB_FOUND) -# TARGET_LINK_LIBRARIES(dcm2niix z) -#else(ZLIB_FOUND) -# ADD_DEFINITIONS(-DmyDisableZlib) -#endif(ZLIB_FOUND) +if(ZLIB_FOUND) + ADD_DEFINITIONS(-DmyDisableMiniZ) + TARGET_LINK_LIBRARIES(dcm2niix ${ZLIB_LIBRARIES}) +endif(ZLIB_FOUND) +if(NIFTI_FOUND) + include_directories(${NIFTI_INCLUDE_DIRS}) + target_link_libraries(dcm2niix ${NIFTI_LIBRARIES}) +else() + include_directories(nifti) +endif() +if(OpenJPEG2_FOUND) + include_directories(${OpenJPEG2_INCLUDE_DIRS}) + target_link_libraries(dcm2niix ${OpenJPEG2_LIBRARIES}) +else() + ADD_DEFINITIONS(-DmyDisableOpenJPEG) +endif() ADD_DEFINITIONS(-DmyDisableJasper) -ADD_DEFINITIONS(-DmyDisableOpenJPEG) install(TARGETS ${PROGRAMS} DESTINATION bin) diff --git a/console/config.h.in b/console/config.h.in new file mode 100644 index 0000000..6665e25 --- /dev/null +++ b/console/config.h.in @@ -0,0 +1,6 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#cmakedefine NIFTI_FOUND + +#endif // CONFIG_H diff --git a/console/nifti1_io_core.cpp b/console/nifti1_io_core.cpp index 660416b..bc61e37 100755 --- a/console/nifti1_io_core.cpp +++ b/console/nifti1_io_core.cpp @@ -1,4 +1,5 @@ #include "nifti1_io_core.h" +#ifndef NIFTI_FOUND #include #include #include @@ -59,108 +60,6 @@ void nifti_swap_2bytes( size_t n , void *ar ) // 2 bytes at a time return ; } -int isSameFloat (float a, float b) { - return (fabs (a - b) <= FLT_EPSILON); -} - -vec3 setVec3(float x, float y, float z) -{ - vec3 v = {x, y, z}; - return v; -} - -vec4 setVec4(float x, float y, float z) -{ - vec4 v= {x, y, z, 1}; - return v; -} - -vec3 crossProduct(vec3 u, vec3 v) -{ - return setVec3(u.v[1]*v.v[2] - v.v[1]*u.v[2], - -u.v[0]*v.v[2] + v.v[0]*u.v[2], - u.v[0]*v.v[1] - v.v[0]*u.v[1]); -} - -float dotProduct(vec3 u, vec3 v) -{ - return (u.v[0]*v.v[0] + v.v[1]*u.v[1] + v.v[2]*u.v[2]); -} - -vec3 nifti_vect33_norm (vec3 v) { //normalize vector length - vec3 vO = v; - float vLen = sqrt( (v.v[0]*v.v[0]) - + (v.v[1]*v.v[1]) - + (v.v[2]*v.v[2])); - if (vLen <= FLT_EPSILON) return vO; //avoid divide by zero - for (int i = 0; i < 3; i++) - vO.v[i] = v.v[i]/vLen; - return vO; -} - -vec3 nifti_vect33mat33_mul(vec3 v, mat33 m ) { //multiply vector * 3x3matrix - vec3 vO; - for (int i=0; i<3; i++) { //multiply Pcrs * m - vO.v[i] = 0; - for(int j=0; j<3; j++) - vO.v[i] += m.m[i][j]*v.v[j]; - } - return vO; -} - -vec4 nifti_vect44mat44_mul(vec4 v, mat44 m ) { //multiply vector * 4x4matrix - vec4 vO; - for (int i=0; i<4; i++) { //multiply Pcrs * m - vO.v[i] = 0; - for(int j=0; j<4; j++) - vO.v[i] += m.m[i][j]*v.v[j]; - } - return vO; -} - -mat44 nifti_dicom2mat(float orient[7], float patientPosition[4], float xyzMM[4]) { - //create NIfTI header based on values from DICOM header - //note orient has 6 values, indexed from 1, patient position and xyzMM have 3 values indexed from 1 - mat33 Q, diagVox; - Q.m[0][0] = orient[1]; Q.m[0][1] = orient[2] ; Q.m[0][2] = orient[3] ; // load Q - Q.m[1][0] = orient[4]; Q.m[1][1] = orient[5] ; Q.m[1][2] = orient[6]; - //printf("Orient %g %g %g %g %g %g\n",orient[1],orient[2],orient[3],orient[4],orient[5],orient[6] ); - /* normalize row 1 */ - double val = Q.m[0][0]*Q.m[0][0] + Q.m[0][1]*Q.m[0][1] + Q.m[0][2]*Q.m[0][2] ; - if( val > 0.0l ){ - val = 1.0l / sqrt(val) ; - Q.m[0][0] *= (float)val ; Q.m[0][1] *= (float)val ; Q.m[0][2] *= (float)val ; - } else { - Q.m[0][0] = 1.0l ; Q.m[0][1] = 0.0l ; Q.m[0][2] = 0.0l ; - } - /* normalize row 2 */ - val = Q.m[1][0]*Q.m[1][0] + Q.m[1][1]*Q.m[1][1] + Q.m[1][2]*Q.m[1][2] ; - if( val > 0.0l ){ - val = 1.0l / sqrt(val) ; - Q.m[1][0] *= (float)val ; Q.m[1][1] *= (float)val ; Q.m[1][2] *= (float)val ; - } else { - Q.m[1][0] = 0.0l ; Q.m[1][1] = 1.0l ; Q.m[1][2] = 0.0l ; - } - /* row 3 is the cross product of rows 1 and 2*/ - Q.m[2][0] = Q.m[0][1]*Q.m[1][2] - Q.m[0][2]*Q.m[1][1] ; /* cross */ - Q.m[2][1] = Q.m[0][2]*Q.m[1][0] - Q.m[0][0]*Q.m[1][2] ; /* product */ - Q.m[2][2] = Q.m[0][0]*Q.m[1][1] - Q.m[0][1]*Q.m[1][0] ; - Q = nifti_mat33_transpose(Q); - if (nifti_mat33_determ(Q) < 0.0) { - Q.m[0][2] = -Q.m[0][2]; - Q.m[1][2] = -Q.m[1][2]; - Q.m[2][2] = -Q.m[2][2]; - } - //next scale matrix - LOAD_MAT33(diagVox, xyzMM[1],0.0l,0.0l, 0.0l,xyzMM[2],0.0l, 0.0l,0.0l, xyzMM[3]); - Q = nifti_mat33_mul(Q,diagVox); - mat44 Q44; //4x4 matrix includes translations - LOAD_MAT44(Q44, Q.m[0][0],Q.m[0][1],Q.m[0][2],patientPosition[1], - Q.m[1][0],Q.m[1][1],Q.m[1][2],patientPosition[2], - Q.m[2][0],Q.m[2][1],Q.m[2][2],patientPosition[3]); - return Q44; -} - float nifti_mat33_determ( mat33 R ) /* determinant of 3x3 matrix */ { double r11,r12,r13,r21,r22,r23,r31,r32,r33 ; @@ -184,28 +83,6 @@ mat33 nifti_mat33_mul( mat33 A , mat33 B ) /* multiply 2 3x3 matrices */ return C ; } -mat44 nifti_mat44_mul( mat44 A , mat44 B ) /* multiply 2 3x3 matrices */ -{ - mat44 C ; int i,j ; - for( i=0 ; i < 4 ; i++ ) - for( j=0 ; j < 4; j++ ) - C.m[i][j] = A.m[i][0] * B.m[0][j] - + A.m[i][1] * B.m[1][j] - + A.m[i][2] * B.m[2][j] - + A.m[i][3] * B.m[3][j]; - return C ; -} - -mat33 nifti_mat33_transpose( mat33 A ) /* transpose 3x3 matrix */ -//see http://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1_io.c -{ - mat33 B; int i,j ; - for( i=0 ; i < 3 ; i++ ) - for( j=0 ; j < 3 ; j++ ) - B.m[i][j] = A.m[j][i]; - return B; -} - mat33 nifti_mat33_inverse( mat33 R ) /* inverse of 3x3 matrix */ { double r11,r12,r13,r21,r22,r23,r31,r32,r33 , deti ; @@ -462,12 +339,4 @@ mat44 nifti_mat44_inverse( mat44 R ) Q.m[3][3] = (deti == 0.0l) ? 0.0l : 1.0l ; // failure flag if deti == 0 return Q ; } - - - - - - - - - +#endif // NIFTI_FOUND diff --git a/console/nifti1_io_core.h b/console/nifti1_io_core.h index 3fc3763..b2a968e 100755 --- a/console/nifti1_io_core.h +++ b/console/nifti1_io_core.h @@ -7,7 +7,13 @@ #ifdef __cplusplus extern "C" { #endif - + +#include "config.h" + +#ifdef NIFTI_FOUND +#include +#else + #include #include @@ -17,52 +23,15 @@ typedef struct { /** 4x4 matrix struct **/ typedef struct { /** 4x4 matrix struct **/ float m[4][4] ; } mat44 ; -typedef struct { /** x4 vector struct **/ - float v[4] ; -} vec4 ; -typedef struct { /** x3 vector struct **/ - float v[3] ; -} vec3 ; -typedef struct { /** x4 vector struct INTEGER**/ - int v[3] ; -} ivec3 ; - -#define LOAD_MAT33(AA,a11,a12,a13 ,a21,a22,a23 ,a31,a32,a33) \ -( AA.m[0][0]=a11 , AA.m[0][1]=a12 , AA.m[0][2]=a13 , \ -AA.m[1][0]=a21 , AA.m[1][1]=a22 , AA.m[1][2]=a23 , \ -AA.m[2][0]=a31 , AA.m[2][1]=a32 , AA.m[2][2]=a33 ) - -#define LOAD_MAT44(AA,a11,a12,a13,a14,a21,a22,a23,a24,a31,a32,a33,a34) \ -( AA.m[0][0]=a11 , AA.m[0][1]=a12 , AA.m[0][2]=a13 , AA.m[0][3]=a14 , \ -AA.m[1][0]=a21 , AA.m[1][1]=a22 , AA.m[1][2]=a23 , AA.m[1][3]=a24 , \ -AA.m[2][0]=a31 , AA.m[2][1]=a32 , AA.m[2][2]=a33 , AA.m[2][3]=a34 , \ -AA.m[3][0]=AA.m[3][1]=AA.m[3][2]=0.0f , AA.m[3][3]=1.0f ) #undef ASSIF // assign v to *p, if possible #define ASSIF(p,v) if( (p)!=NULL ) *(p) = (v) -float dotProduct(vec3 u, vec3 v); float nifti_mat33_determ( mat33 R ) ; -int isSameFloat (float a, float b) ; mat33 nifti_mat33_inverse( mat33 R ); mat33 nifti_mat33_mul( mat33 A , mat33 B ); mat33 nifti_mat33_mul( mat33 A , mat33 B ); -mat33 nifti_mat33_transpose( mat33 A ) ; -mat33 nifti_mat33_transpose( mat33 A ) ; -mat44 nifti_dicom2mat(float orient[7], float patientPosition[4], float xyzMM[4]); -mat44 nifti_dicom2mat(float orient[7], float patientPosition[4], float xyzMM[4]); mat44 nifti_mat44_inverse( mat44 R ); mat44 nifti_mat44_inverse( mat44 R ); -mat44 nifti_mat44_mul( mat44 A , mat44 B ); -mat44 nifti_mat44_mul( mat44 A , mat44 B ); -vec3 crossProduct(vec3 u, vec3 v); -vec3 nifti_vect33_norm (vec3 v); -//vec3 nifti_vect33_norm (vec3 v); -vec3 nifti_vect33mat33_mul(vec3 v, mat33 m ); -//vec3 nifti_vect33mat33_mul(vec3 v, mat33 m ); -vec3 setVec3(float x, float y, float z); -//vec4 nifti_vect44mat44_mul(vec4 v, mat44 m ); -vec4 setVec4(float x, float y, float z); -vec4 nifti_vect44mat44_mul(vec4 v, mat44 m ); void nifti_swap_2bytes( size_t n , void *ar ); // 2 bytes at a time void nifti_swap_4bytes( size_t n , void *ar ); // 4 bytes at a time void nifti_swap_8bytes( size_t n , void *ar ); // 8 bytes at a time @@ -74,8 +43,12 @@ mat44 nifti_quatern_to_mat44( float qb, float qc, float qd, float qx, float qy, float qz, float dx, float dy, float dz, float qfac ); +#endif // NIFTI_FOUND + +#include "nifti1_io_ext.h" + #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/console/nifti1_io_ext.cpp b/console/nifti1_io_ext.cpp new file mode 100644 index 0000000..c3e31b2 --- /dev/null +++ b/console/nifti1_io_ext.cpp @@ -0,0 +1,127 @@ +#include "nifti1_io_core.h" +#include +#include + +int isSameFloat (float a, float b) { + return (fabs (a - b) <= FLT_EPSILON); +} + +vec3 setVec3(float x, float y, float z) +{ + vec3 v = {x, y, z}; + return v; +} + +vec4 setVec4(float x, float y, float z) +{ + vec4 v= {x, y, z, 1}; + return v; +} + +vec3 crossProduct(vec3 u, vec3 v) +{ + return setVec3(u.v[1]*v.v[2] - v.v[1]*u.v[2], + -u.v[0]*v.v[2] + v.v[0]*u.v[2], + u.v[0]*v.v[1] - v.v[0]*u.v[1]); +} + +float dotProduct(vec3 u, vec3 v) +{ + return (u.v[0]*v.v[0] + v.v[1]*u.v[1] + v.v[2]*u.v[2]); +} + +vec3 nifti_vect33_norm (vec3 v) { //normalize vector length + vec3 vO = v; + float vLen = sqrt( (v.v[0]*v.v[0]) + + (v.v[1]*v.v[1]) + + (v.v[2]*v.v[2])); + if (vLen <= FLT_EPSILON) return vO; //avoid divide by zero + for (int i = 0; i < 3; i++) + vO.v[i] = v.v[i]/vLen; + return vO; +} + +vec3 nifti_vect33mat33_mul(vec3 v, mat33 m ) { //multiply vector * 3x3matrix + vec3 vO; + for (int i=0; i<3; i++) { //multiply Pcrs * m + vO.v[i] = 0; + for(int j=0; j<3; j++) + vO.v[i] += m.m[i][j]*v.v[j]; + } + return vO; +} + +vec4 nifti_vect44mat44_mul(vec4 v, mat44 m ) { //multiply vector * 4x4matrix + vec4 vO; + for (int i=0; i<4; i++) { //multiply Pcrs * m + vO.v[i] = 0; + for(int j=0; j<4; j++) + vO.v[i] += m.m[i][j]*v.v[j]; + } + return vO; +} + +mat44 nifti_dicom2mat(float orient[7], float patientPosition[4], float xyzMM[4]) { + //create NIfTI header based on values from DICOM header + //note orient has 6 values, indexed from 1, patient position and xyzMM have 3 values indexed from 1 + mat33 Q, diagVox; + Q.m[0][0] = orient[1]; Q.m[0][1] = orient[2] ; Q.m[0][2] = orient[3] ; // load Q + Q.m[1][0] = orient[4]; Q.m[1][1] = orient[5] ; Q.m[1][2] = orient[6]; + //printf("Orient %g %g %g %g %g %g\n",orient[1],orient[2],orient[3],orient[4],orient[5],orient[6] ); + /* normalize row 1 */ + double val = Q.m[0][0]*Q.m[0][0] + Q.m[0][1]*Q.m[0][1] + Q.m[0][2]*Q.m[0][2] ; + if( val > 0.0l ){ + val = 1.0l / sqrt(val) ; + Q.m[0][0] *= (float)val ; Q.m[0][1] *= (float)val ; Q.m[0][2] *= (float)val ; + } else { + Q.m[0][0] = 1.0l ; Q.m[0][1] = 0.0l ; Q.m[0][2] = 0.0l ; + } + /* normalize row 2 */ + val = Q.m[1][0]*Q.m[1][0] + Q.m[1][1]*Q.m[1][1] + Q.m[1][2]*Q.m[1][2] ; + if( val > 0.0l ){ + val = 1.0l / sqrt(val) ; + Q.m[1][0] *= (float)val ; Q.m[1][1] *= (float)val ; Q.m[1][2] *= (float)val ; + } else { + Q.m[1][0] = 0.0l ; Q.m[1][1] = 1.0l ; Q.m[1][2] = 0.0l ; + } + /* row 3 is the cross product of rows 1 and 2*/ + Q.m[2][0] = Q.m[0][1]*Q.m[1][2] - Q.m[0][2]*Q.m[1][1] ; /* cross */ + Q.m[2][1] = Q.m[0][2]*Q.m[1][0] - Q.m[0][0]*Q.m[1][2] ; /* product */ + Q.m[2][2] = Q.m[0][0]*Q.m[1][1] - Q.m[0][1]*Q.m[1][0] ; + Q = nifti_mat33_transpose(Q); + if (nifti_mat33_determ(Q) < 0.0) { + Q.m[0][2] = -Q.m[0][2]; + Q.m[1][2] = -Q.m[1][2]; + Q.m[2][2] = -Q.m[2][2]; + } + //next scale matrix + LOAD_MAT33(diagVox, xyzMM[1],0.0l,0.0l, 0.0l,xyzMM[2],0.0l, 0.0l,0.0l, xyzMM[3]); + Q = nifti_mat33_mul(Q,diagVox); + mat44 Q44; //4x4 matrix includes translations + LOAD_MAT44(Q44, Q.m[0][0],Q.m[0][1],Q.m[0][2],patientPosition[1], + Q.m[1][0],Q.m[1][1],Q.m[1][2],patientPosition[2], + Q.m[2][0],Q.m[2][1],Q.m[2][2],patientPosition[3]); + return Q44; +} + +mat44 nifti_mat44_mul( mat44 A , mat44 B ) /* multiply 2 3x3 matrices */ +{ + mat44 C ; int i,j ; + for( i=0 ; i < 4 ; i++ ) + for( j=0 ; j < 4; j++ ) + C.m[i][j] = A.m[i][0] * B.m[0][j] + + A.m[i][1] * B.m[1][j] + + A.m[i][2] * B.m[2][j] + + A.m[i][3] * B.m[3][j]; + return C ; +} + +mat33 nifti_mat33_transpose( mat33 A ) /* transpose 3x3 matrix */ +//see http://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1_io.c +{ + mat33 B; int i,j ; + for( i=0 ; i < 3 ; i++ ) + for( j=0 ; j < 3 ; j++ ) + B.m[i][j] = A.m[j][i]; + return B; +} diff --git a/console/nifti1_io_ext.h b/console/nifti1_io_ext.h new file mode 100644 index 0000000..cdf3c5d --- /dev/null +++ b/console/nifti1_io_ext.h @@ -0,0 +1,39 @@ +#ifndef NIFTI1_IO_EXT_H +#define NIFTI1_IO_EXT_H + +typedef struct { /** x4 vector struct **/ + float v[4] ; +} vec4 ; +typedef struct { /** x3 vector struct **/ + float v[3] ; +} vec3 ; +typedef struct { /** x4 vector struct INTEGER**/ + int v[3] ; +} ivec3 ; + +#define LOAD_MAT33(AA,a11,a12,a13 ,a21,a22,a23 ,a31,a32,a33) \ +( AA.m[0][0]=a11 , AA.m[0][1]=a12 , AA.m[0][2]=a13 , \ +AA.m[1][0]=a21 , AA.m[1][1]=a22 , AA.m[1][2]=a23 , \ +AA.m[2][0]=a31 , AA.m[2][1]=a32 , AA.m[2][2]=a33 ) + +#define LOAD_MAT44(AA,a11,a12,a13,a14,a21,a22,a23,a24,a31,a32,a33,a34) \ +( AA.m[0][0]=a11 , AA.m[0][1]=a12 , AA.m[0][2]=a13 , AA.m[0][3]=a14 , \ +AA.m[1][0]=a21 , AA.m[1][1]=a22 , AA.m[1][2]=a23 , AA.m[1][3]=a24 , \ +AA.m[2][0]=a31 , AA.m[2][1]=a32 , AA.m[2][2]=a33 , AA.m[2][3]=a34 , \ +AA.m[3][0]=AA.m[3][1]=AA.m[3][2]=0.0f , AA.m[3][3]=1.0f ) + +float dotProduct(vec3 u, vec3 v); +int isSameFloat (float a, float b) ; +mat33 nifti_mat33_transpose( mat33 A ) ; +mat44 nifti_dicom2mat(float orient[7], float patientPosition[4], float xyzMM[4]); +mat44 nifti_mat44_mul( mat44 A , mat44 B ); +vec3 crossProduct(vec3 u, vec3 v); +vec3 nifti_vect33_norm (vec3 v); +//vec3 nifti_vect33_norm (vec3 v); +vec3 nifti_vect33mat33_mul(vec3 v, mat33 m ); +//vec3 nifti_vect33mat33_mul(vec3 v, mat33 m ); +vec3 setVec3(float x, float y, float z); +//vec4 nifti_vect44mat44_mul(vec4 v, mat44 m ); +vec4 setVec4(float x, float y, float z); +vec4 nifti_vect44mat44_mul(vec4 v, mat44 m ); +#endif // NIFTI1_IO_EXT_H diff --git a/console/nii_dicom.cpp b/console/nii_dicom.cpp index 52c8060..b919a58 100755 --- a/console/nii_dicom.cpp +++ b/console/nii_dicom.cpp @@ -20,6 +20,7 @@ #include "jpg_0XC3.h" #include "ujpeg.h" #include "nifti1.h" +#include "nifti1_io_core.h" #include "nii_dicom.h" #include #include // discriminate files from folders @@ -31,7 +32,6 @@ #include #include #include -#include "nifti1_io_core.h" #ifdef myUseCOut #include #endif @@ -40,7 +40,7 @@ #endif #ifndef myDisableOpenJPEG - #include //"openjpeg.h" + #include //"openjpeg.h" #ifdef myEnableJasper ERROR: YOU CAN NOT COMPILE WITH myEnableJasper AND NOT myDisableOpenJPEG OPTIONS SET SIMULTANEOUSLY diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index 0b430df..885af22 100755 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -35,11 +35,11 @@ #ifdef myUseCOut #include #endif +#include "tinydir.h" #include "nifti1_io_core.h" #include "nifti1.h" #include "nii_dicom_batch.h" #include "nii_dicom.h" -#include "tinydir.h" #include //toupper #include #include diff --git a/console/nii_io.mm b/console/nii_io.mm index c863a4c..e62e62d 100644 --- a/console/nii_io.mm +++ b/console/nii_io.mm @@ -156,7 +156,11 @@ nifti_image* nifti_convert_nhdr2nim(struct nifti_1_header nhdr, const char * fna if( doswap ) swap_nifti_header( &nhdr , is_nifti ) ; // if ( g_opts.debug > 2 ) disp_nifti_1_header("-d nhdr2nim : ", &nhdr); +#ifdef NIFTI_FOUND + if( nhdr.datatype == DT_BINARY || nhdr.datatype == DT_UNKNOWN ) { +#else if( nhdr.datatype == DT_BINARY || nhdr.datatype == DT_UNKNOWN_DT ) { +#endif NSLog(@"unknown or unsupported datatype (%d). Will attempt to view as unsigned 8-bit (assuming ImageJ export)", nhdr.datatype); nhdr.datatype =DT_UNSIGNED_CHAR; -- 2.6.3