Making a cell array of DICOM headers.
Show older comments
Hi there,
I'm VERY new to Matlab and trying to make a cell array of DICOM headers.
Can someone please advise me on how to do this in the simplist way possible?
Many thanks in advance,
Joe
3 Comments
Rik
on 3 Oct 2019
I would say dicominfo is the function you're looking for. But why do you want it specifically in a cell? Are you aware that dicom tags are actually defined by an 8 element long hexadecimal value?
CAM
on 4 Oct 2019
dicominfo provides all the fields in a structure. You can call the specific fields directly using the dot notation (info.fieldname). This is easier than looking up a field and value in a cell array.
Rik
on 4 Oct 2019
Thanks both for your response.
I'm trying to use Matlab for dicom conversion and have been given the script shown in the image below. The guidance in the script says that in the function 'spm_dicom_convert(hdr,opts,root_dir,format,out_dir)' I need to replace 'hdr' with 'a cell array of DICOM headers from spm_dicom_headers'. I'm not sure how to do this. I'm sure this is very basic but can you walk me through what I need to do?
Thanks for your patience.

Answers (1)
Rik
on 4 Oct 2019
0 votes
It seems that there is a function called spm_dicom_headers that will get the dicom header in the correct form. I would assume it is in the same zip file (or website) you got this function from.
5 Comments
joseph Mole
on 8 Oct 2019
Rik
on 8 Oct 2019
However, I'm not sure how to create the variable 'P - array of filenames'. I've managed to create a variable S, which appears to put a list of the filenames into a column in a document but I'm not sure what I should do next to create a variable that takes this information and creates an array of filenames. Do you have any suggestions? Thanks again.

Rik
on 8 Oct 2019
Please stop posting comments in the answer section.
The documentation could have been written a bit better. I would have a assumed a cell array would be preffered, but it turns out it expects a char array with one file name per line. This means you have to pad the file name with spaces.
You can convert your struct array like this:
%s=dir(___);%put your command here
s([s.isdir])=[];%remove folders (including . and ..)
P_folder={s(:).folder};%convert to cell
P_file={s(:).name};%convert to cell
P_folder=cell2mat(pad(P_folder','left'));%pad with spaces and convert to array
P_file=cell2mat(pad(P_file','right'));%pad with spaces and convert to array
P=[P_folder repmat(filesep,size(P_folder,1),1) P_file];%merge to full path
The P resulting from this code should be in the format that spm_dicom_headers can handle.
joseph Mole
on 8 Oct 2019
Rik
on 8 Oct 2019
Those are not error messages, but warning messages. They tell you you're attempting to treat bmp files as if they are dicom files. If you don't have dicom files, why are you trying to use a dicom file reader?
Categories
Find more on DICOM Format in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
