Main Content

getAttribute

Get value of specified top level DICOM attribute

Since R2023a

    Description

    example

    data = getAttribute(dFile,attributeName) returns the value data of the attribute attributeName from the DICOM file specified by the dicomFile object dFile.

    example

    data = getAttribute(dFile,group,element) specifies the attribute to get as a DICOM group number group and element number element.

    Examples

    collapse all

    Import a DICOM file into the workspace. The DICOM file is part of a data set containing three CT volumes. The size of the entire data set is approximately 81 MB. Download the data set from the MathWorks® website, then unzip the folder.

    zipFile = matlab.internal.examples.downloadSupportFile("medical","MedicalVolumeDICOMData.zip");
    filepath = fileparts(zipFile);
    unzip(zipFile,filepath)
    datapath = fullfile(filepath,"MedicalVolumeDICOMData/LungCT01/CT000000.dcm");
    dFile = dicomFile(datapath);

    Get the value of the Modality attribute of the DICOM file.

    modality = getAttribute(dFile,"Modality")
    modality = 
    'CT'
    

    Use the group and element numbers of the Modality attribute, in decimal form, to get its value from the DICOM file.

    modality = getAttribute(dFile,8,96)
    modality = 
    'CT'
    

    Use the group and element numbers of the Modality attribute, in hexadecimal form, to get its value from the DICOM file.

    modality = getAttribute(dFile,"0008","0060")
    modality = 
    'CT'
    

    Input Arguments

    collapse all

    DICOM file from which to retrieve the attribute value, specified as a dicomFile object.

    Name of the attribute, specified as a string scalar or character vector. This argument is case sensitive and must exactly match the DICOM attribute name. For a list of attributes present in the DICOM file, check the AttributeNames property of the dicomFile object dFile.

    Data Types: char | string

    Group number of the attribute, specified as a numeric scalar, string scalar, or character vector. Use a numeric scalar to specify the group number as a decimal value, and a string scalar or character vector to specify the group number as a hexadecimal value. You can find the group number of an attribute by using the dicomlookup function. For more information on the group numbers of DICOM attributes, see Registry of DICOM Data Elements.

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

    Element number of the attribute, specified as a numeric scalar, string scalar, or character vector. Use a numeric scalar to specify the element number as a decimal value, and a string scalar or character vector to specify the element number as a hexadecimal value. You can find the element number of an attribute by using the dicomlookup function. For more information on the element numbers of DICOM attributes, see Registry of DICOM Data Elements.

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

    Output Arguments

    collapse all

    Value of the DICOM attribute, returned as a string scalar, character vector, numeric scalar, numeric vector, or structure, depending upon the value representation (VR) of the specified DICOM attribute.

    Version History

    Introduced in R2023a