[ITK] [ITK-users] ImageSeriesWriter | SimpleITK
Matias Montroull
matimontg at gmail.com
Tue Mar 24 17:19:04 EDT 2015
Thanks Bradley,
So, I did this:
ImageFileReader imgreader = new ImageFileReader();
imgreader.SetFileName(path_pacientes + nombre_paciente +
@"\Fusion\" + "resultado.mha");
itk.simple.Image imgtest = imgreader.Execute();
ImageSeriesWriter SeriesWriter = new ImageSeriesWriter();
VectorString vs = new VectorString();
for (int i=0; i < imgtest.GetSize()[2]; ++i)
{
vs.Add("imagen {0}.dcm");
}
SeriesWriter.SetFileNames(vs);
SeriesWriter.Execute(imgtest, vs, false);
And I only get one file name (imagen {0}.dcm), am I missing something? (I
wasn't able to do this: "name {0}.ext".Format(i))
Thanks,
Matias.
On Tue, Mar 24, 2015 at 3:12 PM, Bradley Lowekamp <blowekamp at mail.nih.gov>
wrote:
> Hello,
>
> On Mar 24, 2015, at 1:56 PM, Matias Montroull <matimontg at gmail.com> wrote:
>
> //Here's where I struggle...
> vs.Add(path_pacientes + nombre_paciente +
> @"\Fusion\SalidaTest\imagen%03d.dcm"); //Is this rthe right way to include
> a vector of strings
>
>
>
> No that is not the write way. You actually need to create the list for
> file names. You needs something closer to what's here in the C++ test [1]
> but converted to CSharp. The length of the list must match the z size of
> the images.
>
> Many languages have convenient generator expressions or list
> comprehensions, which seems more natural than C printf formatting and the
> perils associated with it.
>
> The long way to do it is just write a little for loop, something like:
>
> for (i=0; i < img.GetSize()[2], ++i)
> vs.Add( "name {0}.ext".Format(i))
>
> Brad
>
> [1]
> https://github.com/SimpleITK/SimpleITK/blob/master/Testing/Unit/IOTests.cxx#L123-L152
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150324/3dc0f981/attachment-0001.html>
-------------- next part --------------
_____________________________________
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
More information about the Community
mailing list