18 #include "milxQtDICOMPlugin.h" 22 #include <milxGlobal.h> 25 typedef unsigned char charPixelType;
26 typedef itk::Image<charPixelType, milx::imgDimension> charImageType;
27 typedef short shortPixelType;
28 typedef itk::Image<shortPixelType, milx::imgDimension> shortImageType;
29 typedef unsigned short ushortPixelType;
30 typedef itk::Image<ushortPixelType, milx::imgDimension> ushortImageType;
31 typedef int intPixelType;
32 typedef itk::Image<intPixelType, milx::imgDimension> intImageType;
33 typedef unsigned int uintPixelType;
34 typedef itk::Image<intPixelType, milx::imgDimension> uintImageType;
35 typedef float floatPixelType;
36 typedef itk::Image<floatPixelType, milx::imgDimension> floatImageType;
37 typedef itk::VectorImage<floatPixelType, milx::imgDimension> vectorImageType;
42 MainWindow = qobject_cast<
milxQtMain *>(theParent);
54 dock =
new QDockWidget(tr(
"DICOM Manager"), MainWindow);
55 dock->setFeatures(QDockWidget::AllDockWidgetFeatures);
57 dock->setObjectName(
"DICOM Manager");
67 milxQtDICOMPlugin::~milxQtDICOMPlugin()
71 cout <<
"DICOM Plugin Destroyed." << endl;
81 QString openPythonExt =
"";
102 QString savePythonExt =
"";
104 return savePythonExt;
191 QString directoryPath;
192 QPointer<QFileDialog> fileOpener =
new QFileDialog;
193 QSettings settings(
"Shekhar Chandra",
"milxQt");
196 if(directoryPath.isEmpty())
198 QString path = settings.value(
"recentPath").toString();
199 directoryPath = fileOpener->getExistingDirectory(NULL, tr(
"Open DICOM Directory"),
201 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
204 if(directoryPath.isEmpty())
208 MainWindow->printInfo(
"Trying to read DICOMs in " + directoryPath);
209 qApp->processEvents();
213 QStringList directories;
216 MainWindow->printWarning(
"Found no series found in input directory. Checking internal directories");
217 QDir directory(directoryPath);
218 directory.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
219 directories = directory.entryList();
223 MainWindow->printInfo(QString(
"Total of ") + QString::number(UIDs.size()) +
" UID(s) found");
224 directories.push_back(
"");
229 foreach(
const QString &dir, directories)
231 QString relPath = directoryPath +
"/" + dir;
232 MainWindow->printInfo(
"Reading DICOMs in " + dir);
234 qApp->processEvents();
236 std::vector<std::string> seriesNames(UIDs.size(),
"");
237 MainWindow->printInfo(QString(
"Total of ") + QString::number(UIDs.size()) +
" UID(s) found in " + dir);
240 QStringList headingList;
241 headingList <<
"Tag" <<
"Value";
242 int caseTabIndex =
manager->newTab(
"Tags "+dir, headingList);
244 for(
size_t j = 0; j < UIDs.size(); j ++)
246 qApp->processEvents();
248 std::string echoID =
"";
249 std::string seriesID =
"";
250 std::string acqID =
"";
251 std::string instanceID =
"";
252 std::vector< std::pair<std::string, std::string> > tags;
253 if (!milx::File::GetDICOMTags<floatImageType>(relPath.toStdString(), tags, UIDs[j], caseID, echoID, seriesID, acqID, instanceID))
256 QStringList entryName;
257 entryName << UIDs[j].c_str() <<
"";
260 QList<QStringList> entryList;
261 for(
int k = 0; k < tags.size(); k ++)
264 std::string tag = tags[k].first;
265 std::string value = tags[k].second;
267 tagList << tag.c_str() << value.c_str();
270 entryList.push_back(tagList);
272 manager->addTreeItem(caseTabIndex, entryName, entryList, Qt::NoItemFlags);
276 MainWindow->printInfo(QString(
"Processed ") + QString::number(count) +
" DICOM folders in " + directoryPath);
279 MainWindow->printInfo(
"Done.");
286 QString directoryPath;
287 QPointer<QFileDialog> fileOpener =
new QFileDialog;
288 QSettings settings(
"Shekhar Chandra",
"milxQt");
291 if (directoryPath.isEmpty())
293 QString path = settings.value(
"recentPath").toString();
294 directoryPath = fileOpener->getExistingDirectory(NULL, tr(
"Open DICOM Directory"),
296 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
299 if (directoryPath.isEmpty())
306 QStringList headingList;
307 headingList <<
"Tag" <<
"Value";
308 int caseTabIndex =
manager->newTab(
"Tag Browser", headingList);
311 for (
size_t j = 0; j < UIDs.size(); j++)
313 qApp->processEvents();
315 std::string echoID =
"";
316 std::string seriesID =
"";
317 std::string acqID =
"";
318 std::string instanceID =
"";
319 floatImageType::Pointer floatImg;
320 std::vector< std::pair<std::string, std::string> > tags;
321 if (!milx::File::OpenDICOMSeriesAndTags<floatImageType>(directoryPath.toStdString(), floatImg, tags, UIDs[j], caseID, echoID, seriesID, acqID, instanceID))
324 QStringList entryName;
325 entryName << UIDs[j].c_str() <<
"";
328 QList<QStringList> entryList;
329 for (
int k = 0; k < tags.size(); k++)
332 std::string tag = tags[k].first;
333 std::string value = tags[k].second;
335 tagList << tag.c_str() << value.c_str();
338 entryList.push_back(tagList);
340 manager->addTreeItem(caseTabIndex, entryName, entryList, Qt::NoItemFlags);
341 qApp->processEvents();
345 resultImg->
setName(UIDs[j].c_str());
346 resultImg->setData(floatImg);
347 resultImg->generateImage();
348 MainWindow->display(resultImg);
352 MainWindow->printInfo(
"Done.");
358 cout <<
"Opening DICOM-RT" << endl;
362 int ret = wizardRT.exec();
364 if(ret == QDialog::Rejected)
371 rsFilename = txtRSName->text();
372 inputRTDirectoryname = txtRTInputName->text();
373 outputRTDirectoryname = txtRTOutputName->text();
374 qApp->processEvents();
381 qApp->processEvents();
388 MainWindow->printError(
"No series found in input directory");
393 std::string seriesName = UIDs[0];
394 charImageType::Pointer charImg;
396 #if (ITK_VERSION_MAJOR > 3) //Review only members 397 ExportDICOM_RT<charImageType>(inputRTDirectoryname.toStdString(), rsFilename.toStdString(), outputRTDirectoryname.toStdString(), charImg, seriesName);
398 #endif // (ITK_VERSION_MAJOR > 3) 400 MainWindow->printInfo(
"Done.");
406 cout <<
"Converting DICOMs" << endl;
410 int ret = wizard.exec();
412 if(ret == QDialog::Rejected)
419 inputDirectoryname = txtInputName->text();
420 outputDirectoryname = txtOutputName->text();
422 qApp->processEvents();
430 QStringList directories;
433 MainWindow->printWarning(
"Found no series found in input directory. Checking internal directories");
434 QDir directory(inputDirectoryname);
435 directory.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
436 directories = directory.entryList();
440 MainWindow->printInfo(QString(
"Total of ") + QString::number(UIDs.size()) +
" UID(s) found");
441 directories.push_back(
"");
446 foreach(
const QString &dir, directories)
448 qApp->processEvents();
449 QString relPath = inputDirectoryname +
"/" + dir;
450 QString relOutputPath = outputDirectoryname +
"/" + dir;
452 std::vector<std::string> seriesNames(UIDs.size(),
"");
453 MainWindow->printInfo(QString(
"Total of ") + QString::number(UIDs.size()) +
" UID(s) found in " + dir);
455 QDir outputSubjectDirectory(relOutputPath);
457 bool exist = outputSubjectDirectory.exists();
460 exist = QDir().mkpath(relOutputPath);
465 for(
size_t j = 0; j < UIDs.size(); j ++)
467 qApp->processEvents();
468 seriesNames[j] = UIDs[j];
472 size_t dimensions = 3;
473 std::string pixelType, componentType;
476 milx::PrintError(
"Failed Reading First Image. Check the image type/file. Skipping.");
486 std::string echoID =
"";
487 std::string seriesID =
"";
488 std::string acqID =
"";
489 std::string instanceID =
"";
490 itk::SmartPointer<vectorImageType> vectorImage;
491 itk::SmartPointer<charImageType> labelledImage;
492 itk::SmartPointer<shortImageType> shortImage;
493 itk::SmartPointer<ushortImageType> ushortImage;
494 itk::SmartPointer<intImageType> intImage;
495 itk::SmartPointer<uintImageType> uintImage;
496 itk::SmartPointer<floatImageType> floatImage;
497 std::vector< std::pair<std::string, std::string> > tags;
498 bool labelledImages =
false, shortImages =
false, ushortImages =
false, integerImages =
false, uintegerImages =
false, vectorImages =
false;
499 if (pixelType ==
"vector" || dimensions > 3)
502 if (!milx::File::OpenDICOMSeriesAndTags<vectorImageType>(relPath.toStdString(), vectorImage, tags, seriesNames[j], caseID, echoID, seriesID, acqID, instanceID))
509 else if (componentType ==
"unsigned_char" || componentType ==
"unsigned char")
512 if (!milx::File::OpenDICOMSeriesAndTags<charImageType>(relPath.toStdString(), labelledImage, tags, seriesNames[j], caseID, echoID, seriesID, acqID, instanceID))
517 labelledImages =
true;
519 else if (componentType ==
"short" || componentType ==
"int16")
522 if (!milx::File::OpenDICOMSeriesAndTags<shortImageType>(relPath.toStdString(), shortImage, tags, seriesNames[j], caseID, echoID, seriesID, acqID, instanceID))
529 else if (componentType ==
"unsigned_short" || componentType ==
"unsigned short")
532 if (!milx::File::OpenDICOMSeriesAndTags<ushortImageType>(relPath.toStdString(), ushortImage, tags, seriesNames[j], caseID, echoID, seriesID, acqID, instanceID))
539 else if (componentType ==
"int" || componentType ==
"signed" || componentType ==
"int32" || componentType ==
"int64")
542 if (!milx::File::OpenDICOMSeriesAndTags<intImageType>(relPath.toStdString(), intImage, tags, seriesNames[j], caseID, echoID, seriesID, acqID, instanceID))
547 integerImages =
true;
549 else if (componentType ==
"unsigned_int" || componentType ==
"unsigned int" || componentType ==
"unsigned")
552 if (!milx::File::OpenDICOMSeriesAndTags<uintImageType>(relPath.toStdString(), uintImage, tags, seriesNames[j], caseID, echoID, seriesID, acqID, instanceID))
557 uintegerImages =
true;
562 if (!milx::File::OpenDICOMSeriesAndTags<floatImageType>(relPath.toStdString(), floatImage, tags, seriesNames[j], caseID, echoID, seriesID, acqID, instanceID))
570 QString nameSimplified = seriesNames[j].c_str();
571 nameSimplified = nameSimplified.simplified();
572 nameSimplified.replace(
" ",
"");
573 seriesNames[j] = nameSimplified.toStdString();
574 QString caseSimplified = caseID.c_str();
575 caseSimplified = caseSimplified.simplified();
576 caseSimplified.replace(
" ",
"");
577 caseID = caseSimplified.toStdString();
579 MainWindow->printInfo(QString(
"Opened: ") + seriesNames[j].c_str());
580 qApp->processEvents();
583 std::string filename = relOutputPath.toStdString() +
"/" + dir.toStdString() +
"_" + caseID +
"_" + seriesNames[j] +
".nii.gz";
585 filename = relOutputPath.toStdString() +
"/" + dir.toStdString() + seriesNames[j] +
".nii.gz";
586 MainWindow->printInfo(QString(
"Saving DICOM as ") + filename.c_str());
590 milx::File::SaveImage<vectorImageType>(filename, vectorImage);
591 else if(labelledImages)
592 milx::File::SaveImage<charImageType>(filename, labelledImage);
594 milx::File::SaveImage<shortImageType>(filename, shortImage);
595 else if(ushortImages)
596 milx::File::SaveImage<ushortImageType>(filename, ushortImage);
597 else if(integerImages)
598 milx::File::SaveImage<intImageType>(filename, intImage);
599 else if(uintegerImages)
600 milx::File::SaveImage<uintImageType>(filename, uintImage);
602 milx::File::SaveImage<floatImageType>(filename, floatImage);
606 qApp->processEvents();
608 MainWindow->printInfo(
"Done");
613 cout <<
"Anonymizing DICOMs" << endl;
614 typedef itk::GDCMSeriesFileNames NamesGeneratorType;
615 typedef std::vector< std::string > FileNamesContainer;
616 typedef std::vector< std::string > SeriesIdContainer;
619 wizardAnonymize.restart();
621 int ret = wizardAnonymize.exec();
623 if(ret == QDialog::Rejected)
625 wizardAnonymize.restart();
634 qApp->processEvents();
636 MainWindow->printInfo(QString(
"DICOM directory ") + inputAnonymizeDirectoryname);
637 MainWindow->printInfo(QString(
"Output directory ") + outputAnonymizeDirectoryname);
638 MainWindow->printInfo(QString(
"Prefix anonymisation ") + outputPrefix);
639 MainWindow->printInfo(QString(
"Starting at ID ") + QString::number(outputInitID));
643 MainWindow->printInfo(QString(
"Working..."));
645 unsigned int initial_id = outputInitID;
646 QDir subjectsDir(inputAnonymizeDirectoryname);
647 subjectsDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
650 QStringList entries = subjectsDir.entryList();
651 for( QStringList::ConstIterator entry=entries.begin(); entry!=entries.end(); ++entry)
654 qApp->processEvents();
655 QFileInfo finfo(subjectsDir, *entry);
659 QDir subdir(finfo.absoluteFilePath());
660 QString subjectPath = subdir.absolutePath();
662 QDir::setCurrent(subjectPath);
667 NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
668 nameGenerator->SetUseSeriesDetails(
true );
669 nameGenerator->SetRecursive(
true);
670 nameGenerator->AddSeriesRestriction(
"0008|0021" );
671 nameGenerator->SetDirectory(subjectPath.toStdString().c_str());
675 const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
676 if (seriesUID.size() > 0)
678 QString outputSubjectPath = outputAnonymizeDirectoryname+ QDir::separator() + outputPrefix + QString::number(initial_id);
679 QDir outputSubjectDirectory(outputSubjectPath);
682 bool exist = outputSubjectDirectory.exists();
685 exist = QDir().mkpath(outputSubjectPath);
692 SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
693 SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
696 while( seriesItr != seriesEnd )
698 qApp->processEvents();
699 std::cout << seriesItr->c_str() << std::endl;
700 FileNamesContainer temp = nameGenerator->GetFileNames(seriesItr->c_str());
702 std::vector<std::string>::iterator fileIterator;
703 unsigned int dcm_index = 0;
706 for (fileIterator = temp.begin(); fileIterator != temp.end(); fileIterator++)
709 QString rel_path = subdir.relativeFilePath(QString::fromStdString(*fileIterator));
710 QFileInfo img_info(rel_path);
711 QString rel_dir = img_info.path();
714 bool success =
anonymizeDicomImage(*fileIterator, outputSubjectPath, rel_dir, initial_id, dcm_index, first);
721 std::cout <<
"Failed to anonymise " << *fileIterator << std::endl;
723 qApp->processEvents();
730 catch (itk::ExceptionObject &ex)
732 std::cerr << ex << std::endl;
737 qApp->processEvents();
739 MainWindow->printInfo(
"Done");
744 QSettings settings(
"Shekhar Chandra",
"milxQt");
746 QString exts = openMedImageExts.c_str();
747 QString path = settings.value(
"recentPath").toString();
749 if(!txtRSName->text().isEmpty())
750 path = txtRSName->text();
752 QFileDialog *fileOpener =
new QFileDialog;
753 rsFilename = fileOpener->getOpenFileName(&wizardRT,
754 tr(
"Select RS File to Open"),
756 tr(exts.toStdString().c_str()) );
757 txtRSName->setText(rsFilename);
760 void milxQtDICOMPlugin::showInputFileDialog()
762 QSettings settings(
"Shekhar Chandra",
"milxQt");
764 QString path = settings.value(
"recentPath").toString();
766 QFileDialog *fileOpener =
new QFileDialog;
767 inputDirectoryname = fileOpener->getExistingDirectory(&wizard,
768 tr(
"Select Open Directory"),
770 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
771 txtInputName->setText(inputDirectoryname);
774 void milxQtDICOMPlugin::showRTInputFileDialog()
776 QSettings settings(
"Shekhar Chandra",
"milxQt");
778 QString path = settings.value(
"recentPath").toString();
780 QFileDialog *fileOpener =
new QFileDialog;
781 inputRTDirectoryname = fileOpener->getExistingDirectory(&wizardRT,
782 tr(
"Select Open Directory"),
784 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
785 txtRTInputName->setText(inputRTDirectoryname);
786 txtRSName->setText(inputRTDirectoryname);
789 void milxQtDICOMPlugin::showInputFileDialogAnonymize()
791 QSettings settings(
"Shekhar Chandra",
"milxQt");
793 QString path = settings.value(
"recentPath").toString();
795 QFileDialog *fileOpener =
new QFileDialog;
796 inputAnonymizeDirectoryname = fileOpener->getExistingDirectory(&wizardAnonymize,
797 tr(
"Select Open Directory"),
799 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
800 txtInputAnonymizeName->setText(inputAnonymizeDirectoryname);
803 void milxQtDICOMPlugin::showOutputFileDialog()
805 QSettings settings(
"Shekhar Chandra",
"milxQt");
807 QString path = settings.value(
"recentPath").toString();
809 QFileDialog *fileOpener =
new QFileDialog;
810 outputDirectoryname = fileOpener->getExistingDirectory(&wizard,
811 tr(
"Select Save Directory"),
813 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
814 txtOutputName->setText(outputDirectoryname);
817 void milxQtDICOMPlugin::showRTOutputFileDialog()
819 QSettings settings(
"Shekhar Chandra",
"milxQt");
821 QString path = settings.value(
"recentPath").toString();
823 QFileDialog *fileOpener =
new QFileDialog;
824 outputRTDirectoryname = fileOpener->getExistingDirectory(&wizardRT,
825 tr(
"Select Save Directory"),
827 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
828 txtRTOutputName->setText(outputRTDirectoryname);
831 void milxQtDICOMPlugin::showOutputFileDialogAnonymize()
833 QSettings settings(
"Shekhar Chandra",
"milxQt");
835 QString path = settings.value(
"recentPath").toString();
837 QFileDialog *fileOpener =
new QFileDialog;
838 outputAnonymizeDirectoryname = fileOpener->getExistingDirectory(&wizardAnonymize,
839 tr(
"Select Save Directory"),
841 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
842 txtOutputAnonymizeName->setText(outputAnonymizeDirectoryname);
845 void milxQtDICOMPlugin::createActions()
849 actionOpenSeries->setText(QApplication::translate(
"MainWindow",
"Open Series", 0, QApplication::UnicodeUTF8));
852 actionTags->setIcon(QIcon(
":/resources/toolbar/search.png"));
853 actionTags->setText(QApplication::translate(
"MainWindow",
"View Tags", 0, QApplication::UnicodeUTF8));
856 actionConvertStructure->setText(QApplication::translate(
"DICOMPlugin",
"Convert RT/Structure Set ...", 0, QApplication::UnicodeUTF8));
859 #if (ITK_VERSION_MAJOR > 3) //Review only members 861 #endif // (ITK_VERSION_MAJOR > 3) 863 actionConvert->setText(QApplication::translate(
"DICOMPlugin",
"Convert ...", 0, QApplication::UnicodeUTF8));
866 actionAnonymize->setText(QApplication::translate(
"DICOMPlugin",
"Anonymize ...", 0, QApplication::UnicodeUTF8));
870 void milxQtDICOMPlugin::createMenu()
873 menuDICOM->setTitle(QApplication::translate(
"DICOMPlugin",
"DICOM", 0, QApplication::UnicodeUTF8));
883 void milxQtDICOMPlugin::createWizard()
886 QWizardPage *introPage =
new QWizardPage;
887 introPage->setTitle(
"Introduction");
889 QLabel *label1 =
new QLabel(
"This wizard will help you process DICOM series.");
890 label1->setWordWrap(
true);
891 QLabel *label2 =
new QLabel(
"You will be asked to provide a directory where the DICOM are located.");
892 label2->setWordWrap(
true);
893 QLabel *label3 =
new QLabel(
"You will then be asked to provide an output directory for the process data to be stored.");
894 label3->setWordWrap(
true);
895 QVBoxLayout *introLayout =
new QVBoxLayout;
896 introLayout->addWidget(label1);
897 introLayout->addWidget(label2);
898 introLayout->addWidget(label3);
899 introPage->setLayout(introLayout);
902 QWizardPage *inputPage =
new QWizardPage;
903 inputPage->setTitle(
"Input Directory");
905 QLabel *label4 =
new QLabel(
"Please provide the directory to be analysed.");
906 label4->setWordWrap(
true);
907 txtInputName =
new QLineEdit;
908 QPushButton *btnInputName =
new QPushButton;
909 connect(btnInputName, SIGNAL(clicked()),
this, SLOT(showInputFileDialog()));
910 btnInputName->setText(
"Browse...");
911 QHBoxLayout *inputNameLayout =
new QHBoxLayout;
912 inputNameLayout->addWidget(txtInputName);
913 inputNameLayout->addWidget(btnInputName);
914 QGroupBox *inputGroupBox =
new QGroupBox(
"Series Directory");
915 inputGroupBox->setLayout(inputNameLayout);
916 QVBoxLayout *inputLayout =
new QVBoxLayout;
917 inputLayout->addWidget(label4);
918 inputLayout->addWidget(inputGroupBox);
919 inputPage->setLayout(inputLayout);
922 QWizardPage *outputPage =
new QWizardPage;
923 outputPage->setTitle(
"Output Directory");
925 QLabel *label5 =
new QLabel(
"Please provide the output directory for the processing.");
926 label5->setWordWrap(
true);
927 txtOutputName =
new QLineEdit;
928 QPushButton *btnOutputName =
new QPushButton;
929 btnOutputName->setText(
"Browse...");
930 connect(btnOutputName, SIGNAL(clicked()),
this, SLOT(showOutputFileDialog()));
931 QHBoxLayout *ouputNameLayout =
new QHBoxLayout;
932 ouputNameLayout->addWidget(txtOutputName);
933 ouputNameLayout->addWidget(btnOutputName);
934 QGroupBox *outputGroupBox =
new QGroupBox(
"Output Directory");
935 outputGroupBox->setLayout(ouputNameLayout);
936 QVBoxLayout *outputLayout =
new QVBoxLayout;
937 outputLayout->addWidget(label5);
938 outputLayout->addWidget(outputGroupBox);
939 outputPage->setLayout(outputLayout);
942 wizard.addPage(introPage);
943 wizard.addPage(inputPage);
944 wizard.addPage(outputPage);
945 wizard.setWindowTitle(
"DICOM Wizard");
948 void milxQtDICOMPlugin::createRTWizard()
951 QWizardPage *introPage =
new QWizardPage;
952 introPage->setTitle(
"Introduction");
954 QLabel *label1 =
new QLabel(
"This wizard will help you process DICOM series.");
955 label1->setWordWrap(
true);
956 QLabel *label2 =
new QLabel(
"You will be asked to provide a directory where the DICOM are located.");
957 label2->setWordWrap(
true);
958 QLabel *label3 =
new QLabel(
"You will then be asked to provide an output directory for the process data to be stored.");
959 label3->setWordWrap(
true);
960 QVBoxLayout *introLayout =
new QVBoxLayout;
961 introLayout->addWidget(label1);
962 introLayout->addWidget(label2);
963 introLayout->addWidget(label3);
964 introPage->setLayout(introLayout);
967 QWizardPage *inputPage =
new QWizardPage;
968 inputPage->setTitle(
"Input Directory");
970 QLabel *label4 =
new QLabel(
"Please provide the directory to be analysed.");
971 label4->setWordWrap(
true);
972 txtRTInputName =
new QLineEdit;
973 QPushButton *btnInputName =
new QPushButton;
974 connect(btnInputName, SIGNAL(clicked()),
this, SLOT(showRTInputFileDialog()));
975 btnInputName->setText(
"Browse...");
976 QHBoxLayout *inputNameLayout =
new QHBoxLayout;
977 inputNameLayout->addWidget(txtRTInputName);
978 inputNameLayout->addWidget(btnInputName);
979 QGroupBox *inputGroupBox =
new QGroupBox(
"Series Directory");
980 inputGroupBox->setLayout(inputNameLayout);
981 QVBoxLayout *inputLayout =
new QVBoxLayout;
982 inputLayout->addWidget(label4);
983 inputLayout->addWidget(inputGroupBox);
984 inputPage->setLayout(inputLayout);
987 QWizardPage *outputPage =
new QWizardPage;
988 outputPage->setTitle(
"Output Directory");
990 QLabel *label5 =
new QLabel(
"Please provide the output directory for the processing.");
991 label5->setWordWrap(
true);
992 txtRTOutputName =
new QLineEdit;
993 QPushButton *btnOutputName =
new QPushButton;
994 btnOutputName->setText(
"Browse...");
995 connect(btnOutputName, SIGNAL(clicked()),
this, SLOT(showRTOutputFileDialog()));
996 QHBoxLayout *ouputNameLayout =
new QHBoxLayout;
997 ouputNameLayout->addWidget(txtRTOutputName);
998 ouputNameLayout->addWidget(btnOutputName);
999 QGroupBox *outputGroupBox =
new QGroupBox(
"Output Directory");
1000 outputGroupBox->setLayout(ouputNameLayout);
1001 QVBoxLayout *outputLayout =
new QVBoxLayout;
1002 outputLayout->addWidget(label5);
1003 outputLayout->addWidget(outputGroupBox);
1004 outputPage->setLayout(outputLayout);
1007 QWizardPage *rsPage =
new QWizardPage;
1008 rsPage->setTitle(
"RS File");
1010 QLabel *label6 =
new QLabel(
"Please provide the RS file for processing.");
1011 label6->setWordWrap(
true);
1012 txtRSName =
new QLineEdit;
1013 QPushButton *btnRSName =
new QPushButton;
1014 btnRSName->setText(
"Browse...");
1016 QHBoxLayout *rsNameLayout =
new QHBoxLayout;
1017 rsNameLayout->addWidget(txtRSName);
1018 rsNameLayout->addWidget(btnRSName);
1019 QGroupBox *rsGroupBox =
new QGroupBox(
"RS File");
1020 rsGroupBox->setLayout(rsNameLayout);
1021 QVBoxLayout *rsLayout =
new QVBoxLayout;
1022 rsLayout->addWidget(label6);
1023 rsLayout->addWidget(rsGroupBox);
1024 rsPage->setLayout(rsLayout);
1027 wizardRT.addPage(introPage);
1028 wizardRT.addPage(inputPage);
1029 wizardRT.addPage(outputPage);
1030 wizardRT.addPage(rsPage);
1031 wizardRT.setWindowTitle(
"DICOM RT Wizard");
1037 QWizardPage *introPage =
new QWizardPage;
1038 introPage->setTitle(
"Introduction");
1040 QLabel *label1 =
new QLabel(
"This wizard will help you anonymize DICOM series.");
1041 label1->setWordWrap(
true);
1042 QLabel *label2 =
new QLabel(
"You will be asked to provide the 'top'' directory in which the folders of the patients are located.");
1043 label2->setWordWrap(
true);
1044 QLabel *label3 =
new QLabel(
"You will then be asked to provide an output directory.");
1045 label3->setWordWrap(
true);
1046 QLabel *label3a =
new QLabel(
"Then, you will then be asked to provide a prefix that will be used to replace the patient name eg. 'ANON'.");
1047 label3a->setWordWrap(
true);
1048 QLabel *label3b =
new QLabel(
"You will finally be asked to provide an initial ID for the first case to be anonymized (this ID will be incremented per subject).");
1049 label3b->setWordWrap(
true);
1050 QVBoxLayout *introLayout =
new QVBoxLayout;
1051 introLayout->addWidget(label1);
1052 introLayout->addWidget(label2);
1053 introLayout->addWidget(label3);
1054 introLayout->addWidget(label3a);
1055 introLayout->addWidget(label3b);
1056 introPage->setLayout(introLayout);
1060 QWizardPage *inputPage =
new QWizardPage;
1061 inputPage->setTitle(
"Input Directory");
1063 QLabel *label4 =
new QLabel(
"Please provide the top directory in which the subjects' folders are located.");
1064 label4->setWordWrap(
true);
1065 txtInputAnonymizeName =
new QLineEdit;
1066 QPushButton *btnInputName =
new QPushButton;
1067 connect(btnInputName, SIGNAL(clicked()),
this, SLOT(showInputFileDialogAnonymize()));
1068 btnInputName->setText(
"Browse...");
1069 QHBoxLayout *inputNameLayout =
new QHBoxLayout;
1070 inputNameLayout->addWidget(txtInputAnonymizeName);
1071 inputNameLayout->addWidget(btnInputName);
1072 QGroupBox *inputGroupBox =
new QGroupBox(
"Series Directory");
1073 inputGroupBox->setLayout(inputNameLayout);
1074 QVBoxLayout *inputLayout =
new QVBoxLayout;
1075 inputLayout->addWidget(label4);
1076 inputLayout->addWidget(inputGroupBox);
1077 inputPage->setLayout(inputLayout);
1080 QWizardPage *outputPage =
new QWizardPage;
1081 outputPage->setTitle(
"Output Directory");
1083 QLabel *label5 =
new QLabel(
"Please provide the output directory.");
1084 label5->setWordWrap(
true);
1085 txtOutputAnonymizeName =
new QLineEdit;
1086 QPushButton *btnOutputName =
new QPushButton;
1087 btnOutputName->setText(
"Browse...");
1088 connect(btnOutputName, SIGNAL(clicked()),
this, SLOT(showOutputFileDialogAnonymize()));
1089 QHBoxLayout *ouputNameLayout =
new QHBoxLayout;
1090 ouputNameLayout->addWidget(txtOutputAnonymizeName);
1091 ouputNameLayout->addWidget(btnOutputName);
1092 QGroupBox *outputGroupBox =
new QGroupBox(
"Output Directory");
1093 outputGroupBox->setLayout(ouputNameLayout);
1094 QVBoxLayout *outputLayout =
new QVBoxLayout;
1095 outputLayout->addWidget(label5);
1096 outputLayout->addWidget(outputGroupBox);
1097 outputPage->setLayout(outputLayout);
1100 QWizardPage *prefixPage =
new QWizardPage;
1101 prefixPage->setTitle(
"Prefix anonymization");
1103 QLabel *label6 =
new QLabel(
"Please provide the pefix for naming anonymized subject. If left emply 'Anon' will be used");
1104 label6->setWordWrap(
true);
1105 txtOutputPrefix =
new QLineEdit;
1106 txtOutputPrefix->setText(
"Anon");
1107 QHBoxLayout *prfxNameLayout =
new QHBoxLayout;
1108 prfxNameLayout->addWidget(txtOutputPrefix);
1109 QGroupBox *prefixGroupBox =
new QGroupBox(
"Output prefix");
1110 prefixGroupBox->setLayout(prfxNameLayout);
1111 QVBoxLayout *prefixLayout =
new QVBoxLayout;
1112 prefixLayout->addWidget(label6);
1113 prefixLayout->addWidget(prefixGroupBox);
1114 prefixPage->setLayout(prefixLayout);
1117 QWizardPage *outputIDPage =
new QWizardPage;
1118 outputIDPage->setTitle(
"Output Directory");
1120 QLabel *label7 =
new QLabel(
"Please provide the initial ID for anonymisation (integer). If left empty, '0' will be used");
1121 label7->setWordWrap(
true);
1122 txtOutputInitID =
new QLineEdit;
1123 txtOutputInitID->setText(
"0");
1124 QHBoxLayout *InitIDNameLayout =
new QHBoxLayout;
1125 InitIDNameLayout->addWidget(txtOutputInitID);
1127 QGroupBox *InitIDGroupBox =
new QGroupBox(
"Initial ID");
1128 InitIDGroupBox->setLayout(InitIDNameLayout);
1129 QVBoxLayout *InitIDLayout =
new QVBoxLayout;
1130 InitIDLayout->addWidget(label7);
1131 InitIDLayout->addWidget(InitIDGroupBox);
1132 outputIDPage->setLayout(InitIDLayout);
1135 QWizardPage *optionPage =
new QWizardPage;
1136 optionPage->setTitle(
"Options");
1138 QHBoxLayout *splitLayout =
new QHBoxLayout;
1140 QVBoxLayout *optionLayout =
new QVBoxLayout;
1141 QLabel *label8 =
new QLabel(
"Output options:");
1142 label8->setWordWrap(
true);
1144 checkboxPreserveFolderArc =
new QCheckBox(
"Preserve folder architecture", &wizardAnonymize);
1145 checkboxPreserveFolderArc->setChecked(
true);
1147 QVBoxLayout *anonOptionLayout =
new QVBoxLayout;
1148 QLabel *label10 =
new QLabel(
"Anonymization options:");
1149 label10->setWordWrap(
true);
1151 anonPatientInfo =
new QCheckBox(
"Anonymize Patient info", &wizardAnonymize);
1152 anonPatientInfo->setChecked(
true);
1153 anonPhysician =
new QCheckBox(
"Anonymize Physician(s) info", &wizardAnonymize);
1154 anonOperator =
new QCheckBox(
"Anonymize Operator info", &wizardAnonymize);
1155 anonScanDate =
new QCheckBox(
"Anonymize Scan Date", &wizardAnonymize);
1156 optionLayout->addWidget(label10);
1157 optionLayout->addWidget(checkboxPreserveFolderArc);
1158 optionLayout->addWidget(anonPatientInfo);
1159 optionLayout->addWidget(anonPhysician);
1160 optionLayout->addWidget(anonOperator);
1161 optionLayout->addWidget(anonScanDate);
1162 optionLayout->setAlignment(Qt::AlignTop);
1164 QLabel *label9 =
new QLabel(
"Items for default filename:");
1165 label8->setWordWrap(
true);
1167 checkboxPatientName =
new QCheckBox(
"Patient anonymized name", &wizardAnonymize);
1168 checkboxPatientName->setChecked(
true);
1169 checkboxPatientID =
new QCheckBox(
"PatientID", &wizardAnonymize);
1170 checkboxPatientID->setChecked(
true);
1171 checkboxSeriesDate =
new QCheckBox(
"SeriesDate", &wizardAnonymize);
1172 checkboxSeriesDate->setChecked(
true);
1173 checkboxSeriesTime =
new QCheckBox(
"SeriesTime", &wizardAnonymize);
1174 checkboxSeriesTime->setChecked(
true);
1175 checkboxStudyID =
new QCheckBox(
"StudyID", &wizardAnonymize);
1176 checkboxStudyDesc =
new QCheckBox(
"StudyDesc", &wizardAnonymize);
1177 checkboxStudyDesc->setChecked(
true);
1178 checkboxSeriesNumber =
new QCheckBox(
"SeriesNumber", &wizardAnonymize);
1179 checkboxSeriesNumber->setChecked(
true);
1180 checkboxSeriesNumber->setEnabled(
false);
1181 checkboxSequenceName =
new QCheckBox(
"SequenceName", &wizardAnonymize);
1182 checkboxSequenceName->setChecked(
true);
1183 checkboxProtocolName =
new QCheckBox(
"ProtocolName", &wizardAnonymize);
1184 checkboxProtocolName->setChecked(
true);
1185 checkboxSeriesDescription =
new QCheckBox(
"SeriesDescription", &wizardAnonymize);
1187 anonOptionLayout->addWidget(label8);
1188 anonOptionLayout->addWidget(label9);
1189 anonOptionLayout->addWidget(checkboxPatientName);
1190 anonOptionLayout->addWidget(checkboxPatientID);
1191 anonOptionLayout->addWidget(checkboxSeriesDate);
1192 anonOptionLayout->addWidget(checkboxSeriesTime);
1193 anonOptionLayout->addWidget(checkboxStudyID);
1194 anonOptionLayout->addWidget(checkboxStudyDesc);
1195 anonOptionLayout->addWidget(checkboxSeriesNumber);
1196 anonOptionLayout->addWidget(checkboxSequenceName);
1197 anonOptionLayout->addWidget(checkboxProtocolName);
1198 anonOptionLayout->addWidget(checkboxSeriesDescription);
1199 anonOptionLayout->setAlignment(Qt::AlignTop);
1201 splitLayout->addLayout(optionLayout);
1202 splitLayout->addLayout(anonOptionLayout);
1203 optionPage->setLayout(splitLayout);
1206 wizardAnonymize.addPage(introPage);
1207 wizardAnonymize.addPage(inputPage);
1208 wizardAnonymize.addPage(outputPage);
1209 wizardAnonymize.addPage(prefixPage);
1210 wizardAnonymize.addPage(outputIDPage);
1211 wizardAnonymize.addPage(optionPage);
1213 wizardAnonymize.setWindowTitle(
"DICOM Anonymisation Wizard");
1215 QAbstractButton *
final = wizardAnonymize.button(QWizard::FinishButton);
1216 connect(
final, SIGNAL(clicked()),
this, SLOT(
affectValues()));
1219 void milxQtDICOMPlugin::createConnections()
1228 connect(
this, SIGNAL(
working(
int)), MainWindow, SLOT(
working(
int)));
1229 connect(
this, SIGNAL(
done(
int)), MainWindow, SLOT(
done(
int)));
1234 QString logName= outputAnonymizeDirectoryname + QDir::separator() +
"anonymization.log";
1235 std::string log =
"Anonymizing image: " + input;
1236 writeLog(logName, log);
1237 MainWindow->printInfo(QString(
"Anonymizing: ") + input.c_str());
1241 typedef signed short shortPixelType;
1242 typedef itk::Image<shortPixelType, milx::imgDimension> shortImageType;
1245 std::ostringstream index;
1246 index << index_subject;
1247 std::string anonymization_value = outputPrefix.toStdString() + index.str();
1251 typedef itk::ImageFileReader< shortImageType > ReaderType;
1252 typedef itk::ImageFileReader< rgbImageType > rgbReaderType;
1256 ReaderType::Pointer reader = ReaderType::New();
1257 ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
1258 reader->SetFileName(input.c_str());
1259 reader->SetImageIO( gdcmImageIO );
1260 reader->AddObserver(itk::ProgressEvent(), milx::ProgressUpdates);
1265 catch (itk::ExceptionObject &ex)
1267 std::cerr << ex << std::endl;
1270 shortImageType::Pointer floatImg = reader->GetOutput();
1275 QString fileMappingName = outputAnonymizeDirectoryname + QDir::separator() +
"subjects_mapping.txt";
1276 QFile file_mapping(fileMappingName);
1277 if (file_mapping.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Append))
1281 std::string name_tag(
"0010|0010");
1282 std::string name_value;
1286 QTextStream out(&file_mapping);
1287 out.setCodec(
"UTF-8");
1288 out << QString::fromStdString(name_value) <<
"," << QString::fromStdString(anonymization_value) <<
"\n";
1289 file_mapping.close();
1296 std::string spl_per_px(
"0028|0002");
1297 std::string spl_per_pxl_value;
1298 getTagValue(gdcmImageIO, spl_per_px, spl_per_pxl_value);
1300 if (spl_per_pxl_value ==
"3")
1306 std::vector<std::string> dicomTags;
1307 if (anonPatientInfo->isChecked())
1309 dicomTags.push_back(
"0010|0010");
1310 dicomTags.push_back(
"0010|0020");
1311 dicomTags.push_back(
"0010|1005");
1312 dicomTags.push_back(
"0010|1040");
1313 dicomTags.push_back(
"0010|2154");
1314 dicomTags.push_back(
"0010|0030");
1315 dicomTags.push_back(
"0010|0032");
1316 dicomTags.push_back(
"0010|1020");
1317 dicomTags.push_back(
"0010|1030");
1320 if (anonPhysician->isChecked())
1322 dicomTags.push_back(
"0008|0090");
1323 dicomTags.push_back(
"0008|0092");
1324 dicomTags.push_back(
"0008|0094");
1325 dicomTags.push_back(
"0008|1048");
1326 dicomTags.push_back(
"0008|1050");
1327 dicomTags.push_back(
"0008|1060");
1328 dicomTags.push_back(
"0032|1032");
1329 dicomTags.push_back(
"0040|0006");
1330 dicomTags.push_back(
"4008|0114");
1333 if (anonOperator->isChecked())
1335 dicomTags.push_back(
"0008|1070");
1338 if (anonScanDate->isChecked())
1340 dicomTags.push_back(
"0008|002A");
1341 dicomTags.push_back(
"0008|0020");
1342 dicomTags.push_back(
"0008|0021");
1343 dicomTags.push_back(
"0008|0022");
1347 QString outputSequence = subject_output_folder + QDir::separator();
1348 if (checkboxPreserveFolderArc->isChecked())
1350 outputSequence = outputSequence + rel_dir;
1354 std::string tag1(
"0020|0011");
1355 std::string append1;
1357 removeForbiddenChar(append1,
"\\/:*?\"<>|");
1358 outputSequence = outputSequence + QString::fromStdString(append1) +
"_";
1360 std::string tag2(
"0018|0024");
1361 std::string append2;
1363 removeForbiddenChar(append2,
"\\/:*?\"<>|");
1364 outputSequence = outputSequence + QString::fromStdString(append2);
1367 QDir outputSequenceDirectory(outputSequence);
1368 bool exist = outputSequenceDirectory.exists();
1371 exist = QDir().mkpath(outputSequence);
1374 MainWindow->printError(
"Failed to create directory: " + outputSequence);
1375 std::cout <<
"Create fail: " << anonymization_value << std::endl;
1381 log =
"Component: [" + gdcmImageIO->GetComponentTypeAsString(gdcmImageIO->GetInternalComponentType()) +
"]";
1382 log +=
", Pixel type: [" + gdcmImageIO->GetPixelTypeAsString(gdcmImageIO->GetPixelType()) +
"]\n";
1383 writeLog(logName, log);
1388 log =
"Changing header";
1389 writeLog(logName, log);
1390 DictionaryType & dictionary = floatImg->GetMetaDataDictionary();
1391 std::vector<std::string>::iterator dicomTagIterator;
1392 for (dicomTagIterator = dicomTags.begin(); dicomTagIterator != dicomTags.end(); dicomTagIterator++)
1394 itk::EncapsulateMetaData<std::string>(dictionary, *dicomTagIterator, anonymization_value);
1398 std::string filename;
1399 makeFilename(outputSequence, gdcmImageIO, index_dicom, filename, index_subject);
1402 typedef itk::ImageFileWriter< shortImageType > Writer1Type;
1403 gdcmImageIO->KeepOriginalUIDOn();
1404 Writer1Type::Pointer writer1 = Writer1Type::New();
1405 writer1->SetInput(floatImg);
1406 writer1->SetFileName(filename.c_str());
1407 writer1->SetImageIO( gdcmImageIO);
1408 writer1->AddObserver(itk::ProgressEvent(), milx::ProgressUpdates);
1409 log =
"Writing image as " + filename;
1410 writeLog(logName, log);
1411 MainWindow->printInfo(QString(
"Writing image as: ") + filename.c_str());
1416 catch (itk::ExceptionObject &ex)
1418 MainWindow->printError(ex.GetDescription());
1419 std::cerr << ex << std::endl;
1425 rgbReaderType::Pointer readerrgb = rgbReaderType::New();
1428 gdcmImageIO = ImageIOType::New();
1429 readerrgb->SetFileName(input.c_str());
1430 readerrgb->SetImageIO(gdcmImageIO);
1431 readerrgb->AddObserver(itk::ProgressEvent(), milx::ProgressUpdates);
1434 readerrgb->Update();
1436 catch (itk::ExceptionObject &ex)
1438 std::cerr << ex << std::endl;
1441 rgbImageType::Pointer rgbImg = readerrgb->GetOutput();
1443 ImageIOType::Pointer gdcmImageIO2 = ImageIOType::New();
1445 log =
"Changing header";
1446 writeLog(logName, log);
1448 DictionaryType & dictionary = rgbImg->GetMetaDataDictionary();
1449 std::vector<std::string>::iterator dicomTagIterator;
1450 for (dicomTagIterator = dicomTags.begin(); dicomTagIterator != dicomTags.end(); dicomTagIterator++)
1452 itk::EncapsulateMetaData<std::string>(dictionary, *dicomTagIterator, anonymization_value);
1456 std::string filename;
1457 makeFilename(outputSequence, gdcmImageIO, index_dicom, filename, index_subject);
1459 typedef itk::ImageFileWriter< rgbImageType > Writer1Type;
1460 gdcmImageIO2->SetMetaDataDictionary(dictionary);
1461 gdcmImageIO2->SetUseCompression(gdcmImageIO->GetUseCompression());
1462 gdcmImageIO2->SetIORegion(gdcmImageIO->GetIORegion());
1463 gdcmImageIO2->SetUIDPrefix(gdcmImageIO->GetUIDPrefix());
1464 gdcmImageIO2->KeepOriginalUIDOn();
1466 Writer1Type::Pointer writer1 = Writer1Type::New();
1467 writer1->SetInput(rgbImg);
1469 writer1->SetFileName(filename.c_str());
1470 writer1->SetImageIO(gdcmImageIO2);
1471 writer1->AddObserver(itk::ProgressEvent(), milx::ProgressUpdates);
1472 writer1->UseInputMetaDataDictionaryOff();
1473 log =
"Writing image as " + filename;
1474 writeLog(logName, log);
1475 MainWindow->printInfo(QString(
"Writing image as: ") + filename.c_str());
1480 catch (itk::ExceptionObject &ex)
1482 MainWindow->printError(ex.GetDescription());
1483 std::cerr << ex << std::endl;
1488 writeLog(logName, log);
1494 std::string tag_idx(
"0020|0013");
1495 std::string append_idx;
1498 std::ostringstream index_dcm;
1499 index_dcm << std::setfill(
'0') << std::setw(4) << append_idx;
1502 QString str_separator(QDir::separator());
1503 filename = path.toStdString() + str_separator.toStdString();
1505 if (checkboxPatientName->isChecked())
1507 std::string append = outputPrefix.toStdString();
1508 removeForbiddenChar(append,
"\\/:*?\"<>|");
1509 filename = filename + append +
"_";
1512 if (checkboxPatientID->isChecked())
1514 std::ostringstream SubID;
1515 SubID << index_subject;
1516 filename = filename + SubID.str() +
"_";
1519 if (checkboxSeriesDate->isChecked())
1521 std::string tag(
"0008|0021");
1526 filename = filename + append +
"_";
1530 if (checkboxSeriesTime->isChecked())
1532 std::string tag(
"0008|0031");
1537 filename = filename + append +
"_";
1541 if (checkboxStudyID->isChecked())
1543 std::string tag(
"0020|0010");
1546 removeForbiddenChar(append,
"\\/:*?\"<>|");
1549 filename = filename + append +
"_";
1553 if (checkboxStudyDesc->isChecked())
1555 std::string tag(
"0008|1030");
1558 removeForbiddenChar(append,
"\\/:*?\"<>|");
1561 filename = filename + append +
"_";
1565 if (checkboxSeriesNumber->isChecked())
1567 std::string tag(
"0020|0011");
1572 filename = filename + append +
"_";
1576 if (checkboxSequenceName->isChecked())
1578 std::string tag(
"0018|0024");
1581 removeForbiddenChar(append,
"\\/:*?\"<>|");
1584 filename = filename + append +
"_";
1588 if (checkboxProtocolName->isChecked())
1590 std::string tag(
"0018|1030");
1593 removeForbiddenChar(append,
"\\/:*?\"<>|");
1596 filename = filename + append +
"_";
1600 if (checkboxSeriesDescription->isChecked())
1602 std::string tag(
"0008|103e");
1605 removeForbiddenChar(append,
"\\/:*?\"<>|");
1608 filename = filename + append +
"_";
1612 filename = filename + index_dcm.str() +
".IMA";
1615 void milxQtDICOMPlugin::removeForbiddenChar(std::string &str,
char* charsToRemove)
1617 for (
unsigned int i = 0; i < strlen(charsToRemove); ++i)
1619 str.erase(
remove(str.begin(), str.end(), charsToRemove[i]), str.end());
1625 itk::MetaDataDictionary & dic = gdcmImageIO->GetMetaDataDictionary();
1626 itk::MetaDataDictionary::ConstIterator tag_iter = dic.Find(tag);
1628 if (tag_iter == dic.End())
1633 MetaDataStringType::ConstPointer entryValue=
dynamic_cast<const MetaDataStringType *
>(tag_iter->second.GetPointer());
1636 tag_value = entryValue->GetMetaDataObjectValue();
1637 QString tag_simplified = QString::fromStdString(tag_value);
1638 tag_simplified = tag_simplified.simplified();
1639 tag_value = tag_simplified.toStdString();
1640 std::replace(tag_value.begin(), tag_value.end(),
' ',
'_');
1644 void milxQtDICOMPlugin::writeLog(QString &filename, std::string &output)
1646 QFile file_log(filename);
1647 if (file_log.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Append))
1649 QTextStream out_log(&file_log);
1650 out_log.setCodec(
"UTF-8");
1651 out_log << QString::fromStdString(output) <<
"\n";
1658 outputAnonymizeDirectoryname = txtOutputAnonymizeName->text();
1659 inputAnonymizeDirectoryname = txtInputAnonymizeName->text();
1660 QDir output(outputAnonymizeDirectoryname);
1661 QDir input(inputAnonymizeDirectoryname);
1662 if (output.exists() && input.exists())
1671 if (!txtOutputPrefix->text().isEmpty())
1673 outputPrefix = txtOutputPrefix->text();
1677 outputPrefix =
"Anon";
1680 QString value = txtOutputInitID->text();
1681 if (!value.isEmpty())
1682 outputInitID = value.toInt();
void openSeries()
Open DICOM image series.
virtual void SetInputCollection(vtkPolyDataCollection *collection, QStringList &filenames)
Pass a collection to internal plugin class. [Implement this in your plugin].
virtual void save(QString filename)
Save the result as a file using the plugin. [Implement this in your plugin].
bool threaded
Threaded plugin?
virtual QString openFileSupport()
Get the file support string for opening (extension wildcard list). [Implement this in your plugin]...
QPointer< milxQtManager > manager
Manager widget.
virtual bool isPluginWindow(QWidget *window)
Is the window provided a plugin generated window? In this case a milxQtShapeModel window...
QAction * actionOpenSeries
open series action
virtual QString name()
Get the Name of the plugin. [Implement this in your plugin].
QPointer< QDockWidget > dock
Dock widget.
void setName(const QString filename)
Set the name of the data.
This class represents the MILX Qt Render Window Display object using QVTK.
bool consoleWindow
console window?
static std::vector< std::string > GetDICOMSeriesFilenames(const std::string directoryPath, const std::string seriesName, bool recursive=false)
Returns the filenames for a given UID/Series name for a given directory.
virtual void open(QString filename)
Open the file using the plugin. [Implement this in your plugin].
This class represents the MILX Qt Image Display object using VTK.
A manager (tabbed) widget class for displaying information about data such as case ID etc...
virtual QStringList openExtensions()
Get a list of supported file format extensions. [Implement this in your plugin].
void done(int value)
Send signal that computation is done. Value carries the progress,.
void PrintError(const std::string msg)
Displays a generic msg to standard error with carriage return.
bool extension
Extension rather than a plugin?
virtual milxQtModel * modelResult()
Get the model result. The result can then be displayed in milxQtMain etc. [Implement this in your plu...
virtual milxQtImage * imageResult()
Get the image result. The result can then be displayed in milxQtMain etc.[Implement this in your plug...
QAction * actionTags
open series action
void makeFilename(const QString &path, ImageIOType::Pointer gdcmImageIO, unsigned int index, std::string &filename, unsigned int index_subject)
Small helper to make filename from dicom tags.
void convert()
Convert a DICOM series (or a path to a number of series) to Nifti (*.nii.gz) images.
This class represents the MILX Qt Model/Mesh Display object using VTK.
milxQtDICOMPlugin(QObject *theParent=0)
Default destructor.
void working(int value)
Send signal that computation is in progress. Value carries the progress,.
bool dockable
Dockable plugin?
virtual milxQtRenderWindow * genericResult()
Get the generic result, which is a milxQtRenderWindow. The result can then be displayed in milxQtMain...
void createWizardAnonymise()
void affectValues()
Function called when the wizard for anonymization is validated It will verify that everything is in o...
virtual QStringList saveExtensions()
Get a list of supported file format extensions. [Implement this in your plugin].
The interface for any plugins that can be made for milxQtMain.
void viewTags()
View DICOM tags of image series in the manager.
void PrintInfo(const std::string msg)
Displays a generic msg to standard output with carriage return.
QAction * actionAnonymize
Anonymize action.
std::string NumberToString(double num, unsigned zeroPad=0)
Number to string converter.
QMenu * menuDICOM
DICOM menu.
static bool ReadImageInformation(const std::string filename, std::string &pixeltype, std::string &componentType, size_t &dimensions)
Reads just the header of an image file (without reading the image data), and writes the info into the...
bool anonymizeDicomImage(const std::string &input, const QString &subject_output_folder, const QString &rel_dir, unsigned int index_subject, unsigned int index_dicom, bool &isFirst)
Function used to anonymize a single dicom image.
QAction * actionConvertStructure
convert RT action
virtual QDockWidget * dockWidget()
Return the dock widget (if one is provided by plugin). [Implement this in your plugin].
static std::vector< std::string > GetDICOMSeriesUIDs(const std::string directoryPath, bool recursive=false)
DICOM Related.
virtual QString saveFileSupport()
Get the file support string for saving (extension wildcard list). [Implement this in your plugin]...
This class represents the MILX Qt Main Window object using Qt.
QAction * actionConvert
convert action
void getTagValue(ImageIOType::Pointer gdcmImageIO, const std::string &tag, std::string &tag_value)
Retrieve tag value fromt he gdcmImageIO object.
virtual void loadExtension()
Load the extension. [Implement this in your plugin].
void openStructureSet()
Open DICOM RT image series.