[Insight-users] ImageSeriesReadWrite error - help?

Tim Bhatnagar tim.bhatnagar at gmail.com
Wed Sep 4 12:41:33 EDT 2013


Ah... my reference file is not the same size as this current data set..
apparently just by chance!

Bingo - that was the issue.

Sorry for the trouble, and thanks for responding!

Tim


On Wed, Sep 4, 2013 at 9:33 AM, Tim Bhatnagar <tim.bhatnagar at gmail.com>wrote:

> well, the individual files are displacement fields that were output from
> the ImageRegistration5 routine.
>
> The deformation vector magnitudes will most assuredly be different than
> other sets, but the type of information and file are the same..
>
> Here's the source code:
>
> #include "itkImage.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
> #include "itkNumericSeriesFileNames.h"
> #include "itkPNGImageIO.h"
> #include "itkVTKImageIO.h"
> #include "itkChangeInformationImageFilter.h"
>
>
>
> int main( int argc, char ** argv )
> {
>
>   if( argc < 4 )
>     {
>     std::cerr << "Usage: " << std::endl;
>     std::cerr << argv[0] << " firstSliceValue lastSliceValue
> filenamePrefix  outputImageSuffix " << std::endl;
>     return EXIT_FAILURE;
>     }
>
>
>   typedef unsigned short                       PixelType;
>   const unsigned int Dimension = 3;
>   typedef itk::Vector< float,       3 >  Vector3DType;
>   typedef itk::Image< Vector3DType, 2 >  VectorImage2DType;
>
>   typedef itk::Image< Vector3DType, Dimension >  VectorImage3DType;
>
>   typedef itk::ImageSeriesReader< VectorImage3DType >  ReaderType;
>   typedef itk::ImageFileWriter<   VectorImage3DType >  WriterType;
>
>   ReaderType::Pointer reader = ReaderType::New();
>   WriterType::Pointer writer = WriterType::New();
>
>
>   const unsigned int first = atoi( argv[1] );
>   const unsigned int last  = atoi( argv[2] );
>
>   const char * outputFilesuffix = argv[4];
>
>   std::string format = argv[3];
>   format += "%02d.vtk";
>   std::string format2 = argv[3];
>   format2 += argv[4];
>
>   std::cerr << (format2.c_str() );
>
>
>   typedef itk::NumericSeriesFileNames    NameGeneratorType;
>
>   NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
>
>   nameGenerator->SetSeriesFormat( format.c_str() );
>
>   nameGenerator->SetStartIndex( first );
>   nameGenerator->SetEndIndex( last );
>   nameGenerator->SetIncrementIndex( 1 );
>
>
>   reader->SetImageIO( itk::VTKImageIO::New() );
>
>   reader->SetFileNames( nameGenerator->GetFileNames()  );
>
>   writer->SetFileName( format2.c_str() );
>
>
>   typedef itk::ImageFileReader< VectorImage3DType  > RefImageReaderType;
>
>   RefImageReaderType::Pointer reference = RefImageReaderType::New();
>
>   reference->SetFileName( "48Slice-refField.vtk" ); // this is a reference
> file I have designed
>
>   typedef itk::ChangeInformationImageFilter<
>                             VectorImage3DType >
> ChangeInformationImageFilterType;
>
>   ChangeInformationImageFilterType::Pointer changer =
> ChangeInformationImageFilterType::New();
>
>   changer->UseReferenceImageOn();
>   changer->SetReferenceImage( reference->GetOutput() );
>   changer->SetInput( reader->GetOutput() );
>   changer->ChangeSpacingOn();
>
>   writer->SetInput( changer->GetOutput() );
>
>   try
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & err )
>     {
>     std::cerr << "ExceptionObject caught !" << std::endl;
>     std::cerr << err << std::endl;
>     return EXIT_FAILURE;
>     }
>
>
>   return EXIT_SUCCESS;
> }
>
>
>
> On Wed, Sep 4, 2013 at 9:28 AM, Xiaoxiao Liu <xiaoxiao.liu at kitware.com>wrote:
>
>> Hi,
>> There  seem to be something different in this this last dataset than your
>> other datasets?
>> It's better to post the source code with the question so that others
>> could help the diagnosis.
>> Thanks.
>>
>> -Xiaoxiao
>>
>>
>>
>> On Wed, Sep 4, 2013 at 12:16 PM, Tim Bhatnagar <tim.bhatnagar at gmail.com>wrote:
>>
>>> Hello,
>>>
>>> I am combining a number of vector-component 2D images into a 3D volume,
>>> using ImageSeriesReadWrite.
>>>
>>> The work has been going fine, but with my last sample set, I am
>>> receiving an error:
>>>
>>> requested region is outside largest possible region itk
>>>
>>> Reading some old nabble ITK, I thought this type of error had been
>>> addressed by having an automatic implementation of
>>> UpdateLargestPossibleRegion(), but I'm seeing it here.
>>>
>>> Because this is only occurring on my last dataset (the others functioned
>>> just fine), could someone help me in terms of what to look for/change?
>>>
>>> thanks,
>>>
>>> --
>>> Tim Bhatnagar
>>> PhD Candidate
>>> Orthopaedic Injury Biomechanics Group
>>> Department of Mechanical Engineering
>>> University of British Columbia
>>>
>>> Rm 5000 - 818 West 10th Ave.
>>> Vancouver, BC
>>> Canada
>>> V5Z 1M9
>>>
>>> Ph: (604) 675-8845
>>> Fax: (604) 675-8820
>>> Web: oibg.mech.ubc.ca
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.php
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>
>>
>> --
>>
>>
>> ---------------------------------------------
>> *Xiaoxiao Liu*, Ph.D.
>> R & D Engineer
>> Kitware Inc <http://www.kitware.com/>.
>> Clifton Park, NY
>> Phone: (518) 881-4924  or  (518) 371-3971 x124
>>
>>
>
>
> --
> Tim Bhatnagar
> PhD Candidate
> Orthopaedic Injury Biomechanics Group
> Department of Mechanical Engineering
> University of British Columbia
>
> Rm 5000 - 818 West 10th Ave.
> Vancouver, BC
> Canada
> V5Z 1M9
>
> Ph: (604) 675-8845
> Fax: (604) 675-8820
> Web: oibg.mech.ubc.ca
>



-- 
Tim Bhatnagar
PhD Candidate
Orthopaedic Injury Biomechanics Group
Department of Mechanical Engineering
University of British Columbia

Rm 5000 - 818 West 10th Ave.
Vancouver, BC
Canada
V5Z 1M9

Ph: (604) 675-8845
Fax: (604) 675-8820
Web: oibg.mech.ubc.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/b030b632/attachment.htm>


More information about the Insight-users mailing list