我在将文件添加到 DICOMDir 时遇到问题。基于此示例,我已成功创建系列映像并将其保存到磁盘。然后,我尝试将该文件添加到DICOMDIR,以便Dir引用新文件,并且,尽管保存成功,但当我尝试再次打开DICOMDir及其系列时,我得到“标记:(0088,0200)在数据集中找不到”异常。
代码如下:
var dataset = new DicomDataset();
this.FillDataset(dataset); //this function copies several Tag values of an already existing DICOM Series file, such as Patient information
dataset.Add(DicomTag.PhotometricInterpretation, PhotometricInterpretation.Rgb.Value);
dataset.Add(DicomTag.Rows, (ushort)rows);
dataset.Add(DicomTag.Columns, (ushort)columns);
var pixelData = DicomPixelData.Create(dataset, true);
pixelData.AddFrame(buffer);
var dicomfile = new DicomFile(dataset);
var pathImage = Path.Combine(dirImages.FullName, imageFileName);
dicomfile.Save(pathImage); //Image is saved fine and it's well formed, I've checked opening it with an online DICOM viewer
var dicomdirPath = Path.Combine(studyPath, Constants.DICOMDIRFileName);
var dicomdir = DicomDirectory.Open(dicomdirPath);
dicomdir.AddFile(dicomfile, $@"Images\{imageFileName}");
dicomdir.Save(dicomdirPath); //this executes without problems and the DICOMDIR is saved
这是串联开场法:
var dicomDirectory = await DicomDirectory.OpenAsync(dicomdirPath);
foreach (var patientRecord in dicomDirectory.RootDirectoryRecordCollection)
{
foreach (var studyRecord in patientRecord.LowerLevelDirectoryRecordCollection)
{
foreach (var seriesRecord in studyRecord.LowerLevelDirectoryRecordCollection)
{
foreach (var imageRecord in seriesRecord.LowerLevelDirectoryRecordCollection)
{
var dicomDataset = imageRecord.GetSequence(DicomTag.IconImageSequence).Items.First(); //This line works fine before saving the image in the method above, but throws when opening the same study
//Load data and series from dataset
}
}
}
}
我不知道我是否遗漏了有关保存DICOMDir文件的内容,或者是否是错误。
繁星点点滴滴
相关分类