-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Add test to improve vtkDICOMImageReader coverage.
This patch set adds a new test to exercise the vtkDICOMImageReader's ability to parse a folder containing DICOM files. The DICOM files were generated using David Gobbi's niftitodicom tool from the vtk-dicom project, and using the filtered_func_data.nii.gz NIfTI file already present in VTK's testing data. Only 10 slices around the central axial region of the volume are included to limit the testing data size.
- Loading branch information
Jon Haitz Legarreta
committed
Dec 15, 2016
1 parent
f359477
commit 0ed16ca
Showing
15 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
IO/Image/Testing/Cxx/TestDICOMImageReaderFileCollection.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/*========================================================================= | ||
Program: Visualization Toolkit | ||
Module: TestDICOMImageReaderFileCollection.cxx | ||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen | ||
All rights reserved. | ||
See Copyright.txt or http://www.kitware.com/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 notice for more information. | ||
=========================================================================*/ | ||
// .NAME Test of vtkDICOMImageReader | ||
// .SECTION Description | ||
// | ||
|
||
|
||
#include "vtkSmartPointer.h" | ||
|
||
#include "vtkDICOMImageReader.h" | ||
|
||
#include "vtkImageData.h" | ||
#include "vtkImageViewer2.h" | ||
#include "vtkRenderer.h" | ||
#include "vtkRenderWindowInteractor.h" | ||
#include "vtkTestUtilities.h" | ||
|
||
|
||
int TestDICOMImageReaderFileCollection(int argc, char *argv[]) | ||
{ | ||
|
||
if ( argc <= 1 ) | ||
{ | ||
cout << "Usage: " << argv[0] << " <dicom folder>" << endl; | ||
return 1; | ||
} | ||
|
||
char* dirName = vtkTestUtilities::ExpandDataFileName( argc, argv, "Data/dicom/collection" ); | ||
std::string directoryName = dirName; | ||
delete [] dirName; | ||
|
||
vtkSmartPointer<vtkDICOMImageReader> DICOMReader = | ||
vtkSmartPointer<vtkDICOMImageReader>::New(); | ||
|
||
// Read the input files | ||
DICOMReader->SetDirectoryName(directoryName.c_str()); | ||
cout << "Directory name: " << DICOMReader->GetDirectoryName() << endl; | ||
|
||
DICOMReader->Update(); | ||
|
||
// Read and display the image properties | ||
const char* fileExtensions = DICOMReader->GetFileExtensions(); | ||
cout << "File extensions: " << fileExtensions << endl; | ||
|
||
const char* descriptiveName = DICOMReader->GetDescriptiveName(); | ||
cout << "Descriptive name: " << descriptiveName << endl; | ||
|
||
double* pixelSpacing = DICOMReader->GetPixelSpacing(); | ||
cout << "Pixel spacing: " << *pixelSpacing << endl; | ||
|
||
int width = DICOMReader->GetWidth(); | ||
cout << "Image width: " << width << endl; | ||
|
||
int height = DICOMReader->GetHeight(); | ||
cout << "Image height: " << height << endl; | ||
|
||
float* imagePositionPatient = DICOMReader->GetImagePositionPatient(); | ||
cout << "Image position patient: " << *imagePositionPatient << endl; | ||
|
||
float* imageOrientationPatient = DICOMReader->GetImageOrientationPatient(); | ||
cout << "Image orientation patient: " << *imageOrientationPatient << endl; | ||
|
||
int bitsAllocated = DICOMReader->GetBitsAllocated(); | ||
cout << "Bits allocated: " << bitsAllocated << endl; | ||
|
||
int pixelRepresentation = DICOMReader->GetPixelRepresentation(); | ||
cout << "Pixel representation: " << pixelRepresentation << endl; | ||
|
||
int numberOfComponents = DICOMReader->GetNumberOfComponents(); | ||
cout << "Number of components: " << numberOfComponents << endl; | ||
|
||
const char* transferSyntaxUID = DICOMReader->GetTransferSyntaxUID(); | ||
cout << "Transfer syntax UID: " << transferSyntaxUID << endl; | ||
|
||
float rescaleSlope = DICOMReader->GetRescaleSlope(); | ||
cout << "Rescale slope: " << rescaleSlope << endl; | ||
|
||
float rescaleOffset = DICOMReader->GetRescaleOffset(); | ||
cout << "Rescale offset: " << rescaleOffset << endl; | ||
|
||
const char* patientName = DICOMReader->GetPatientName(); | ||
cout << "Patient name: " << patientName << endl; | ||
|
||
const char* studyUID = DICOMReader->GetStudyUID(); | ||
cout << "Study UID: " << studyUID << endl; | ||
|
||
const char* studyID = DICOMReader->GetStudyID(); | ||
cout << "Study ID: " << studyID << endl; | ||
|
||
float gantryAngle = DICOMReader->GetGantryAngle(); | ||
cout << "Gantry angle: " << gantryAngle << endl; | ||
|
||
|
||
// Display the center slice | ||
int sliceNumber = | ||
(DICOMReader->GetOutput()->GetExtent()[5] + | ||
DICOMReader->GetOutput()->GetExtent()[4]) / 2; | ||
|
||
// Visualize | ||
vtkSmartPointer<vtkImageViewer2> imageViewer = | ||
vtkSmartPointer<vtkImageViewer2>::New(); | ||
imageViewer->SetInputConnection(DICOMReader->GetOutputPort()); | ||
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = | ||
vtkSmartPointer<vtkRenderWindowInteractor>::New(); | ||
imageViewer->SetupInteractor(renderWindowInteractor); | ||
imageViewer->SetSlice(sliceNumber); | ||
imageViewer->Render(); | ||
imageViewer->GetRenderer()->ResetCamera(); | ||
renderWindowInteractor->Initialize(); | ||
imageViewer->Render(); | ||
|
||
renderWindowInteractor->Start(); | ||
|
||
|
||
return 0; | ||
} |
1 change: 1 addition & 0 deletions
1
IO/Image/Testing/Data/Baseline/TestDICOMImageReaderFileCollection.png.md5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6c042ee4549194e7ad928446e82896b9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3258ea5d2a205a17c47d9360c9748f5b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
07ebebd3fd24d2391a6c70655b6796f6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8eb81359e5d950cf1afb0afe7b2371f6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7bc8b3eeaf480aecba5d58ee83eee000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6d68ed1fbc44a83e5edc57def951a416 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ac8befa7248e9a6a98df3a8bb02e4e3a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ca1cfecd2cd54e34f4d6715f030b7ca7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8bc833af0701dbf9e9e2101930ad95f8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bfc7b2189f7f4ada15ecdbfb2416c223 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c5ca32209c7ecd151635581d97a43b81 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dc1ac27b3f31512d5863ea16e86ca634 |