Sorting dicom images in Matlab
<p>I am working with lung data sets in matlab, but I need to sort the slices correctly and show them.</p>

<p>I knew that can be done using the "instance number" parameter in Dicom header, but I did not manage to run the correct code.</p>

<p>How can I do that?</p>

<p>Here is my piece of code:</p>

<pre><code>Dicom_directory = uigetdir();
sdir = strcat(Dicom_directory,'\*.dcm');
files = dir(sdir);
I = strcat(Dicom_directory, '\',files(i).name);
x = repmat(double(0), [512 512 1 ]);
x(:,:,1) = double(dicomread(I));
axes(handles.axes1);
imshow(x,[]);
</code></pre>