[Insight-users] Loading a CT Volume in C# - SimpleITK or ITK
Dan Mueller
dan.muel at gmail.com
Mon Sep 16 15:33:25 EDT 2013
Hi Jason,
What version of SimpleITK are you using? These methods have been
available since at least 0.6.2... There is nothing special you need to
do to access these functions.
How are you viewing/searching the assembly? Visual Studio object
browser? MonoDevelop assembly browswer?
Cheers, Dan
On 17 September 2013 00:38, Jason Gibbs <jdgibbs at gmail.com> wrote:
> Hi Dan,
>
> Thanks for the reply! I've hacked my way around this for now but for the
> future I'd like to see if I can figure this out the right way. My problem
> was that ImageSeriesReader.GetGDCMSeriesFileNames wasn't showing up in the
> assembly as an option. The assembly metadata is listed as below, which
> isn't including that method. Is there something special about static
> methods with swig and C#? I'm very new to swig and how it should be
> configured with CMake.
>
> #region Assembly SimpleITKCSharpManaged.dll, v2.0.50727 //
> C:\Users\jgibbs\Documents\Visual Studio
> 2010\Projects\DisplayDICOM\DisplayDICOM\SimpleITKCSharpManaged.dll
> #endregion using System; namespace itk.simple { public class
> ImageSeriesReader : IDisposable { protected bool swigCMemOwn; public
> ImageSeriesReader(); public virtual void Dispose(); public Image Execute();
> public VectorString GetFileNames(); public ImageSeriesReader
> SetFileNames(VectorString fns); } }
>
> Thanks again for your help!
> Jason
>
>
> On Mon, Sep 16, 2013 at 7:14 AM, Dan Mueller <dan.muel at gmail.com> wrote:
>>
>> Hi Jason,
>>
>> Sorry for the delayed response — I've been away the last few days.
>>
>> You should be able to use the following code to obtain the file names:
>>
>> var reader = new ImageSeriesReader();
>> var names = ImageSeriesReader.GetGDCMSeriesFileNames("C:/Temp");
>> reader.SetFileNames(names);
>> var image = reader.Execute();
>>
>> BTW: If you are not already using it, the new SimpleITK 0.7.0rc1 has
>> added C# operators which are really nice e.g.
>>
>> var threshold = image >= 128;
>>
>> HTH
>>
>> Cheers, Dan
>>
>> On 7 September 2013 02:04, Jason Gibbs <jdgibbs at gmail.com> wrote:
>> > Brad,
>> >
>> > Thank you for the response! I'm pretty sure that global functions
>> > aren't
>> > allowed in C# so it would have to be shoved into some class somewhere,
>> > with
>> > the natural one being ImageSeriesReader.
>> >
>> > I did search through the assembly for any "GDCM" substring in the object
>> > browser; no luck. For now I've wrapped the function on my own and it
>> > works
>> > fine. However I'd be interested if anyone has a more elegant solution
>> > moving forward.
>> >
>> > Thanks again!
>> > Jason
>> >
>> >
>> > On Fri, Sep 6, 2013 at 12:16 PM, Bradley Lowekamp
>> > <blowekamp at mail.nih.gov>
>> > wrote:
>> >>
>> >> Hello Jason,
>> >>
>> >> You are correct that you need a method like
>> >> ImageSeriesReader::GetGDCMSeriesFilenames()[1] which is a static member
>> >> function in C++.
>> >>
>> >> I am not certain, but I believe SWIG translate these static member
>> >> methods
>> >> to global functions with names such as
>> >> ImageSeriesReader_GetGDCMSeriesFilenames. But hopefully you can search
>> >> for
>> >> that function name and find it in the assembly.
>> >>
>> >> Please let up know if you figure it out,
>> >> Brad
>> >>
>> >> [1]
>> >>
>> >> http://www.itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1ImageSeriesReader.html#a26da9041bf5efd3db05524258de15dc2
>> >>
>> >> On Sep 5, 2013, at 6:11 PM, Jason Gibbs <jdgibbs at gmail.com> wrote:
>> >>
>> >> Hello,
>> >>
>> >> I am writing a pure C# based application and first started out using
>> >> the
>> >> SimpleITKCSharpManaged assembly. I'm attempting to load a DICOM image
>> >> from a
>> >> folder. It is known the folder contains only one series. However, I'm
>> >> having trouble ordering the files correctly.
>> >>
>> >> Doing this loads an image, but the slices are all out of order:
>> >> var FilesInFolder = Directory.EnumerateFiles(m_folder).ToList();
>> >>
>> >> itk.simple.ImageSeriesReader reader = new
>> >> itk.simple.ImageSeriesReader();
>> >> itk.simple.VectorString vs = new
>> >> itk.simple.VectorString();
>> >>
>> >> foreach (var file in FilesInFolder)
>> >> vs.Add(file);
>> >> reader.SetFileNames(vs);
>> >>
>> >> m_ITKImg = reader.Execute();
>> >>
>> >> I realize that I need something along the lines of
>> >> GetGDCMSeriesFileNames
>> >> to order the files correctly. It seems this is a public static member
>> >> of
>> >> itk.simple.ImageSeriesReader. However this does not seem to appear in
>> >> the
>> >> assembly metadata (below). Is there something I'm missing or a
>> >> different
>> >> route to achieve the same end result of loading the image in C#? I'm
>> >> assuming that others have loaded CT volumes in the C# wrapper before so
>> >> I'm
>> >> guessing it's something I'm doing incorrectly. Thank you for any help!
>> >>
>> >> Jason Gibbs
>> >>
>> >>
>> >> #region Assembly SimpleITKCSharpManaged.dll, v2.0.50727 //
>> >> C:\Users\jgibbs\Documents\Visual Studio
>> >> 2010\Projects\DisplayDICOM\DisplayDICOM\SimpleITKCSharpManaged.dll
>> >> #endregion using System; namespace itk.simple { public class
>> >> ImageSeriesReader : IDisposable { protected bool swigCMemOwn; public
>> >> ImageSeriesReader(); public virtual void Dispose(); public Image
>> >> Execute();
>> >> public VectorString GetFileNames(); public ImageSeriesReader
>> >> SetFileNames(VectorString fns); } }
>> >>
>> >> _____________________________________
>> >> 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://www.itk.org/mailman/listinfo/insight-users
>> >>
>> >>
>> >
>> >
>> > _____________________________________
>> > 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://www.itk.org/mailman/listinfo/insight-users
>> >
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SimpleITK ImageSeriesReader.png
Type: image/png
Size: 68162 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130917/416102c4/attachment.png>
More information about the Insight-users
mailing list