How to read .mnc files using ITK

From Slicer Wiki
Revision as of 00:24, 16 February 2011 by Fedorov (talk | contribs) (Created page with 'Recently, I needed to read .mnc files provided by BrainWeb available here: http://mouldy.bic.mni.mcgill.ca/brainweb/anatomic_normal.html. As it turned out, the format used to sto…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < How to read .mnc files using ITK

Recently, I needed to read .mnc files provided by BrainWeb available here: http://mouldy.bic.mni.mcgill.ca/brainweb/anatomic_normal.html. As it turned out, the format used to store these files is not supported by either Slicer or ITK out of the box. Here are the instructions how to get around this limitation.

ITK 3.18 provides MINC2ImageIO in the review mode, however enabling it does not register the MINC2 IO factory, and some additional hacks are needed. Assuming you have Slicer built from source, you can use the following instructions to be able to read MINC2 files using ITK. This was tested on Ubuntu 10.04 x64:

  • 1 you need to have MINC2 and NETCDF4 installed (on Ubuntu, install minc-tools, libminc2-1, libminc-dev, libnetcdf4, libnetcdf-dev)
  • 2 in Insight-build directory, run "ccmake .", enable ITK_USE_MINC2. If the previous step completed correctly, the dependency libraries will be found, and ccmake configuration will succeed
  • 3 next is the hack part: copy MINC sources to the ITK IO directory
cp Code/Review/*MINC2* Code/IO
  • 4 patch Code/IO/itkImageIOFactory.cxx and Code/IO/CMakeLists.txt to provide support for MINC2
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/IO/CMakeLists.txt,v
retrieving revision 1.98
diff -r1.98 CMakeLists.txt
61a62,63
>   itkMINC2ImageIO.cxx
>   itkMINC2ImageIOFactory.cxx
93c95,97
< ITKniftiio)
---
> ITKniftiio
> ${MINC2_LIB} ${HDF5_LIB} ${NETCDF_LIB}
> )
Index: itkImageIOFactory.cxx
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/IO/itkImageIOFactory.cxx,v
retrieving revision 1.37
diff -r1.37 itkImageIOFactory.cxx
39a40
> #include "itkMINC2ImageIOFactory.h"
122a124
>       ObjectFactoryBase::RegisterFactory( MINC2ImageIOFactory::New() );
  • 5 recompile ITK -- you should be able to read .mnc files now using itkImageFileReader
  • I found that BrainWeb template files are not readable "as is" even after this change, but they are readable by minc-tools. If you apply mincconvert first, you can read the file it produces with ITK:
 mincconvert -2 brainweb.mnc brainweb-fixed.mnc