Find a specific value/text inside a dicom header

11 Ansichten (letzte 30 Tage)
Alec Buczek
Alec Buczek am 16 Apr. 2021
Beantwortet: aditi bagora am 10 Okt. 2023
Hi, I have dicom files (not images) which contain a header with lots of metadata, in the form of a structure with sub-structures. I need to find all the occurances of the value 'BODY' inside this header... any ideas? thanks!!

Antworten (1)

aditi bagora
aditi bagora am 10 Okt. 2023
Hello Alec,
I understand you want to read metadata from a DICOM file and specifically want to identify the fields that contain the term 'BODY' in the metadata.
You can use "dicominfo()" function to read the metadata from the DICOM file and store it in a structure called "dicom_info". You can directly access field name using the syntax dicom_info.filed_name.
To locate all instances of the term 'BODY' within the metadata, you can follow the below steps:
1. Read the metadata using the "dicominfo()" function and save it as a structure.
2. Extract all the field names from the structure using the "fields()" function.
3. Use "cellfun()" to iterate through the field names and identify the ones that contain the term 'BODY'. This will provide you with the indices of the matching fields.
4. Utilize the "find()" function to locate the field names that match the criteria.
5. Iterate through the identified fields and extract their corresponding values using the "extractfield()" function.
Below is a sample code that finds occurrences of ‘ID’ in the fields of DICOM header.
% Reading the metadata and fields in the structure
dicom_info = dicominfo('CT-MONO2-16-ankle.dcm');
fieldnames = fields(dicom_info);
% Filter all the tags that contains ‘ID’.
matchingindices =cellfun(@(y) ~isempty(strfind(y,'ID')), fieldnames);
matchingfieldnames = fieldnames(find(matchingindices)');
% Create a cell array that contains the field names and their values
val = cell([numel(matchingfieldnames),2]);
for i=1: numel(matchingfieldnames)
val{i,1} = matchingfieldnames{i};
val{i,2} = extractfield(dicom_info, matchingfieldnames{i});
end
Please refer to the following documentation to know more about reading metadata using "dicominfo" function:
Hope this helps!
Regards,
Aditi

Kategorien

Mehr zu DICOM Format finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by