Main Content

dicomupdate

Update value of target attribute in DICOM metadata

Since R2021b

    Description

    example

    newinfo = dicomupdate(info,attributeInfo) updates the values of the target attributes of the DICOM metadata structure info, and returns the updated metadata structure, newinfo. The attributeInfo argument specifies the locations and new values of the target attributes.

    newinfo = dicomupdate(info,attribute,value) updates the value of a target attribute in a DICOM metadata structure by specifying the name of the target attribute and the new value.

    Examples

    collapse all

    Create the DICOM metadata structure by reading it from a DICOM file.

    info = dicominfo("rtstruct.dcm");

    Find the value of a metadata field and its location in the DICOM metadata structure. The dicomfind function returns a table with two columns: Location and Value. Each element of the table is a cell array.

    ROINumber_info = dicomfind(info,"ROINumber")
    ROINumber_info=2×2 table
                          Location                      Value
        ____________________________________________    _____
    
        {'StructureSetROISequence.Item_1.ROINumber'}    {[1]}
        {'StructureSetROISequence.Item_2.ROINumber'}    {[2]}
    
    

    Specify a new value for the Value field of the second ROInumber.

    ROINumber_info.Value{2} = 4
    ROINumber_info=2×2 table
                          Location                      Value
        ____________________________________________    _____
    
        {'StructureSetROISequence.Item_1.ROINumber'}    {[1]}
        {'StructureSetROISequence.Item_2.ROINumber'}    {[4]}
    
    

    Update the DICOM metadata structure info by specifying the table that contains the new value for the second ROInumber field. The dicomupdate function creates a new, updated DICOM metadata structure.

    newInfo = dicomupdate(info,ROINumber_info);

    Check that the newInfo structure contains the updated value.

    ROINumber_info = dicomfind(newInfo,"ROINumber")
    ROINumber_info=2×2 table
                          Location                      Value
        ____________________________________________    _____
    
        {'StructureSetROISequence.Item_1.ROINumber'}    {[1]}
        {'StructureSetROISequence.Item_2.ROINumber'}    {[4]}
    
    

    Create a DICOM metadata structure by using the dicominfo function.

    info = dicominfo("rtstruct.dcm");

    Find the value and location in the info structure of the ROINumber metadata field by using the dicomfind function.

    ROINumber = dicomfind(info,"ROINumber")
    ROINumber=2×2 table
                          Location                      Value
        ____________________________________________    _____
    
        {'StructureSetROISequence.Item_1.ROINumber'}    {[1]}
        {'StructureSetROISequence.Item_2.ROINumber'}    {[2]}
    
    

    Update the ROINumber field in the DICOM metadata structure, info, by specifying the name of the field and its new value.

    newInfo = dicomupdate(info,ROINumber=4);

    Check that the newInfo structure contains the updated field. Notice that the metadata structure contains updated values for all instances of the specified attribute.

    ROINumber_info = dicomfind(newInfo,"ROINumber")
    ROINumber_info=2×2 table
                          Location                      Value
        ____________________________________________    _____
    
        {'StructureSetROISequence.Item_1.ROINumber'}    {[4]}
        {'StructureSetROISequence.Item_2.ROINumber'}    {[4]}
    
    

    Input Arguments

    collapse all

    DICOM metadata, specified as a structure. You can extract the DICOM metadata structure from a DICOM file using the dicominfo function.

    Data Types: struct

    Location and new value of the target attribute, specified as a table.

    Name of the target DICOM metadata field, specified as a string scalar or character vector.

    Example: "ROINumber"

    Data Types: string | char

    New value for the DICOM metadata attribute, specified as a numeric array, string scalar, or character vector.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string

    Output Arguments

    collapse all

    Updated DICOM metadata, returned as a structure.

    Version History

    Introduced in R2021b

    See Also

    | | | | | | | | | | (Medical Imaging Toolbox) | (Medical Imaging Toolbox)