//create a new Dicom attribute collection DicomAttributeCollection attributes = new DicomAttributeCollection(); //add a new attribute with a string value DicomAttributepatientName = new DicomAttribute (DicomTag.PatientName, "John Doe"); attributes.Add(patientName); //get the value of the patient name attribute string name = attributes.GetString(DicomTag.PatientName);
//create a new Dicom attribute collection from a DICOM file DicomFile file = DicomFile.Open("example.dcm"); DicomAttributeCollection attributes = file.Dataset; //modify an attribute value attributes[DicomTag.PatientName].SetStringValue("Jane Doe"); //write the modified data to a new file file.Save("new_example.dcm");In this example, we load a DICOM file into a new DicomFile object and extract the attribute collection from the file's dataset. We modify the value of the patient name attribute and save the modified data to a new file. Package Library: fo-dicom.