简体   繁体   中英

How to remove a file from DICOMDIR using fo-dicom

I have created the the DICOMDIR using fo-dicom as follows.

var dicomDir = new DicomDirectory();
var dicomFile = Dicom.DicomFile.Open(dicomFilePath);
dicomDir.AddFile(dicomFile, filePathForDicomDir);
DicomWriteOptions options = DicomWriteOptions.Default;
options.ExplicitLengthSequenceItems = false;
dicomDir.Save(dicomDirPath, options);

I have to remove the already added file from the existing DICOMDIR, but couldn't find a method in the DicomDirectory.cs class.

How do I successfully remove a file reference from a DICOMDIR using fo-dicom, rather than recreating the entire DICOMDIR again?

您是否尝试过删除方法?

dicomDir.File.Delete();

Your request is rather unusual. fo-dicom does not provide a method in DicomDirectory to remove an entry from an existing DICOMDIR.

The filesets in DICOM are meant to be immutable. Such file-sets are a collection of files that are for example burnt on a CD and then are indexed with the DICOMDIR file. So when should you create a DICOMDIR? When you have a set of files to burn on CD and for those you create the DICOMDIR file.

Also internally the DicomDirectoryRecords are list of entries with offsets that reference each other. So removing an entry means internally to completely rebuild the records-structure. So there is not a big advantage of removing an entry over recreating the DICOMDIR.

What is the use case where you need to remove an entry and recreating the DICOMDIR is not possible? If there is a valid use case, then you have to create an issue in fo-dicom project on github.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM