[Insight-users] read mhd file

Luis Ibanez luis.ibanez@kitware.com
Mon, 31 Mar 2003 22:42:04 -0500


Hi Zhao,

For some reason, the MetaImage reader is having trouble
reading the binary section of your dicom files.

Please check the following

1) The DICOM files should not be using compression.

    The MetaImage reader can only read the raw binary
    data at the end of uncompressed dicom files


2) Please check the size of the dicom files. If they
    are uncompressed, their size should be at least
    256 x 256 x 4

    ( 4 bytes / pixel since you are using INT).

    =  262144 bytes,

    The Dicom header should take a couple hundred bytes,
    so you probably should have files of size ~262500 bytes.

    If the files are smaller that this value, they are
    probably compressed, and the MetaImage reader will not
    be able to process them.



Regards,


   Luis


----------------------------------
zhao yong qiang wrote:
> Hi Luis,
> 
>     I write the following code to read a series DICOM files and save it 
> as VTK file.
> 
>   typedef itk::Image<signed int, 3>  ImageType;
> 
>   typedef itk::ImageFileReader< ImageType >  VolumeReaderType;
> 
>   VolumeReaderType::Pointer reader = VolumeReaderType::New();
> 
>   reader->SetFileName( "f:\\test\\test.mhd" );
> 
>   reader->Update();
> 
>   ImageType::Pointer imOut;
> 
>   imOut = reader->GetOutput();
> 
>     itk::VTKImageIO::Pointer vtkIO;
> 
>     vtkIO = itk::VTKImageIO::New();
> 
>     itk::ImageFileWriter<ImageType>::Pointer writer;
> 
>     writer = itk::ImageFileWriter<ImageType>::New();
> 
>     writer->SetInput(imOut);
> 
>     writer->SetFileName("f:\\test.vtk"); 
> 
> writer->Update();
> 
>     writer->SetImageIO(vtkIO);
> 
>     writer->Write();
> 
>  But when execution, It shows:
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 154288
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> MetaImage: M_ReadElements: data not read completely
> 
>    ideal = 262144 : actual = 0
> 
> Why it can not read the total data?
> 
> It seems that only read one file, others are not read.
> 
> The test.mhd file:
> 
> NDims = 3
> 
> DimSize = 256 256 18
> 
> ElementSpacing = 1 1 1
> 
> Position = 0 0 0
> 
> ElementByteOrderMSB = False
> 
> ElementType = MET_INT
> 
> HeaderSize = -1
> 
> ElementDataFile = LIST 2
> 
> 00013E9A_01.dcm
> 
> 00013E9A_02.dcm
> 
> 00013E9A_03.dcm
> 
> 00013E9A_04.dcm
> 
> 00013E9A_05.dcm
> 
> 00013E9A_06.dcm
> 
> 00013E9A_07.dcm
> 
> 00013E9A_08.dcm
> 
> 00013E9A_09.dcm
> 
> 00013E9A_10.dcm
> 
> 00013E9A_11.dcm
> 
> 00013E9A_12.dcm
> 
> 00013E9A_13.dcm
> 
> 00013E9A_14.dcm
> 
> 00013E9A_15.dcm
> 
> 00013E9A_16.dcm
> 
> 00013E9A_17.dcm
> 
> 00013E9A_18.dcm
> 
> Sincerely,
>                           Zhao Yongqiang
>                           Dept. of Computer Science & Engineering
>                           Shanghai JiaoTong University
>                           Shanghai, China
>                           zhao-yq@cs.sjtu.edu.cn 
> <mailto:zhao-yq@cs.sjtu.edu.cn>
> 
>  
>