25 #include <itkGDCMImageIO.h> 26 #include <itkGDCMSeriesFileNames.h> 27 #include <itkImageSeriesReader.h> 28 #include <itkMetaDataDictionary.h> 29 #include <itkObjectFactoryBase.h> 30 #include <itkMetaDataObject.h> 31 #include <itkImageFileWriter.h> 62 QStringList arguments;
63 arguments <<
"-x" <<
"N";
64 arguments <<
"-r" <<
"N";
65 arguments <<
"-g" <<
"N";
68 QProcess process(
this);
69 process.setStandardOutputFile(d->
tempDirectory + QDir::separator() +
"logs" + QDir::separator() + d->
serieUID +
".txt");
70 process.start(program, arguments);
71 process.waitForFinished();
74 typedef signed short PixelType;
75 const unsigned int Dimension = 3;
76 typedef itk::Image< PixelType, Dimension > ImageType;
77 typedef itk::ImageSeriesReader< ImageType > ReaderType;
78 typedef itk::ImageFileWriter<ImageType> WriterType;
79 typedef itk::GDCMImageIO ImageIOType;
80 typedef itk::GDCMSeriesFileNames NamesGeneratorType;
81 typedef std::vector< std::string > FileNamesContainer;
82 typedef std::vector< std::string > SeriesIdContainer;
86 ReaderType::Pointer reader = ReaderType::New();
87 ImageIOType::Pointer dicomIO = ImageIOType::New();
89 NamesGeneratorType::Pointer inputNames = NamesGeneratorType::New();
90 inputNames->SetUseSeriesDetails (
true );
91 inputNames->AddSeriesRestriction (
"0008|0021" );
92 inputNames->AddSeriesRestriction (
"0020,0037" );
93 inputNames->LoadSequencesOn();
94 inputNames->LoadPrivateTagsOn();
97 const SeriesIdContainer & seriesUID = inputNames->GetSeriesUIDs();
98 if (seriesUID.empty()) {
99 qCritical() <<
"Series uid list is empty";
102 std::string seriesIdentifier = seriesUID.begin()->c_str();
103 FileNamesContainer filenames = inputNames->GetFileNames ( seriesIdentifier );
105 dicomIO->SetFileName ( filenames.begin()->c_str() );
107 dicomIO->ReadImageInformation();
109 catch ( itk::ExceptionObject &e ) {
110 qCritical() << e.GetDescription();
114 reader->UseStreamingOn();
115 reader->SetFileNames ( filenames );
116 reader->SetImageIO ( dicomIO );
121 catch ( itk::ExceptionObject &excp ) {
122 qCritical() << excp.GetDescription();
172 WriterType::Pointer writer = WriterType::New();
176 writer->SetFileName ( completeFilename.toStdString() );
177 writer->SetInput ( reader->GetOutput() );
183 catch ( itk::ExceptionObject &ex ) {
184 qCritical() << ex.GetDescription();
188 catch ( itk::ExceptionObject &ex ) {
189 qCritical() << ex.GetDescription();
static QtDcmPreferences * instance()
void setSerieUID(const QString &uid)
QtDcmConvert(QObject *parent=0)
void setInputDirectory(const QString &dir)
QString dcm2niiPath() const
void setOutputFilename(const QString &fname)
void setOutputDirectory(const QString &dir)
void setTempDirectory(const QString &dir)