[Insight-users] FW: Dicom Series reader and Image Registration

Luis Ibanez luis.ibanez at kitware.com
Wed, 03 Mar 2004 23:16:20 -0500


Hi Raghu,

There are two implementation of DICOM readers in ITK 1.4.
They are:


    Insight/Code/IO/
                  DICOMImageIO
                  DICOMImageIO2


DICOMImageIO2 is more recent than DICOMImageIO and use
a different parser mechanism based on the library in

       Insight/Utilities/DICOMParser

They have different levels of verfication of compliance
with the DICOM format. It is likely that in one machine
you are using DICOMImageIO and in the other DICOMImageIO2.
Only one of them complains about magic numbers.


You may want try reading your DICOM files with MRIConvert
http://lcni.uoregon.edu/~jolinda/MRIConvert

or with VolView
http://www.kitware.com/products/volview.html

--

About methods for evaluating registration result you may
want to look at the publications by Fitzpatrick
http://www.vuse.vanderbilt.edu/~jmf/jmf.html

and the retrospective image registration evaluation project
http://www.vuse.vanderbilt.edu/~image/registration/

you may also want to look at the book:
"Medical Image Registration" by Hajnal, Hill and Hawkes


---


In the deformable case you can speed up convergence
(if using Demons) if you precompute a deformation field
and provide it as initialization.

In the FEM case, fiducial will not directly help to speed
up convergence, but they will allow you to define anatomical
features that should match between the two images, and by
doing so you can restrict the evolution of the deformation.

All coordinates in registration should be interpreted in the
physical coordinate system of the fixed image.  You may have
to look at the origin and spacing of your image in order to
get an idea of this coordinate frame.


Regards,


    Luis


-----------------------
raghu venkatram wrote:

> 
> 
> Hi Luis,
> Thank you for replying, it looks like dicom series reader is rather 
> strange. I checked with one of my co workers, and it works fine on her 
> machine, the same computer, OS, using ITK 1.4, same data.  I do see the 
> "no magic number warning", but it reads in all the files, unlike on my 
> computer, where it generates all the file names and gives an abnormal 
> program termination error, the same happens with yet another coworker of 
> mine.
> 
> the registration aspect, i am using analyze files generated by MRICro 
> for the timebeing.
> ct data: 512x 512x58
> mr data: 256x 256 x 72
> 
> the ct pixel sizes are roughly half the size of mr pixels, so spatially 
> they occupy approx. the same volume.
> 
> Mattesmutual information metric with 50,000 samples, time: 6-8 mins. I 
> was wondering if you could suggest methods to evaluate registration 
> results. are there any papers, guidlines as far as the number of samples 
> goes?
> 
> also in the deformable case would using a pre-computed mesh be possible, 
> to reduce time.
> 
> would using landmarks/fiducials help in improving time complexity?
> i have seen the format of the landmarks file, but i was wondering as to 
> what origin/coordinate system was used, is the origin in the center of 
> the volume, or the top left hand corner of the volume?
> 
> I apologize if my questions are too lame or have been previously stated.
> 
> 
> Thanks in advance.
> Raghu
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>> From: Luis Ibanez <luis.ibanez at kitware.com>
>> To: raghu venkatram <raghu_420 at hotmail.com>
>> CC: insight-users at itk.org
>> Subject: Re: [Insight-users] FW:
>> Date: Wed, 03 Mar 2004 17:04:46 -0500
>>
>>
>> Hi Raghu,
>>
>>
>> Good news:   Your code works for me.
>>
>>
>> Bad news:    Your data seems to be the problem.
>>
>>
>>
>> The fact that you are getting the warning about
>> the "no magic number" is a bad sign about the
>> compliance of your files with the DICOM standard.
>>
>> You may want to get back to your data source
>> and complaint about the format used for your files.
>>
>>
>> Regards,
>>
>>
>>    Luis
>>
>>
>>
>> ----------------------
>> raghu venkatram wrote:
>>
>>> Hi Luis,
>>>
>>> I wish that was the problem, but i understand that the 0/1 flag is 
>>> controls the ordering of the images. Also I have commented out the 
>>> writing out part. For the time being i am just trying to read in the 
>>> series from a directory which contains only one series and no other 
>>> files. I see the filenames in the series, also it gives me the 'no 
>>> magic number warning', for both dicom and dicom2iofactory. and after 
>>> it spits out all the file names, it gives an abnormal program 
>>> termination error.
>>>
>>> Thanks
>>>
>>> Raghu
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>  >From: Luis Ibanez
>>>  >To: raghu venkatram
>>>  >CC: insight-users at itk.org
>>>  >Subject: Re: [Insight-users] FW:
>>>  >Date: Tue, 02 Mar 2004 17:53:09 -0500
>>>  >
>>>  >
>>>  >Hi Raghu,
>>>  >
>>>  >The problem seems to be with the arguments that you
>>>  >are passing to the program. Right now you are using
>>>  >the example in:
>>>  >
>>>  >
>>>  >   Insight/Examples/IO/
>>>  >             DicomSeriesReadImageWriter.cxx
>>>  >
>>>  >
>>>  >This program expects as argument:
>>>  >
>>>  >
>>>  >   1) The directory where the DICOM files are
>>>  >
>>>  >   2) The filename of an output image file where the
>>>  >      set of image slices will be saved as a 3D dataset.
>>>  >
>>>  >   3) A *string identifying a dicom series*
>>>  >
>>>  >
>>>  >You are passing:
>>>  >
>>>  >    F:\itk\data\MR\temp1\  0
>>>  >
>>>  >You are probably expecting the second argument "0"
>>>  >to refer to the first series. That's not the case,
>>>  >the program is taking "0" as the filename that you
>>>  >want to use for saving the image data.
>>>  >
>>>  >
>>>  >You sould be passing something like
>>>  >
>>>  >    F:\itk\data\MR\temp1   myOutputImageFile.mhd
>>>  >
>>>  >
>>>  >The reason why the program is printing out all the
>>>  >series Ids is for making it easier for you to take
>>>  >one of those strings and use it as second argument
>>>  >to the  program. So, in a second run you can do
>>>  >something more specific like:
>>>  >
>>>  >
>>>  >  DicomSeriesReaderImageWriter.exe
>>>  >     F:\itk\data\MR\temp1
>>>  >        myOutputImageFile.mhd
>>>  >          1.3.12.2.1107.5.1.4.24515.4.0.6770456214062487
>>>  >
>>>  >(all in a single line...)
>>>  >
>>>  >
>>>  >Where the last string "1.3.12.2...." is the identifier
>>>  >of one of the series.
>>>  >
>>>  >
>>>  >Once you save your DICOM data in a fileformat
>>>  >such as Analyze of MetaImage, you will be ready
>>>  >for start testing the ImageRegistration examples.
>>>  >
>>>  >
>>>  >Deformable registration can easily take 40 minutes
>>>  >if you are dealing with 3D datasets.
>>>  >
>>>  >
>>>  >Did you use the Multi-Resolution framework ?
>>>  >
>>>  >
>>>  >
>>>  >
>>>  >   Regards,
>>>  >
>>>  >
>>>  >     Luis
>>>  >
>>>  >
>>>  >----------------------
>>>  >raghu venkatram wrote:
>>>  >
>>>  >>Hello,
>>>  >>I am using the dicom imageseriesreader, to read in a series of
>>>  >>dicom images.
>>>  >>
>>>  >>My program arguments are:
>>>  >>F:\itk\data\MR\temp1\  0
>>>  >>
>>>  >>I only have one series in this directory, and nothing other than
>>>  >>the dicom files
>>>  >>are in this directory.
>>>  >>Its reads through, gets the filenames in the series and gives an
>>>  >>"abnormal
>>>  >>program termination error". Debugging shows that the it crashes on
>>>  >>the second
>>>  >>file in the series. I would appreciate if anyone could help me out.
>>>  >>also i see
>>>  >>Chunyan had postes a similar problem.
>>>  >>
>>>  >>If i am able to read in a series of dicom images, i want to use one
>>>  >>of the
>>>  >>registration algorithms and pass the two series, I am not sure if
>>>  >>this would
>>>  >>give me 3d registration.  I tried using the analyze format, with
>>>  >>deformable
>>>  >>registration, it takes close to 40 mins, which makes me think i am
>>>  >>doing
>>>  >>something wrong. I would be glad if somebody could help me sort
>>>  >>things out.
>>>  >>
>>>  >>
>>>  >>All my dicom images are viewable using the QT viewr, MRICro.
>>>  >>
>>>  >>Thanks in advance
>>>  >>Raghu Venkatram
>>>  >>
>>>  
>>> >>/*========================================================================= 
>>>
>>>  >>
>>>  >>  Program:   Insight Segmentation & Registration Toolkit
>>>  >>  Module:    $RCSfile: DicomSeriesReadImageWrite.cxx,v $
>>>  >>  Language:  C++
>>>  >>  Date:      $Date: 2003/12/30 21:13:04 $
>>>  >>  Version:   $Revision: 1.2 $
>>>  >>
>>>  >>  Copyright (c) Insight Software Consortium. All rights reserved.
>>>  >>  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for
>>>  >>details.
>>>  >>
>>>  >>     This software is distributed WITHOUT ANY WARRANTY; without
>>>  >>even
>>>  >>     the implied warranty of MERCHANTABILITY or FITNESS FOR A
>>>  >>PARTICULAR
>>>  >>     PURPOSE.  See the above copyright notices for more
>>>  >>information.
>>>  >>
>>>  
>>> >>=========================================================================*/ 
>>>
>>>  >>
>>>  >>//  Software Guide : BeginLatex
>>>  >>//
>>>  >>//  This example illustrates how to read a DICOM series into a
>>>  >>volume
>>>  >>//  and then save this volume in another file format.
>>>  >>//
>>>  >>//  Software Guide : EndLatex
>>>  >>
>>>  
>>> >>/*========================================================================= 
>>>
>>>  >>
>>>  >>  Program:   Insight Segmentation & Registration Toolkit
>>>  >>  Module:    $RCSfile: itkDICOMImageSeriesTest.cxx,v $
>>>  >>  Language:  C++
>>>  >>  Date:      $Date: 2003/09/10 14:30:10 $xgoto-l
>>>  >>
>>>  >>  Version:   $Revision: 1.5 $
>>>  >>
>>>  >>  Copyright (c) Insight Software Consortium. All rights reserved.
>>>  >>  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for
>>>  >>details.
>>>  >>
>>>  >>     This software is distributed WITHOUT ANY WARRANTY; without
>>>  >>even
>>>  >>     the implied warranty of MERCHANTABILITY or FITNESS FOR A
>>>  >>PARTICULAR
>>>  >>     PURPOSE.  See the above copyright notices for more
>>>  >>information.
>>>  >>
>>>  
>>> >>=========================================================================*/ 
>>>
>>>  >>#if defined(_MSC_VER)
>>>  >>#pragma warning ( disable : 4786 )
>>>  >>#endif
>>>  >>#include "itkDICOMImageIOFactory.h"
>>>  >>#include "itkDICOMImageIO2.h"
>>>  >>#include "itkImageSeriesReader.h"
>>>  >>#include "itkDICOMSeriesFileNames.h"
>>>  >>#include "itkAnalyzeImageIO.h"
>>>  >>#include "itkImageFileWriter.h"
>>>  >>#include
>>>  
>>> >>"F:/itk/InsightToolkit-1.4.0/Testing/Code/BasicFilters/itkFilterWatcher.h" 
>>>
>>>  >>
>>>  >>int main(int ac, char* av[])
>>>  >>{
>>>  >>
>>>  >>  typedef itk::AnalyzeImageIO ImageIOType;
>>>  >>
>>>  >>  if(ac < 3)
>>>  >>  {
>>>  >>    std::cerr << "Usage: " << av[0] << " DicomDirectory
>>>  >>ReverseOrder(0/1)\n";
>>>  >>    return EXIT_FAILURE;
>>>  >>  }
>>>  >>
>>>  >>  typedef itk::Image ImageNDType;
>>>  >>  typedef itk::Image Image3DType;
>>>  >>  typedef itk::ImageSeriesReader ReaderType;
>>>  >>
>>>  >>  itk::DICOMImageIO2::Pointer io = itk::DICOMImageIO2::New();
>>>  >>
>>>  >>  // Get the DICOM filenames from the directory
>>>  >>  itk::DICOMSeriesFileNames::Pointer names =
>>>  >>itk::DICOMSeriesFileNames::New();
>>>  >>  names->SetDirectory(av[1]);
>>>  >>
>>>  >>  ReaderType::Pointer reader = ReaderType::New();
>>>  >>  reader->SetFileNames(names->GetFileNames());
>>>  >>  reader->SetImageIO(io);
>>>  >>  std::cout << names;
>>>  >>
>>>  >>   FilterWatcher watcher(reader);
>>>  >>
>>>  >>  try
>>>  >>    {
>>>  >>    if (atoi(av[2]))
>>>  >>      {
>>>  >>      reader->ReverseOrderOn();
>>>  >>      }
>>>  >>    reader->Update();
>>>  >>    reader->GetOutput()->Print(std::cout);
>>>  >>    }
>>>  >>  catch (itk::ExceptionObject &ex)
>>>  >>    {
>>>  >>    std::cout << ex;
>>>  >>    return EXIT_FAILURE;
>>>  >>    }
>>>  >>
>>>  >>/*
>>>  >>  typedef itk::ImageFileWriter< Image3DType > WriterType;
>>>  >>     WriterType::Pointer writer = WriterType::New();
>>>  >>
>>>  >>     std::cout  << "Writing the image as " << std::endl <<
>>>  >>std::endl;
>>>  >>     std::cout  << av[2] << std::endl << std::endl;
>>>  >>
>>>  >>     writer->SetFileName( "out.hdr" );
>>>  >>     ImageIOType::Pointer analyzeIO = ImageIOType::New();
>>>  >>     writer->SetImageIO(analyzeIO);
>>>  >>
>>>  >>     writer->SetInput( reader->GetOutput() );
>>>  >>
>>>  >>     try
>>>  >>    {
>>>  >>         writer->Update();
>>>  >>    }
>>>  >>         catch (itk::ExceptionObject &ex)
>>>  >>    {
>>>  >>    std::cout << ex;
>>>  >>    return EXIT_FAILURE;
>>>  >>    }
>>>  >>
>>>  >>*/
>>>  >>
>>>  >>
>>>  >>  return EXIT_SUCCESS;
>>>  >>
>>>  >>}
>>>  >>
>>>  >>_________________________________________________________________
>>>  >>Fast. Reliable. Get MSN 9 Dial-up - 1 month FREE! (Limited-time
>>>  >>Offer) http://click.atdmt.com/AVE/go/onm00200361ave/direct/01/
>>>  >>
>>>  >>_______________________________________________
>>>  >>Insight-users mailing list
>>>  >>Insight-users at itk.org
>>>  >>http://www.itk.org/mailman/listinfo/insight-users
>>>  >>
>>>  >
>>>  >
>>>  >
>>>
>>> ------------------------------------------------------------------------
>>> Store more e-mails with MSN Hotmail Extra Storage – 4 plans to choose 
>>> from! <http://g.msn.com/8HMAENUS/2737??PS=> 
>>> _______________________________________________ Insight-users mailing 
>>> list Insight-users at itk.org 
>>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> _________________________________________________________________
> Frustrated with dial-up? Lightning-fast Internet access for as low as 
> $29.95/month. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/
> 
>