[ITK-users] Problem with reading dicom series using SimpleITK

Francois Budin francois.budin at kitware.com
Fri Nov 4 10:59:33 EDT 2016


Thanks for sharing the solution to your problem.

Francois

On Fri, Nov 4, 2016 at 10:57 AM, Sara Gh <sg.ele.eng at gmail.com> wrote:

> Dear Francois,
>
> Thank you for your helpful email.
> As you said, the issue was about the series ID. I fixed the issue by
> making metadata (including SeriesInstanceUID) the same for all dicom files
> in my MATLAB code:
>
> sizeP = [128 128 128]
>
> [p,ellipse]=phantom3dAniso(sizeP);
>
> outDir = './SLPData/';
>
> fname = [outDir 'SLP000001.dcm'];
>
> dicomwrite(p(:,:,i), fname);
>
> metadata = dicominfo(fname);
>
> for i=2:sizeP(3)
>
>     fname = [outDir sprintf('SLP%06d.dcm', i)];
>
>     dicomwrite(p(:,:,i), fname, metadata, 'CreateMode', 'copy');
> end
>
> Thanks,
> Sara
>
>
> On Thu, Nov 3, 2016 at 10:26 PM, Francois Budin <
> francois.budin at kitware.com> wrote:
>
>> Hello Sara,
>>
>> Your code using SimpleITK is correct. I downloaded dicom images from here
>> [1] and ran your code with this data and it found all the input dicom that
>> were in the specified folder. Can you make sure that your output DICOM
>> images from matlab are 2D images with the same series ID? My guess isthat
>> your DICOMs have different seriesID, and reader.GetGDCMSeriesFileNames(pathDicomA)
>> only takes the first series it finds (if no seriesID is specified).
>>
>> Hope this helps,
>> Francois
>>
>>
>> [1] https://midas3.kitware.com/midas/folder/7741
>>
>> On Thu, Nov 3, 2016 at 8:46 PM, Sara Gh <sg.ele.eng at gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I have used this MATLAB
>>> <https://www.mathworks.com/matlabcentral/fileexchange/50974-3d-shepp-logan-phantom> code
>>> to create a stack of images using Shepp-Logan Phantom and saved all these
>>> images in dicom format using *dicomwrite* function:
>>>
>>> sizeP = [128 128 128]
>>>
>>> [p,ellipse]=phantom3dAniso(sizeP);
>>>
>>> outDir = './SLPData/';
>>>
>>> for i=1:sizeP(3)
>>>
>>>     fname = [outDir sprintf('SLP%06d.dcm', i)];
>>>
>>>     dicomwrite(p(:,:,i), fname)
>>> end
>>>
>>> So, I have 128 dicom files ('SLP000001.dcm', 'SLP000002.dcm', ... ,
>>> 'SLP000128.dcm' ) in the 'SLPData' folder. Now, I am trying to read
>>> these dicom images in Python using SimpleITK:
>>>
>>> pathDicomA = '/SLPData'
>>> reader = sitk.ImageSeriesReader()
>>> dicom_namesA = reader.GetGDCMSeriesFileNames(pathDicomA)
>>> reader.SetFileNames(dicom_namesA)
>>> imageA = reader.Execute()
>>>
>>> However, when I run the code, it only reads in one of the images
>>> instead of the whole series:
>>>
>>> dicom_namesA => ('.../SLPData/SLP000108.dcm',)
>>> imageA.GetSize()  => (128, 128, 1)
>>>
>>> I am wondering what is causing this issue and how I should resolve it?
>>>
>>> Thanks in advance!
>>>
>>> Best regards,
>>> Sara
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.php
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/insight-users
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20161104/79d9bbe7/attachment.html>


More information about the Insight-users mailing list