[ITK] problem (and fix?) for Nifti IO with very large number of elements in file
Kris Thielemans
kris.f.thielemans at gmail.com
Sun Aug 17 09:42:50 EDT 2014
Dear all
My Nifti file is very large (448x512x176 x141). After a lot of pain, I
discovered that it doesn't get read completely by the ITK Nifti IO image
reader. The reason is that the number of elements is computed as an integer,
which is 32bit on my system (Ubuntu 12.04, gcc 4.6.3). Below is an easy
patch that seems to solve the problem. (It also fixes a compilation error in
the file when __USE_VERY_VERBOSE_NIFTI_DEBUGGING__ is on, as then it refers
to a nonexisting variable tobuffer, so I've just commented that line out).
I'm afraid I don't have the resources to put in a bug report (in fact, I
couldn't register as https://issues.itk.org/jira/secure/Signup.jspa seems to
ask for a captcha, but I can't see any in my firefox window), nor for adding
a test case etc, so I'm hoping somebody else will take this further.
Please also reply to my email address as I might miss anything sent to the
list.
Kris Thielemans
Senior Lecturer at University College London
Institute for Nuclear Medicine, UCL Hospital
diff --git a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
index 25d85d3..491bcd1 100644
--- a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
+++ b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
@@ -409,7 +409,7 @@ void RescaleFunction(TBuffer *buffer,
double intercept,
size_t size)
{
- for ( unsigned int i = 0; i < size; i++ )
+ for ( size_t i = 0; i < size; i++ )
{
double tmp = static_cast< double >( buffer[i] ) * slope;
tmp += intercept;
@@ -437,7 +437,7 @@ void NiftiImageIO::Read(void *buffer)
ImageIORegion::SizeType size = regionToRead.GetSize();
ImageIORegion::IndexType start = regionToRead.GetIndex();
- int numElts = 1;
+ size_t numElts = 1;
int _origin[7];
int _size[7];
unsigned int i;
@@ -1933,7 +1933,7 @@ NiftiImageIO
}
delete[] vecOrder;
dumpdata(buffer);
- dumpdata(tobuffer);
+ //dumpdata(tobuffer);
//Need a const cast here so that we don't have to copy the memory for
//writing.
this->m_NiftiImage->data = (void *)nifti_buf;
More information about the Community
mailing list