<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Courier New";
panose-1:2 7 3 9 2 2 5 2 4 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New",serif;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier",serif;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.msoIns
{mso-style-type:export-only;
mso-style-name:"";
text-decoration:underline;
color:teal;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Please avoid cross posting questions.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ll repost my answer here for completeness though:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">SimpleITK uses SWIG to wrap a C++ interface to Insight Segmentation and Registration Toolkit (ITK). As such the inline python documentation should be supplemented with the C++ Doxygen documentation. There is a mapping of C++ types to Python
types with robust implicit conversion between them. You can find the documentation for the sitk::ReadImage methods here:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://itk.org/SimpleITKDoxygen/html/namespaceitk_1_1simple.html#ae3b678b5b043c5a8c93aa616d5ee574c">https://itk.org/SimpleITKDoxygen/html/namespaceitk_1_1simple.html#ae3b678b5b043c5a8c93aa616d5ee574c</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Notice there are 2 ReadImage methods, and the Python docstring you listed appears is one of them.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">From the SimpleITK examples here is a snippet to read a DICOM series:<o:p></o:p></p>
<p class="MsoNormal">print( "Reading Dicom directory:", sys.argv[1] )<o:p></o:p></p>
<p class="MsoNormal">reader = sitk.ImageSeriesReader()<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">dicom_names = reader.GetGDCMSeriesFileNames( sys.argv[1] )<o:p></o:p></p>
<p class="MsoNormal">reader.SetFileNames(dicom_names)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">image = reader.Execute()<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This uses the class interface as opposed to the procedural. Which would simply be:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">image = sitk.ReadImage(dicom_names)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">or generically with a list of string filenames:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">image = sitk.ReadImage(["image1.png", "image2.png"...])<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Many common array like type of strings will be implicitly converted to the SWIG VectorStringtype.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Oren <oren.a4@gmail.com><br>
<b>Date: </b>Friday, July 14, 2017 at 3:12 AM<br>
<b>To: </b>"community@itk.org" <community@itk.org><br>
<b>Subject: </b>[ITK] Can python sitk.ReadImage read a list of images?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Hello,<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:.5in">I do not understand if sitk.ReadImage can read a list of images or not? I did not manage to find an example showing how to list of images should be imputed to the function.
<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">But in the function documentations it say:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<div style="mso-element:para-border-div;border:solid #CCCCCC 1.0pt;padding:5.0pt 5.0pt 5.0pt 5.0pt;background:#F7F7F7;margin-left:.5in;margin-right:0in">
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in;box-sizing:border-box;word-wrap:break-word;border-radius:2px;white-space:pre-wrap;overflow:auto"><span style="font-size:10.5pt;color:black">ReadImage(<b>VectorString fileNames</b>, itk::simple::PixelIDValueEnum outputPixelType) -> Image<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">ReadImage(std::string const & filename, itk::simple::PixelIDValueEnum outputPixelType) -> Image<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black"><o:p> </o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black"><o:p> </o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black"><o:p> </o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">ReadImage is a procedural interface to the ImageSeriesReader class which is convenient for most image reading tasks.<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black"><o:p> </o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black"><o:p> </o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">Note that when <b>reading a series of images</b> that have meta-data<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">associated with them (e.g. a DICOM series) the resulting image will<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">have an empty meta-data dictionary. It is possible to programmatically<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">add a meta-data dictionary to the compounded image by reading in one<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">or more images from the series using the ImageFileReader class,<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">analyzing the meta-dictionary associated with each of those images and<o:p></o:p></span></pre>
<pre style="margin-bottom:6.75pt;line-height:14.55pt;background:#F7F7F7;word-break:break-all;border:none;padding:0in"><span style="font-size:10.5pt;color:black">creating one that is relevant for the compounded image.<o:p></o:p></span></pre>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
<br>
<br>
So it seems from the documentations that it is possible. Can someone show me a simple example.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">I also posted the question in stackoverflow in case anyone else will ask it in the future:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="https://stackoverflow.com/questions/45096861/can-python-sitk-readimage-read-a-list-series-of-images">https://stackoverflow.com/questions/45096861/can-python-sitk-readimage-read-a-list-series-of-images</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Thanks.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>