Uploading a DICOM image into Matlab and using imageBatchProcessor

Hi,
I've been trying to upload a DICOM image into Matlab and get it into a format to use in the image batch processor. I've managed to get the image of one slice but can't get the rest. I've tried using different methods to get each slice into individual images.
Here is the first method. It takes a long time to run because the data set is so big and makes Matlab unresponsive.
[X, map] = dicomread('R.G._20150923.dcm');
info = dicominfo('R.G._20150923.dcm');
X = dicomread(info);
imshow('R.G._20150923.dcm')
%Preallocate the image array.
nRows = 512;
nCols = 512;
nPlanes = 1;
nFrames = 199; %The number of files in the directory
Y = repmat(int16(0), [nRows, nCols, nPlanes, nFrames]);
%Read the series of images.
for p=1:nFrames
filename = sprintf('R.G._20150923.dcm',p);
Y(:,:,:,:,p) = dicomread(filename);
end
%Display the image stack
montage(Y, [])
Here is the second method. I found this on the Batch Processing Using the Image Batch Processor App Matlab web page. I keep getting this error when I run it: Reference to non-existent field 'D'.
mkdir('CTdata');
d = load('ct');;
image = squeeze(d.D);
for ind = 1:size(image,3)
fileName = sprintf('Slice%02d.jpg', ind);
imwrite(image(:,:,ind),fullfile('CTdata','R.G._20150923.dcm'));
end
Is there something wrong with my code or is a different way to go about this?
Thanks!

2 comentarios

What is the variable part of the file name? For example are the files R.G.1_20150923.dcm R.G.2_20150923.dcm R.G.3_20150923.dcm and so on? Or are all of the frames in the single R.G._20150923.dcm file?
What is 'ct'? Is it a mat file? +1 to the comment above - let us know more about the format of the data you have now (I am assuming MxNXP volume in a single .dcm file, please confirm).

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre DICOM Format en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Ag. de 2016

Comentada:

el 17 de Ag. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by