I have a DICOM RT STRUCTURE file (attached) with 1 structure set. I tried dicomread(filename) but it returned an empty array. Are there any scripts to read DICOM RT STRUCTURE file with Matlab?

 Akzeptierte Antwort

Thomas
Thomas am 4 Mär. 2014
Bearbeitet: Thomas am 4 Mär. 2014

4 Stimmen

or try
RSInfo=dicominfo('RS.ZZ_YUNINN_.dcm');
dicomwrite(1, 'RSDicomOut.dcm', RSInfo, 'CreateMode', 'Copy');
Then read
X=dicomread('RSDicomOut.dcm');

13 Kommentare

Yun Inn
Yun Inn am 4 Mär. 2014
Hi Thomas,
I tried the code and it returned a single number?
Yun
Thomas
Thomas am 4 Mär. 2014
Bearbeitet: Thomas am 4 Mär. 2014
hmmm. here is why-
RSInfo
RSInfo =
Filename: [1x55 char]
FileModDate: '04-Mar-2014 05:50:52'
FileSize: 1899490
Format: 'DICOM'
FormatVersion: 3
Width: []
Height: []
BitDepth: []
The image you attached is not being read correctly by matlab.. no width , height or bit depth..
are you sure your Dicom RT file is valid..
I have another dicom-rt image and this is how the output of dicominfo looks like..
info1=dicominfo('image_0.dcm')
info1 =
Filename: [1x52 char]
FileModDate: '11-Jan-2012 07:42:44'
FileSize: 525444
Format: 'DICOM'
FormatVersion: 3
Width: 512
Height: 512
BitDepth: 16
ColorType: 'grayscale'
Yun Inn
Yun Inn am 5 Mär. 2014
Hi Thomas,
Finally figured out what was wrong. The RTStructure.dcm file does not have any width, height, or bit depth information. The information is contained in the CTimage.dcm file. The GitHub link with codes provided by Ulrik is very helpful. Thank you very much!
Yun Inn
Yun Inn am 18 Mai 2014
Hi Zahra,
The RTstructure.dcm is related to the set of CTimage.dcm files. Without the CTimage.dcm, the RTstructure.dcm will be meaningless.
In order for the correct readout of the structures, the RTstructure.dcm and the whole set of CTimage.dcm (all axial slices) must be in the same folder. Subsequently, you can use the codes provided by Ulrik on Github (https://github.com/ulrikls/dicomrt2matlab) to read and convert the structure into binary image in matlab. To display the outline of structure, you can try using the bwtraceboundary function.
If you have more than 1 structures, you can browse the structure from the output under: contours(?,?).Segmentation;
Hope you can see this reply and it would be helpful to you.
zahra
zahra am 18 Mai 2014
Dear Yun,
Thank you for your help and guides. I gather all of the CT images with the structure file in one folder and run the following function: >> dicomrt2matlab('RTSTRUCT_NAGHDI MAHBANOO_S1_C1')
but finally get these errors, I don't know what is the header and what should I do to fix this error, Do you have any idea?
error: Reading image headers... Converting RT structures... ??? Reference to non-existent element of a cell array.
Error in ==> getAffineXfm at 7 dr = headers{1}.PixelSpacing(1);
Error in ==> readRTstructures at 4 xfm = getAffineXfm(imgheaders);
Error in ==> dicomrt2matlab at 26 contours = readRTstructures(rtssheader, imageheaders); %#ok<NASGU>
Bests
Yun Inn
Yun Inn am 18 Mai 2014
Hi Zahra,
Check that you have these functions from the Github download: (1) scanDir.m (2) dicomrt2matlab.m (3) loadDicomImageInfo.m (4) readRTstructures.m (5) getAffinexfm.m
Then put all the dicom files (RTstructure.dcm and all CTimage.dcm) in one folder (e.g. FolderA), and just run these 2 lines:
% Specify the path of the folder
directory='/Users/xxxx/Desktop/FolderA;
% Output into the same folder
files_out = scanDir(directory);
You should see the .mat file saved in the same folder. It could take a few minutes to get the output depending on the number of CT slices and structures.
Hope it works for you!
zahra
zahra am 19 Mai 2014
Hi,
Thank you very much. I do your suggestions but finally get this:
Converting C:\Users\zahra si\Documents\MATLAB\brachy\patient2\RTSTRUCT_NAGHDI MAHBANOO_S1_C1.dcm
and the files_out is just: files_out =
{}
I really don't know what is the problem!
Bests,
zahra
zahra am 19 Mai 2014
Excuse me, I mean that no .mat file was created.
Bests, Zahra
zahra
zahra am 20 Mai 2014
Dear Yun,
Finally I can have a .mat file in that folder after running the codes, but can you see your structures on the CTs? If yes would you please let me know how? I can't do it by imshow.
Bests, Zahra
Yun Inn
Yun Inn am 21 Mai 2014
Bearbeitet: Walter Roberson am 25 Mai 2018
Hi Zahra,
I haven't tried that but you should be able to. If you are seeing all black on the CT image, then its the windowing. You can set the window limits.
imshow(Im, [LowLim UpLim])
To display the structure, you have to specify which structure first. Example:
Str1=contours(1,1).Segmentation; % (1,1) is just an example.
Choose your own structure of interest. Then
imshow(Str1)
If you want only the outline, you have to trace the boundary first, bwtraceboundary. To superimpose, use 'hold on'.
Thomas
Thomas am 14 Aug. 2014
Hello Zahra, Can you describe how you solved the problem with
files_out =
{} ?
Any help is much appreciated, Tom
manuela
manuela am 3 Sep. 2014
Hello Zahra, I have the same problem as Thomas, Please let me know how you solved the problem files_out = {} Thank you very much, Manuela
zahra
zahra am 3 Sep. 2014
Hi Thomas, Excuse me I see your question now. I just did what Yun said put all of my CTs and structures to a single folder and run the code as : % Specify the path of the folder
directory='/Users/xxxx/Desktop/FolderA;
% Output into the same folder
files_out = scanDir(directory); Bests.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

MARIA LIZONDO
MARIA LIZONDO am 22 Dez. 2016

0 Stimmen

Hi all,
I have tried to use this code but I have problems to view the structure...
imshow(Str1)
Error using images.internal.imageDisplayValidateParams>validateCData (line 115)
Multi-plane image inputs must be RGB images of size MxNx3.
Error in images.internal.imageDisplayValidateParams (line 27)
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 222)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Thanks in advance!
Maria

2 Kommentare

Mengxiao Wang
Mengxiao Wang am 25 Mai 2018
Hi Maria, Can you solve the problem to view the structure? Thank you very much. Megan
Walter Roberson
Walter Roberson am 25 Mai 2018
Bearbeitet: Walter Roberson am 25 Mai 2018
What shows up for size(Str1) and class(Str1) ?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu DICOM Format finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 4 Mär. 2014

Beantwortet:

am 22 Sep. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by