[Insight-users] Possible bug in Gipl file not being recognized

Raghavendra Chandrashekara rc3@doc.ic.ac.uk
Mon, 31 Mar 2003 12:04:10 +0100


This is a multi-part message in MIME format.
--------------020707080108090503030601
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi Luis,

Sorry the for the delay in replying. I've attached the entire image as 
it's quite a small one.

Thanks,

Raghavendra.

Luis Ibanez wrote:
> Hi Raghavendra,
> 
> The ramp.gipl file was added to Testing after the 1.2 release.
> You can get it through CVS at:
> http://www.itk.org/cgi-bin/cvsweb.cgi/Insight/Testing/Data/Baseline/IO/?cvsroot=Insight 
> 
> 
> ---
> 
> Your test shows that your Gipl file is ok.
> 
> What seems to be failing is the testing criteria of the GIPL
> reader for recognizing your file as a gipl-file.
> 
> Could you please post the header (just the header, not the data)
> of your GIPL file. It should have an extra field, or a missing
> field that is making the GiplImageIO reject the file.
> 
> You can also check the GiplImageIO.cxx file in Insight/Code/IO
> and verify the revision criteria in the method "CanReadFile()".
> 
> 
> 
> Thanks
> 
> 
> Luis
> 
> 
> 
> ----------------------------------------
> 
> Raghavendra Chandrashekara wrote:
> 
>> Just to be on the safe side I cleaned our copy of the ITK repository,
>> updated it again, and built everything from scratch. Unfortunately the
>> ramp.gipl image doesn't seem to be there anymore so I couldn't check the
>> program with the test image. Has the image been removed from the
>> Release-1-2-0 branch?
>>
>> Here's the code that I am using:
>>
>> #include <iostream>
>> #include <iomanip>
>>
>> #include "itkImage.h"
>> #include "itkImageFileReader.h"
>> #include "itkGiplImageIO.h"
>> #include "itkImageFileWriter.h"
>>
>> /* Program reads a GIPL image and writes it out again. */
>> int main(int argc, char** argv)
>> {
>>   if (argc != 3) {
>>     std::cout << std::setiosflags(std::ios::left) << "GIPLIOTest reads an
>> input image file and writes it out again." << std::endl
>>        << std::endl
>>        << "Usage: GIPLIOTest input.gipl output.gipl" << std::endl
>>        << std::endl
>>        << "Where:" << std::endl
>>        << std::endl
>>        << std::setw(30) << "input.gipl" << std::setw(50) << "is the input
>> image" << std::endl
>>        << std::setw(30) << "output.gipl" << std::setw(50) << "is the 
>> output
>> filename" << std::endl;
>>     exit(1);
>>   }
>>
>>   typedef short PixelType;
>>   typedef itk::Image<PixelType, 3> ImageType;
>>   typedef itk::ImageFileReader<ImageType> ReaderType;
>>   typedef itk::ImageFileWriter<ImageType> WriterType;
>>   itk::GiplImageIO::Pointer pGiplImageIO = itk::GiplImageIO::New();
>>
>>   try {
>>     ReaderType::Pointer pReader = ReaderType::New();
>>     WriterType::Pointer pWriter = WriterType::New();
>>
>>     //    pReader->SetImageIO(pGiplImageIO);
>>
>>     pReader->SetFileName(argv[1]);
>>     pWriter->SetFileName(argv[2]);
>>
>>     pWriter->SetInput(pReader->GetOutput());
>>
>>     pWriter->Update();
>>   }
>>   catch (itk::ExceptionObject& ex) {
>>     std::cout << "Exception object caught!" << std::endl;
>>     std::cout << ex << std::endl;
>>     exit(1);
>>   }
>>
>>   return 0;
>> }
>>
>> When I uncomment out the line that sets the GIPL IO object then 
>> everything
>> works fine! So it looks like the image that I am using is alright.
>>
>> Thanks,
>>
>> Raghavendra
>>
>> ----- Original Message -----
>> From: "Luis Ibanez" <luis.ibanez@kitware.com>
>> To: "Raghavendra Chandrashekara" <rc3@doc.ic.ac.uk>
>> Cc: <Insight-users@public.kitware.com>
>> Sent: Friday, March 28, 2003 1:28 PM
>> Subject: Re: [Insight-users] Possible bug in itkAnalyzeImageIO? : Gipl 
>> not
>> being found
>>
>>
>>
>>> Hi Raghavendra,
>>>
>>> Yeap, the code looks right.
>>>
>>> 1) Could you post the piece of code you are using for
>>>    reading the gipl file ?
>>>
>>> 2)  Could you try reading the gipl test file
>>>     that is available in
>>>
>>>        Insight/Testing/Data/Baseline/IO
>>>
>>>     the file name is
>>>
>>>               ramp.gipl
>>>
>>> If this test file works, this may mean that there
>>> is something particular in your gipl file that
>>> prevents the reader from recognizing the format.
>>>
>>> Note that checking the extension .gipl is only the
>>> initial part of the test. Readers verify the content
>>> of the file in order to make sure they are capable
>>> of processing the file.
>>>
>>>
>>> Thanks
>>>
>>>   Luis
>>>
>>>
>>> --------------------------
>>>
>>> Raghavendra Chandrashekara wrote:
>>>
>>>> Hi Luis,
>>>>
>>>> There is a line registering the GiplImageIOFactory but it is on line 
>>>> 98,
>>>> this is the code:
>>>>
>>>> void
>>>> ImageIOFactory::RegisterBuiltInFactories()
>>>> {
>>>>  static bool firstTime = true;
>>>>
>>>>  static SimpleMutexLock mutex;
>>>>  {
>>>>    // This helper class makes sure the Mutex is unlocked
>>>>    // in the event an exception is thrown.
>>>>    MutexLockHolder<SimpleMutexLock> mutexHolder( mutex );
>>>>    if( firstTime )
>>>>      {
>>>>      ObjectFactoryBase::RegisterFactory( DicomImageIOFactory::New() );
>>>>      ObjectFactoryBase::RegisterFactory( MetaImageIOFactory::New() );
>>>>      ObjectFactoryBase::RegisterFactory( PNGImageIOFactory::New() );
>>>>      ObjectFactoryBase::RegisterFactory( VTKImageIOFactory::New() );
>>>>      ObjectFactoryBase::RegisterFactory( GiplImageIOFactory::New() );
>>>>      ObjectFactoryBase::RegisterFactory( AnalyzeImageIOFactory::New());
>>>>      firstTime = false;
>>>>      }
>>>>  }
>>>>
>>>> }
>>>>
>>>> Does it look correct to you? I'm using Release-1-2-0 also.
>>>>
>>>> Thanks,
>>>>
>>>> Raghavendra.
>>>>
>>>> ----- Original Message -----
>>>> From: "Luis Ibanez" <luis.ibanez@kitware.com>
>>>> To: "Raghavendra Chandrashekara" <rc3@doc.ic.ac.uk>
>>>> Cc: <insight-users@public.kitware.com>
>>>> Sent: Friday, March 28, 2003 12:31 PM
>>>> Subject: Re: [Insight-users] Possible bug in itkAnalyzeImageIO? : Gipl
>>>
>>>
>> not
>>
>>>> being found
>>>>
>>>>
>>>>
>>>>
>>>>> Hi Raghavendra,
>>>>>
>>>>> It looks like the GiplImageIO factory
>>>>> is not being found.
>>>>>
>>>>> Could you please double check the file
>>>>>
>>>>> Insight/Code/IO
>>>>>
>>>>>  itkImageIOFactory.cxx
>>>>>
>>>>> and see if in line 99, the following
>>>>> line is not commented out :
>>>>>
>>>>>
>>>>> ObjectFactoryBase::RegisterFactory( GiplImageIOFactory::New() );
>>>>>
>>>>>
>>>>> This lines registers the Gipl reader/writer
>>>>> in the factory mechanism.
>>>>>
>>>>> (I'm assuming you are using ITK version 1.2)
>>>>>
>>>>>
>>>>>
>>>>> Regards,
>>>>>
>>>>>
>>>>>
>>>>> Luis
>>>>>
>>>>>
>>>>> ---------------------------------------------
>>>>> Raghavendra Chandrashekara wrote:
>>>>>
>>>>>
>>>>>> Hi Kent,
>>>>>>
>>>>>> Okay I tried the patch that you sent. Now another exception is 
>>>>>> thrown,
>>>>>
>>>>>
>>>> this
>>>>
>>>>
>>>>>> time by the itkImageFileReader class:
>>>>>>
>>>>>> Exception object caught!
>>>>>>
>>>>>> itk::ImageFileReaderException (0x815ace8)
>>>>>> Location: "Unknown"
>>>>>> File: /vol/vipdata/packages/InsightCVS/Code/IO/itkImageFileReader.txx
>>>>>> Line: 94
>>>>>> Description:  Could not create IO object for file
>>>>>> ../../Data/Synthetic/cube.gipl
>>>>>>
>>>>>> Does this mean that the gipl image is not being recognised by any of
>>>>>
>>>>>
>> the
>>
>>>> IO
>>>>
>>>>
>>>>>> classes?
>>>>>>
>>>>>> Raghavendra.
>>>>>>
>>>>>> ----- Original Message -----
>>>>>> From: "Kent Williams" <kent@mail.psychiatry.uiowa.edu>
>>>>>> To: "Raghavendra Chandrashekara" <rc3@doc.ic.ac.uk>
>>>>>> Sent: Wednesday, March 19, 2003 6:46 PM
>>>>>> Subject: Re: [Insight-users] Possible bug in itkAnalyzeImageIO?
>>>>>>
>>>>>>
>>>>>> I don't know why you're getting that far into CanRead, since the 1.2
>>>>>
>>>>>
>>>> version
>>>>
>>>>
>>>>>> of itkAnalyzeImageIO.cxx checks for valid extensions first before
>>>>>
>>>>>
>> trying
>>
>>>> to
>>>>
>>>>
>>>>>> open the file.
>>>>>>
>>>>>> I think that it's incorrect to throw an exception in CanRead 
>>>>>> anyway; my
>>>>>> suggestion to  you is to patch around line 1000 in that file thusly:
>>>>>>
>>>>>> CHANGE:
>>>>>>   if( local_InputStream.fail() )
>>>>>>     {
>>>>>>       ExceptionObject exception(__FILE__, __LINE__);
>>>>>>       exception.SetDescription("File cannot be read");
>>>>>>       throw exception;
>>>>>>     }
>>>>>>   local_InputStream.read( (char *)&(this->m_hdr), sizeof(struct
>>>>>
>>>>>
>>>> dsr) );
>>>>
>>>>
>>>>>>   if( local_InputStream.eof() )
>>>>>>     {
>>>>>>       ExceptionObject exception(__FILE__, __LINE__);
>>>>>>       exception.SetDescription("Unexpected end of file");
>>>>>>       throw exception;
>>>>>>     }
>>>>>> TO:
>>>>>>   if( local_InputStream.fail() )
>>>>>>     {
>>>>>> return false;
>>>>>>     }
>>>>>>   local_InputStream.read( (char *)&(this->m_hdr), sizeof(struct
>>>>>
>>>>>
>>>> dsr) );
>>>>
>>>>
>>>>>>   if( local_InputStream.eof() )
>>>>>>     {
>>>>>> return false;
>>>>>>     }
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Insight-users mailing list
>>>>>> Insight-users@public.kitware.com
>>>>>> http://public.kitware.com/mailman/listinfo/insight-users
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Insight-users mailing list
>>>>> Insight-users@public.kitware.com
>>>>> http://public.kitware.com/mailman/listinfo/insight-users
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users@public.kitware.com
>>> http://public.kitware.com/mailman/listinfo/insight-users
>>>
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users@public.kitware.com
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users


--------------020707080108090503030601
Content-Type: application/x-gunzip;
 name="sphere.gipl.gz"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="sphere.gipl.gz"

H4sICKF9eD4CA3NwaGVyZS5naXBsAO3dza3kZBQE0CYC8pgkmIxIge1kRDhIBGKENGwQP2/e
PLvKrnNabFhQveB127euv359fv35+uH140+/vF5//XOGf/rvvvXf/bfPP//2rnf06fcvv74A
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAACAezi+vrLpmXdw/O2VTb/6Hcg/yv4PWPv7y3/+AAAAAAAA8JGW+9fjX17Z
9GvewfE/L/ny5T83P/35k//8zX//5L9/AQAAAADgPD1PH+/0z9v91/GGVzb9zHewnX98w0v+
8/L9/aXz05+/vv/y1x8N11/5608AAAAAgLMk56/Lzz8v98/b/ePxjS/58uXLf0q+/RP7F/nr
r/z1Z/76GwAAAACer+3Xjzee/9Z/658T+cc7Xs/JP975ki9f/v3z1z//fP/lrz/y11/568/8
9Xf+/qPh/gsAAACAs60+f67/3uy/9c+7/dvxHS/58uXLv3O+/Qv7F/Yf8tff+fuP/P1Xw/0n
AAAAwBVy84/d58/13/pv/fNa/vGdL/ny5cu/a77vH/sX9h/sP+TvvxruP/P33wAAAEDu7n/h
/HfPn2/27/pv/XMm//iAl3z58uXLv1++/Qv7D/Yf8vcf+fuv/P1n/v67Yf4AAAAA19l8/l3/
rn9f69/13/qnVP7xQS/58uXLv1u+7x/7D/Yf7B/k77/y95/5++/8/KFh/gIAAMCV9O/69+7T
P/3++BP6d/2z/iuVf3zgS758+fLvlO/7x/6F/Qf7Bw37D/YP8vOH/PylYf4EAABwtdzdT/Lu
z++/7/Xvzn/Xv+vf9d9b+ccHv+TLl3+ffJ+/9h/sH9g/8PsP9g8a5g/5+UvD/Klh/gYAACzJ
3f3o350/7/n3lf5d/61/0X/Lly9fvnz7D/Yf7D/YP/D7C35/YXf/IDl/AwAAruf8+6vfg/5d
/65/17/rv/VP5+cfJ7zky5c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