How to associate Patient, Study, Series in DICOM file information in C++ itk programming?

Hello,

I need to read in all Dicom files under the path that I input to get the relationship between Patient, Study and Series. But I can only get all the Tag information by reading a single DCIOM or reading DICOM series. How do I list the study corresponding to each patient and the series corresponding to each study?

Thanks

	QString dir = QFileDialog::getExistingDirectory(this, QStringLiteral("打开Series目录"), "F:/", 
	QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
	if (dir.isEmpty() == true)
		return;
	typedef signed short InternalPixelType;
	const unsigned int  Dimension = 3;
	using InternalImageType = itk::Image<InternalPixelType, Dimension>;

	typedef itk::Image<InternalPixelType, Dimension> ImageType;
	typedef itk::ImageSeriesReader<ImageType> ReaderType;

	typedef itk::GDCMImageIO ImageIOType;
	typedef itk::GDCMSeriesFileNames NamesGeneratorType;

	ImageIOType::Pointer gdcmIO = ImageIOType::New();
	NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
	std::string DirectoryPath = dir.toStdString();
	namesGenerator->SetInputDirectory(DirectoryPath);

	namesGenerator->SetUseSeriesDetails(true);
	typedef std::vector<std::string> seriesIdContainer;
	const seriesIdContainer & seriesUID = namesGenerator->GetSeriesUIDs();
	seriesIdContainer::const_iterator seriesItr = seriesUID.begin();
	seriesIdContainer::const_iterator seriesEnd = seriesUID.end();
	qDebug() << "Contains the following DICOM Series: ";
	std::string series_identifier;
	typedef std::vector<std::string> fileNamesContainer;
	fileNamesContainer filenames;
	QMap <QString, fileNamesContainer> UID_Files;
	QString seriesList;
	//正常,构造表格
	ui.tableWidgetSeries->setColumnCount(6);
	ui.tableWidgetSeries->setRowCount(0);//行数
	QStringList headerText = QStringList() << "seriesNumber" << "seriesUID" << "seriesDate" << "seriesDescription" << "modality" << "bodyPartExamined";
	ui.tableWidgetSeries->setHorizontalHeaderLabels(headerText);
	ui.tableWidgetSeries->verticalHeader()->setVisible(false); // 隐藏垂直header
	ui.tableWidgetSeries->setSelectionBehavior(QAbstractItemView::SelectRows);//选中一行
	while (seriesItr != seriesEnd)
	{
		series_identifier = seriesItr->c_str();
		filenames = namesGenerator->GetFileNames(series_identifier);
		UID_Files.insert(QString::fromStdString(series_identifier), filenames);
		ReaderType::Pointer reader = ReaderType::New();
		reader->SetImageIO(gdcmIO);
		reader->SetFileNames(filenames);
		// Reading Data;
		try
		{
			reader->Update();

			//Series信息
			std::string seriesNumber = FindDicomTag("0020|0011", gdcmIO);
			std::string seriesUID = FindDicomTag("0020|000E", gdcmIO);
			std::string seriesDate = FindDicomTag("0008|0023", gdcmIO);
			std::string seriesDescription = FindDicomTag("0008|103E", gdcmIO);
			std::string modality = FindDicomTag("0008|0060", gdcmIO);
			std::string bodyPartExamined = FindDicomTag("0018|0015", gdcmIO);

			int curRow = ui.tableWidgetSeries->rowCount();
			ui.tableWidgetSeries->insertRow(curRow);
			ui.tableWidgetSeries->setItem(curRow, 0, new QTableWidgetItem(QString::fromStdString(seriesNumber)));
			ui.tableWidgetSeries->setItem(curRow, 1, new QTableWidgetItem(QString::fromStdString(seriesUID)));
			ui.tableWidgetSeries->setItem(curRow, 2, new QTableWidgetItem(QString::fromStdString(seriesDate)));
			ui.tableWidgetSeries->setItem(curRow, 3, new QTableWidgetItem(QString::fromStdString(seriesDescription)));
			ui.tableWidgetPatient->setItem(curRow, 4, new QTableWidgetItem(QString::fromStdString(modality)));
			ui.tableWidgetPatient->setItem(curRow, 5, new QTableWidgetItem(QString::fromStdString(bodyPartExamined)));
		}
		catch (const itk::ExceptionObject& excp)
		{
			qDebug() << " Reading Exceptaion Caught" << endl;
			qDebug() << excp.what() << endl;

			return;
		}
		qDebug() <<  seriesItr->c_str() ;
		++seriesItr;
	}

Is there any interface like this that can be classified by Patient or by study?

	typedef std::vector<std::string> seriesIdContainer;
	const seriesIdContainer & seriesUID = namesGenerator->GetSeriesUIDs();

What you seem to want already exists in CTK. @lassoan should be better able to direct you to it.

That is exactly it. If you need usage examples then you can have a look at 3D Slicer or MITK.

@dzenanz @lassoan Thank you for your reply, I will learn about these methods.