getAttribute
Description
Examples
Find Modality of DICOM File
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
dFile
— DICOM file
dicomFile
object
DICOM file from which to retrieve the attribute value, specified as a dicomFile
object.
attributeName
— Name of attribute
string scalar | character vector
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
— Group number of attribute
numeric scalar | string scalar | character vector
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
— Element number of attribute
numeric scalar | string scalar | character vector
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
data
— Value of DICOM attribute
string scalar | character vector | numeric scalar | numeric vector | structure
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
See Also
dicomFile
| isAttribute
| findAttribute
| updateAttribute
| getPixelData
| write
| dicominfo
External Websites
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)