Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add support for MINC image IO #716

Closed
wants to merge 1 commit into from
Closed

Conversation

thewtex
Copy link
Member

@thewtex thewtex commented Apr 27, 2017

Issue #4085

This enables MINC Image IO via ITK. This currently supports MINC version 2
(HDF5-based).

@vovythevov
Copy link

LGTM ! Thanks for the contribution !

@thewtex
Copy link
Member Author

thewtex commented Apr 27, 2017

Tested locally on Linux.

CC: @lassoan @jcfr @vfonov @gdevenyi

@fedorov
Copy link
Member

fedorov commented Apr 27, 2017

xref CoBrALab/atlases#6

@thewtex
Copy link
Member Author

thewtex commented Apr 27, 2017

@fedorov Thanks for the note!

I am trying to update ITK's MINC to address the reported Windows build issue...

@vfonov
Copy link

vfonov commented Apr 27, 2017

So, what is the problem now?

@thewtex
Copy link
Member Author

thewtex commented Apr 27, 2017

ITK's libminc is updated to the latest develop branch version here:

http://review.source.kitware.com/#/c/22329/

This includes: BIC-MNI/libminc@d8cdab3 but newer Visual Studio may still not work because of BIC-MNI/libminc#77

@thewtex
Copy link
Member Author

thewtex commented Apr 27, 2017

Spoke too soon: the update does include BIC-MNI/libminc@9679353

@lassoan could you please test? We should then mark BIC-MNI/libminc#77 as closed if it has been addressed.

@fedorov
Copy link
Member

fedorov commented Apr 27, 2017

@thewtex I can test on mac, if this would help, but I won't find time to rigorously examine the code (I see you assigned me on gerrit), I have no familiarity with this library at all.

Let me know if it would help if I test this branch on mac, I don't want to do if someone else is already did/doing it.

@thewtex
Copy link
Member Author

thewtex commented Apr 27, 2017

@fedorov Thanks, yes that would help. I only tested on Linux. To test, check out the branch:

git fetch http://review.source.kitware.com/ITK refs/changes/29/22329/1 && git checkout FETCH_HEAD

and set Module_ITKIOMINC=1 in ITK's CMake configuration.

To build only ITKIOMINC module,

make ITKIOMINC-all

To run just the MINC tests:

ctest -L ITKIOMINC

@fedorov
Copy link
Member

fedorov commented Apr 27, 2017

@thewtex ok I will test ITK as you suggested.

Should we test if this causes any issues with SimpleITK?

Isn't this specific PR premature, as it would need to also include an update to ITK which is not finalized itself yet?

@thewtex
Copy link
Member Author

thewtex commented Apr 27, 2017

@fedorov thanks!

I do not anticipate any issues with SimpleITK.

Yes, we will need to get the fixes into ITK first, then update Slicer's version of ITK.

@lassoan
Copy link
Contributor

lassoan commented Apr 27, 2017

@thewtex What should I test? Should I try to build the version in this PR? If a custom ITK version is needed, could you update the ITK repository/git tag in SuperBuild\External_ITKv4.cmake to that version?

@fedorov
Copy link
Member

fedorov commented Apr 28, 2017

Here is the error I am getting on mac compiling ITK branch @thewtex asked me to test:

[ 89%] Building C object Modules/ThirdParty/MINC/src/libminc/CMakeFiles/itkminc2.dir/libcommon/minc_error.c.o
In file included from /Users/fedorov/github/ITK/Modules/ThirdParty/MINC/src/libminc/libcommon/minc_error.c:92:
In file included from /Users/fedorov/github/ITK/Modules/ThirdParty/MINC/src/libminc/libsrc/minc_private.h:83:
/Users/fedorov/github/ITK/Modules/ThirdParty/MINC/src/libminc/libsrc/minc.h:171:10: fatal error: 'netcdf.h' file not found
#include <netcdf.h>
         ^
1 error generated.

@lassoan
Copy link
Contributor

lassoan commented Apr 28, 2017

The issue of MINC support came up a couple of times in the past but we failed to add it due that there were always build errors on non-Linux platforms.

Considering persistent build issues, lack of cross-platform interest of MINC developers, and existence of a number of other well-supported alternative file formats, I would consider moving away from this format, maybe even move it from ITK proper to a remote module.

@vfonov
Copy link

vfonov commented Apr 28, 2017

@fedorov - somehow it is configured to search for NetCDF , can you send configuration parameters?

@fedorov
Copy link
Member

fedorov commented Apr 28, 2017

@vfonov: as mentioned earlier by @thewtex, the proposed modification to ITK to include MINC support is in this branch: http://review.source.kitware.com/#/c/22329/. Instructions how to build it are provided here: Slicer/Slicer#716 (comment). If you have a mac, you should be able to reproduce the issue and debug it.

I don't know how and where configuration parameters are passed -- it is configured as a third-party module of ITK, and I don't know the details of implementation.

vfonov referenced this pull request in BIC-MNI/libminc Apr 28, 2017
vfonov referenced this pull request in BIC-MNI/libminc Apr 28, 2017
vfonov referenced this pull request in BIC-MNI/libminc Apr 28, 2017
@vfonov
Copy link

vfonov commented Apr 28, 2017

Here are my updates: http://review.source.kitware.com/#/c/22331/

To test it , I configure with -DITK_USE_SYSTEM_MINC:BOOL=OFF -DModule_ITKIOMINC:BOOL=ON -DModule_ITKIOTransformMINC:BOOL=ON -DModule_ITKMINC:BOOL=ON

To compile: make ITKIOMINC-all ITKIOTransformMINC-all

And to run tests: ctest -L ITKIOTransformMINC -L ITKIOMINC

@fedorov
Copy link
Member

fedorov commented Apr 28, 2017

@vfonov great!

  1. git fetch http://review.source.kitware.com/ITK refs/changes/31/22331/1 && git checkout FETCH_HEAD
  2. cd ITK-build && cmake -DITK_USE_SYSTEM_MINC:BOOL=OFF -DModule_ITKIOMINC:BOOL=ON -DModule_ITKIOTransformMINC:BOOL=ON -DModule_ITKMINC:BOOL=ON ../ITK
  3. make ITKIOMINC-all ITKIOTransformMINC-all
  4. Build worked without problems on mac!
  5. All tests passed except ITKIOMINCKWStyleTest, but I think this is due to mis-configuration on my machine.

thewtex referenced this pull request in thewtex/ITK Apr 29, 2017
Run the UpdateFromUpstream.sh script to extract upstream MINC
using the following shell commands.

$ git archive --prefix=upstream-minc/ 3d79acf3 -- 
./ChangeLog
./volume_io
./libsrc
./libsrc/minc_compat.h
./libcommon/minc_config.h
./libcommon/minc_config.c
./libsrc/minc_format_convert.c
./libsrc/value_conversion.c
./libsrc/hdf_convenience.c
./libcommon/read_file_names.c
./libsrc/minc_simple.c
./libcommon/time_stamp.h
./libsrc/hdf_convenience.h
./libsrc/type_limits.h
./libcommon/read_file_names.h
./libsrc/minc_varlists.h
./libcommon/restructure.h
./libsrc/nd_loop.h
./libcommon/restructure.c
./libsrc/minc_simple.h
./libsrc/strdup.c
./libsrc/minc_useful.h
./libsrc/minc_convenience.c
./libsrc/minc_basic.h
./libsrc/minc_compat.c
./libcommon/time_stamp.c
./libsrc/voxel_loop.h
./libsrc/minc_routines.h
./libsrc/minc_private.h
./libsrc/netcdf_convenience.c
./libsrc/voxel_loop.c
./libsrc/dim_conversion.c
./libsrc/minc_format_convert.h
./libsrc/nd_loop.c
./libcommon/ParseArgv.h
./libcommon/minc_error.c
./libcommon/minc_error.h
./libsrc/minc_structures.h
./libsrc/minc.h
./libsrc/image_conversion.c
./libcommon/ParseArgv.c
./libcommon/minc_common_defs.h
./COPYING
./UseLIBMINC.cmake.in
./NEWS
./AUTHORS
./libsrc2/m2util.c
./libsrc2/minc2_defs.h
./libsrc2/minc2_api.h
./libcommon/minc2_error.h
./libsrc2/grpattr.c
./libsrc2/hyper.c
./libsrc2/minc_compat2.h
./libcommon/minc2_error.c
./libsrc2/record.c
./libsrc2/volume.c
./libsrc2/datatype.c
./libsrc2/volprops.c
./libsrc2/valid.c
./libsrc2/convert.c
./libsrc2/free.c
./libsrc2/dimension.c
./libsrc2/label.c
./libsrc2/minc2.h
./libsrc2/minc2_private.h
./libsrc2/slice.c
./libsrc2/minc2_structs.h
./CMakeLists.txt
./nifti
./LIBMINCConfig.cmake.in
./README.release
./INSTALL
./config.h.cmake
./README
 | tar x
$ git shortlog --perl-regexp --author='^((?!Kitware Robot).*)$' --no-merges --abbrev=8 --format='%h %s' 8632513e..3d79acf3

Chris Hammill (1):
      06f3e87b Unsatisfying solution to issue InsightSoftwareConsortium#71

Robert D. Vincent (34):
      5b483ac0 Fix problem discovered by Jerome Redoute - voxel_loop programs do not properly remove the loop dimension if it contains a 'xxxx-width' variable.
      59678daa Minor fixes for MINC2.0 API. Implement alignment, properly record dimorder for irregular dimension variables, quiet some errors.
      f0126d35 Hopefully useful version of minc_get_world_transform() and new function minc_transform_to_world().
      3775a0a9 Propagate read errors such that voxel_loop() now returns an integer exit code.
      2e33bca0 Propagate read errors through volume_io as well.
      5ac1aca8 Fix warning.
      3ca34259 Correctly place attributes intended for the image variable (e.g. 'complete').
      25792953 Avoid repetitive code while correcting placement of attributes within the HDF5 hierarchy.
      17aa090d Fix BIC-MNI/minc-tools#45 - add quotes around argv items that contain spaces.
      e7101d7a Make sure variable is initialized.
      d99dd016 Fix InsightSoftwareConsortium#74, don't assume hid_t === int since this is no longer true in HDF5 1.10.
      e7df7ce1 Minor fixes so that miclose() return value is correct.
      2f6b922f Fix issues with proper ranging of data in NIfTI files.
      6fbea42f Fix memory leaks to keep LeakSanitizer happy.
      eb7cf239 Add multidim array tests.
      1f4a4c5a Fix warnings.
      3f0c0389 Fix BIC-MNI/Display#63, Ignore MGZ/freesurfer offsets so that volumes align with their surfaces.
      00ac284f Fix warnings for unused variables (in an unused test).
      3b2df807 Major fix to NIfTI reading for images with non-standard transforms.
      f01e9be2 Fix problem if scl_slope is zero.
      063fce99 Correctly read NIfTI files with a fifth dimension.
      1e1b300d Attempt to improve speed of NIfTI loader.
      f3f881fe Fix bug in nifti reader.
      433acc15 Implement some additional special cases for volume interpolation.
      85733672 Basic reader for NRRD format.
      14cee37d Fix minor memory leak.
      baced81b Add libcommon to LIBMINC_INCLUDE_DIRS_CONFIG so that minctools will build.
      931df645 Fix InsightSoftwareConsortium#78, correct documentation for miget_dimension_sampling_flag().
      c3841475 Fix use-after-free error.
      3d5a2277 Fix range calculation for small NIfTI files.
      62a6a849 Fix InsightSoftwareConsortium#80, memory leaks in hyperslab reading.
      b2fdfff7 testing for leaks.
      4d68e862 Free memory at end of test.
      3daa90b4 Fix issue when copying a non-allocated volume.

Vladimir S. FONOV (38):
      2c9fe645 Removing allocation  debug code, it is superseded by address sanitizer or valgrind
      d3ab23b5 Added proper flag to MIcomplete when minc file is successfully closed
      39d86771 Replaced C++ comment to C comment
      6ef58fe9 Added option to work with integer labels (avoid inter-slice scaling)
      9c27bde6 Disabled writing of complete flag temporarely
      5df49651 WIP: adding labels to volumeio
      89a82cf9 WIP: modifying volume_io to work properly with labels
      466cdede WIP: adding possibility to debug minc2 volume io interface
      bbf80974 Added labels support in volume_io and a new environment configuration variable MINC_PREFER_V2_API to force volume_io to use MINC2 API directly, mostly for debugging purposes
      3764357a Finalizing MINC2 api choise support in volume_io
      0bd33a2e Fixed segfault that creeped in after the previous commit
      46261240 Tweaking voxel_loop
      745d75a9 Removed FindHDF5 and bumped cmake version requirements, addresses InsightSoftwareConsortium#71
      d641c4fd Updating HDF5 variables, fixing libnifti internal build dependencies
      b45312d9 Disabled allocation debugging in volume_io - superceded by valgrind and asan
      21125c4b Downgraded cmake requirements to satisfy travis-ci
      44b8d4b3 Fixed memory leak in minc_long_attr tests
      92ba4fa2 Fixing function forgotten in d99dd01632dbcb62870870557b333142b9117e9a , related to InsightSoftwareConsortium#74
      eb7eb487 Fixing memory leak, addresses InsightSoftwareConsortium#75
      70a27484 Added description of environment variables
      96793536 Added explicit test for rint, addresses InsightSoftwareConsortium#77
      f134ca9c Updated brew control sum for HDF5
      eecefd5d Refactoring minc2 internals
      34b08c7e Trying to make travis-build happy
      d9d98771 Fixed dimorder variable contents for image-min and image-max
      54169226 Made some tests actually perform something meaningless and report errors if things don't work
      dbf3e037 Minor change: fixed comments
      dd93215a Refactring error handling in volume_io
      f864dd22 Fixing failed build when MINC1 support is disabled
      bb7ce2db Refactoring common minc1&minc2 code
      a74eef51 Refactoring minc error reporting
      cba6f09b Bumped package patch version
      b1cd7f50 Updated comment for restructure
      d8cdab34 Hopefully fixes compilation issue on Windows, addresses CoBrALab/atlases#6
      bd17b1f2 Replaced c++ style comment with c
      a44cf8de Added a hack to address BIC-MNI/minc-tools#59
      f8f16142 Fixed volume_io error reporting routine, adresses BIC-MNI/Register#16
      3d79acf3 Fixing issue from Slicer/Slicer#716: moved code from libsrc into libcommon, removed unused varable

Change-Id: I8d3238e3bf830b6c4df9a64df35567e01268a030
@thewtex
Copy link
Member Author

thewtex commented Apr 29, 2017

Hats off to @vfonov for the update!

@lassoan Here is a branch that includes the MINC/ITK update: https://github.com/thewtex/Slicer/tree/minc-io-with-itk-update

@lassoan
Copy link
Contributor

lassoan commented Apr 29, 2017

@thewtex Thanks, I've started a build of https://github.com/thewtex/Slicer/tree/minc-io-with-itk-update on Win10 with VS2013.

Build failed with this error:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(515): error C2375: 'rint' : redefinition; different linkage [C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\MINC\src\libminc\itkminc2.vcxproj] [C:\D\E\Slicer-0-build\ITKv4.vcxproj]

            c:\d\e\slicer-0-build\itkv4\modules\thirdparty\minc\src\libminc\libsrc2\minc2_private.h(209) : see declaration of 'rint'

full log:
https://1drv.ms/t/s!Arm_AFxB9yqHr6o8nrmLx-Tlnu-aDQ

@thewtex
Copy link
Member Author

thewtex commented May 1, 2017

@lassoan Thanks for testing on the target compiler / platform.

It looks like the system has rint, but HAVE_RINT is not defined -- this patch may address the issue:

BIC-MNI/libminc#83

@thewtex
Copy link
Member Author

thewtex commented May 1, 2017

@lassoan
Copy link
Contributor

lassoan commented May 1, 2017

Build failed with this error:

35> Project "C:\D\E\Slicer-0-build\ITKv4-build\ALL_BUILD.vcxproj" (1) is building "C:\D\E\Slicer-0-build\ITKv4-build\Modules\IO\MINC\src\ITKIOMINC.vcxproj" (110) on node 1 (default targets).
35> Project "C:\D\E\Slicer-0-build\ITKv4-build\Modules\IO\MINC\src\ITKIOMINC.vcxproj" (110) is building "C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\MINC\src\libminc\itkminc2.vcxproj" (111) on node 1 (default targets).
35> InitializeBuildStatus:
35> Touching "itkminc2.dir\Release\itkminc2.tlog\unsuccessfulbuild".
35> CustomBuild:
35> All outputs are up-to-date.
35> ClCompile:
35> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\CL.exe /c /I"C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\ZLIB\src" /I"C:\D\E\Slicer-0-build\zlib-install\include" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\HDF5\src" /I"C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\HDF5\src" /I"C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\KWSys\src" /I"C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\MINC" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\libcommon" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\libsrc2" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\volume_io\Include" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\HDF5\src\itkhdf5" /I"C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\HDF5\src\itkhdf5" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\HDF5\src\itkhdf5\src" /I"C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\MINC\src\libminc" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\libsrc" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\ezminc" /I"C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\HDF5\src\itkhdf5\c++\src" /I"C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\HDF5\src\itkhdf5\c++\src" /I"C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\HDF5\src\itkhdf5\src" /nologo /W0 /WX- /O2 /Ob2 /D WIN32 /D _WINDOWS /D NDEBUG /D _CRT_FAR_MAPPINGS_NO_DEPRECATE /D _CRT_IS_WCTYPE_NO_DEPRECATE /D _CRT_MANAGED_FP_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _CRT_SECURE_NO_DEPRECATE /D _CRT_SECURE_NO_DEPRECATE_GLOBALS /D _CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE /D _CRT_TIME_FUNCTIONS_NO_DEPRECATE /D _CRT_VCCLRIT_NO_DEPRECATE /D _SCL_SECURE_NO_DEPRECATE /D HAVE_CONFIG_H /D MINC2=1 /D "CMAKE_INTDIR="Release"" /D _MBCS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR /Fo"itkminc2.dir\Release\" /Fd"itkminc2.dir\Release\vc120.pdb" /Gd /TC /errorReport:queue /bigobj "C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\libsrc2\dimension.c" "C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\libsrc2\hyper.c"
35> dimension.c
35>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(515): error C2375: 'rint' : redefinition; different linkage [C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\MINC\src\libminc\itkminc2.vcxproj]
35> c:\d\e\slicer-0-build\itkv4\modules\thirdparty\minc\src\libminc\libsrc2\minc2_private.h(210) : see declaration of 'rint'
35> hyper.c
35>C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\libsrc2\hyper.c(52): error C2084: function 'double copysign(double,double)' already has a body [C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\MINC\src\libminc\itkminc2.vcxproj]
35> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(483) : see previous definition of 'copysign'
35>C:\D\E\Slicer-0-build\ITKv4\Modules\ThirdParty\MINC\src\libminc\libsrc2\hyper.c(65): error C2084: function 'double round(double)' already has a body [C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\MINC\src\libminc\itkminc2.vcxproj]
35> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(516) : see previous definition of 'round'
35> Generating Code...
35> Done Building Project "C:\D\E\Slicer-0-build\ITKv4-build\Modules\ThirdParty\MINC\src\libminc\itkminc2.vcxproj" (default targets) -- FAILED.
35> Done Building Project "C:\D\E\Slicer-0-build\ITKv4-build\Modules\IO\MINC\src\ITKIOMINC.vcxproj" (default targets) -- FAILED.

I start a clean build now.

@thewtex Would you like to get access to the computer so that you can test and fix the errors directly? If yes then send me a message in private.

@thewtex
Copy link
Member Author

thewtex commented May 1, 2017

@lassoan Thanks for checking.

If the error persists after a fresh build, I'll try to reproduce on a different box, and, if I still persists, debugging on the target will be very helpful.

@lassoan
Copy link
Contributor

lassoan commented May 1, 2017

The error is the same when starting the build from scratch. See full build log here (first error is around line 79121): https://1drv.ms/t/s!Arm_AFxB9yqHr61zxIsdFj_PLLf5qw

Issue #4085

This enables MINC Image IO via ITK. This currently supports MINC version 2
(HDF5-based).
@thewtex
Copy link
Member Author

thewtex commented May 10, 2017

Rebased on Slicer master, which now includes updated ITK, which includes updated libminc. These include fixes for Visual Studio.

@@ -55,6 +55,7 @@ ITKImageFileFormat FileFormatTable[] =
{"MGHImageIO", "Uncompressed FreeSurfer pixel data in binary", "MGH", ".mgh"},
{"MGHImageIO", "Gzip Compressed FreeSurfer pixel data in binary", "MGH", ".mgz"},
{"MGHImageIO", "Gzip Compressed FreeSurfer pixel data in binary", "MGH", ".mgh.gz"},
{"MINCImageIO", "Optional compression. Binary pixel data", "MINC", ".mnc"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a line line like this be added then:

{"MINCImageIO", "Gzip Compressed binary pixel data", "MINC", ".mnc.gz"},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be careful here, classically, .mnc.gz files are "MINC1" aka NetCDF files, which the ITK MINC IO can't open.

.mnc files are now typically MINC2 files which are HDF5 with internal zlib compression built into the filespec.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integrated MINC ITK reader is based only on MINC2 library, and is not capable of reading MINC1 files.
If one would compile full minc library (with MINC1 & MINC2 support) and incorporated it into Slicer, then ITK would be able to read .mnc.gz files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback.

Would the following be correct then:

{"MINCImageIO", "MINC2 binary pixel data using HDF5 with internal zlib compression", "MINC2", ".mnc"},

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks right.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compression have to be enabled though, through SetUseCompression / UseCompressionOn - methods of ImageIOBase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, I will plan on using this then:

{"MINCImageIO", "MINC2 binary pixel data using HDF5 with optional internal zlib compression", "MINC2", ".mnc"},

@jcfr
Copy link
Member

jcfr commented May 15, 2017

Integrated in r26011

@lassoan That said, could you confirm that loading the sample data pd_z-_float_xyz.mnc gives the expected results:

http://slicer.kitware.com/midas3/item/286044

mnc_slicer

@jcfr jcfr closed this May 15, 2017
@lassoan
Copy link
Contributor

lassoan commented May 16, 2017

I've tested this and Reading/writing .mnc files work well on Windows.

@thewtex
Copy link
Member Author

thewtex commented May 16, 2017

🍾 Thanks all for working together to make this happen!

@thewtex thewtex deleted the minc-io branch May 16, 2017 17:44
@jcfr
Copy link
Member

jcfr commented May 17, 2017

@thewtex when compiling Slicer using centos 5 with g++ 4.8.2 from the latest version of docker-centos-build, it reports the following error:

/usr/src/Slicer-build/ITKv4/Modules/ThirdParty/MINC/src/libminc/libsrc2/hyper.c:64:1: error: redefinition of ‘round’
 round(double x)
 ^

@jcfr
Copy link
Member

jcfr commented May 17, 2017

The try_compile associated with Modules/ThirdParty/MINC/src/libminc/CMakeLists.txt#L125 returns the following:

/opt/rh/devtoolset-2/root/usr/bin/gcc    -Wno-uninitialized -Wno-unused-parameter -Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winvalid-pch -Wno-format-nonliteral -Wpointer-arith -Wshadow -Wunused -Wwrite-strings -funit-at-a-time -Wno-strict-overflow  -w   -fPIC  -fPIE -o CMakeFiles/cmTC_5d14a.dir/CheckSymbolExists.c.o   -c /usr/src/Slicer-build/ITKv4-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/usr/src/Slicer-build/ITKv4-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function ‘main’:
/usr/src/Slicer-build/ITKv4-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: ‘round’ undeclared (first use in this function)
   return ((int*)(&round))[argc];
                   ^
/usr/src/Slicer-build/ITKv4-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in

@jcfr
Copy link
Member

jcfr commented May 17, 2017

The issue is that the C99 extension is not enabled during introspection, adding the following to the CMakeLists addressed the problem (adapted from python-cmake-buildsystem/python-cmake-buildsystem):

# Convenient macro allowing to update CMAKE_REQUIRED_DEFINITIONS
set(CMAKE_REQUIRED_DEFINITIONS )
macro(set_required_def var value)
  set(${var} ${value})
  list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${var}=${value}")
endmacro()

set_required_def(_GNU_SOURCE 1)       # Define on Linux to activate all library features

@jcfr
Copy link
Member

jcfr commented May 17, 2017

The following commit should be backported and integrated: Slicer/ITK@3cc1a24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants