public void RemoveMetaHeaderTest() { var dcm = new DICOMObject(); dcm.Elements.Add(DICOMForge.FileMetaInformationGroupLength(0)); dcm.Elements.Add(DICOMForge.FileMetaInformationVersion(0)); dcm.Elements.Add(DICOMForge.PatientID("123456")); dcm.RemoveMetaHeader(); var meta = dcm.Elements.Where(e => e.Tag.Group == "0002").ToList(); Assert.AreEqual(0, meta.Count); }
/// <summary> /// Same function as write, but adds required metadata for file (often missing in DICOM objects transferred over a network) /// </summary> /// <param name="file">the path to write</param> /// <param name="settings">the DICOM settings to write (endianness, and indefinite sequences)</param> public void WriteAddMeta(string file, DICOMIOSettings settings = null) { var newSOP = GetSelector().SOPInstanceUID.Data; var sopClass = GetSelector().SOPClassUID.Data; //ADD REQUIRED METADATA ReplaceOrAdd(DICOMForge.FileMetaInformationGroupLength(0)); ReplaceOrAdd(DICOMForge.FileMetaInformationVersion(0)); ReplaceOrAdd(DICOMForge.MediaStorageSOPClassUID(sopClass)); ReplaceOrAdd(DICOMForge.MediaStorageSOPInstanceUID(newSOP)); ReplaceOrAdd(DICOMForge.ImplementationClassUID("2.16.840.1.113883.3.7570")); Write(file, settings); }