[vtkusers] vtkGDCMImageReader spacing
mbcx9rb9
richard.j.brown at live.co.uk
Thu Apr 30 09:44:04 EDT 2015
Hi,
I'm at a complete loss to understand whats going on with the
vtkGDCMImageReader. I have created a simple example containing two adjacent
DICOM slices. Their z-positions are 83.75mm and 82.50mm, respectively.
However, when I put the two into the same vtkGDCMImageReader, my bounds are
from 83.75mm to 84.75mm.
Why is the location of the second slice always wrong when the two are
together?
And furthermore, why is the spacing wrong (it seems to think there is a
spacing of 1mm, when in reality it is 1.25mm)?
When I read in the whole stack of images, this trend continues (wrong
spacing and wrong direction), which makes it impossible to superimpose a RT
Structure file, since it is in a completely different location.
Any help would be greatly appreciated.
I have attached two example images and the code:
CT.dcm <http://vtk.1045678.n5.nabble.com/file/n5731702/CT.dcm>
CT.dcm <http://vtk.1045678.n5.nabble.com/file/n5731702/CT.dcm>
// vtk
#include <vtkSmartPointer.h>
#include <vtkStringArray.h>
// gdcm
#include <vtkGDCMImageReader.h>
int main()
{
const char *firstFile =
"/Users/CRCT_Richard/Documents/PhD/Scan_Data/Laure/TDMGLIO/CT.1.2.840.113619.2.234.90587441419.3074.1422364474001.3380.dcm";
const char *secondFile =
"/Users/CRCT_Richard/Documents/PhD/Scan_Data/Laure/TDMGLIO/CT.1.2.840.113619.2.234.90587441419.3074.1422364474005.3381.dcm";
// reader for first file
vtkSmartPointer<vtkGDCMImageReader> file1 =
vtkSmartPointer<vtkGDCMImageReader>::New();
file1->SetFileName(firstFile);
file1->FileLowerLeftOn();
file1->Update();
// reader for second file
vtkSmartPointer<vtkGDCMImageReader> file2 =
vtkSmartPointer<vtkGDCMImageReader>::New();
file2->SetFileName(secondFile);
file2->FileLowerLeftOn();
file2->Update();
// vtkStringArray for both files together
vtkSmartPointer<vtkStringArray> filenames =
vtkSmartPointer<vtkStringArray>::New();
filenames->InsertNextValue(firstFile);
filenames->InsertNextValue(secondFile);
// reader for both files together
vtkSmartPointer<vtkGDCMImageReader> bothFilesTogether =
vtkSmartPointer<vtkGDCMImageReader>::New();
bothFilesTogether->SetFileNames(filenames);
bothFilesTogether->FileLowerLeftOn();
bothFilesTogether->Update();
// cout info
std::cout << "centre of file1 in z-direction: " <<
file1->GetOutput()->GetOrigin()[2] << std::endl;
std::cout << "centre of file2 in z-direction: " <<
file2->GetOutput()->GetOrigin()[2] << std::endl;
std::cout << "lower bound of bothFilesTogether: " <<
bothFilesTogether->GetOutput()->GetBounds()[4] <<
" and upper bound: " <<
bothFilesTogether->GetOutput()->GetBounds()[5] << std::endl;
std::cout << "spacing for file1 in z-direction: " <<
file1->GetOutput()->GetSpacing()[2] << std::endl;
std::cout << "spacing for file in z-direction: " <<
file2->GetOutput()->GetSpacing()[2] << std::endl;
std::cout << "spacing for bothFilesTogether in z-direction: " <<
file1->GetOutput()->GetSpacing()[2] << std::endl;
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkGDCMImageReader-spacing-tp5731702.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list