Main Content

isAttribute

Check if specified attribute is present in DICOM file

Since R2023a

    Description

    TF = isAttribute(dFile,attributeName) returns a logical 1 (true) if the attribute attributeName is present in the DICOM file specified by the dicomFile object dFile. Otherwise, it returns a logical 0 (false).

    example

    TF = isAttribute(dFile,group,element) returns a logical 1 (true) if the attribute specified by the DICOM group number group and element number element is present in the DICOM file specified by the dicomFile object dFile. Otherwise, it returns a logical 0 (false).

    example

    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);

    Use the attribute name to check if Modality is an attribute of the DICOM file.

    TF = isAttribute(dFile,"Modality")
    TF = logical
       1
    
    

    Use the group and element numbers of the Modality attribute, in decimal form, to check if it is an attribute of the DICOM file.

    TF = isAttribute(dFile,8,96)
    TF = logical
       1
    
    

    Use the group and element numbers of the Modality attribute, in hexadecimal form, to check if it is an attribute of the DICOM file.

    TF = isAttribute(dFile,"0008","0060")
    TF = logical
       1
    
    

    Input Arguments

    collapse all

    DICOM file in which to search for the attribute, specified as a dicomFile object. The attribute to be searched, may or may not be a property of the 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

    Version History

    Introduced in R2023a