<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Thanks Richard</div><div class=""><br class=""></div><div class="">I’ve built the SWIG branch and used it to recompile SimpleITK with R wrapping - so far working like a charm!</div><div class=""><br class=""></div><div class="">Character vectors as arguments and returns now seems to be working fine; I can access the DICOM image metadata as expected.  The ImageSeriesReader_GetGDCMSeriesFileNames() also now works.  I guess it would be nice to have the static methods available via the $ operator just for consistency with e.g. Python wrapping but it is not a big deal.</div><div class=""><br class=""></div><div class="">Many thanks for the help</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 5 Apr 2016, at 04:30, Richard Beare <<a href="mailto:richard.beare@gmail.com" class="">richard.beare@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">I have a better fix for this now, but it requires building your own swig. I've made a pull request but it will probably take a while to work its way through to the release.<br class=""><br class=""></div>If you get swig from:<br class=""><br class=""><a href="https://github.com/richardbeare/swig.git" class="">https://github.com/richardbeare/swig.git</a><br class=""><br class=""></div>and use the RCharacterVectorSupport branch then you will end up with a working version (hopefully).<br class=""><br class=""></div>The issue with static methods seems to vary with language - some bindings allow an instance of a class to access a static method, others don't.<br class=""><div class=""><br class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Apr 4, 2016 at 1:18 AM, Mathew Guilfoyle <span dir="ltr" class=""><<a href="mailto:mrguilfoyle@gmail.com" target="_blank" class="">mrguilfoyle@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi<div class=""><br class=""></div><div class="">I’ve been trying to get to grips with using the R wrapping to SimpleITK.  On OS X 10.11 I’ve successfully built/compiled SimpleITK from source with Python and R wrapping turned on in Cmake.  I can import the SimpleITK package into R 3.2.4 within Studio without any error reports.</div><div class=""><br class=""></div><div class="">The main difficulties I’m finding are around importing CT image volumes which are stored as a series of image slices within a single directory.   Following the usual workflow I’ve tried in Python I start with:</div><div class=""><br class=""></div><div class="">reader = ImageSeriesReader()</div><div class=""> </div><div class="">this works ok but the ‘GetGDCMSeriesFileNames’ function is not exposed for the reader object via the $ operator.   This is in contrast to the Python wrapping where this function is available as 'reader.GetGDCMSeriesFilenames()'</div><div class=""><br class=""></div><div class="">In R the ImageSeriesReader_GetGDCMSeriesFileNames() static function is available but does not work when supplied with a directory either as a R character vector or as a SimpleITK ‘VectorString’ object.</div><div class=""><br class=""></div><div class="">For the moment I have resorted to getting a list of the files with native R code. Passing this list as an argument to reader$SetFileNames() causes the R session to crash.  Instead I’ve created a (SimpleITK) VectorString of appropriate length and then transfer the individual filenames from the R list within a loop, before finally using the reader$SetFileNames(VectorString) method.  When I then run reader$Execute the DICOM image series is correctly read to an image object.</div><div class=""><br class=""></div><div class="">Next I need to do some initial image transformation based on certain fields of DICOM metadata.  However, I’ve not been able to access this at all.  The image$GetMetaDataKeys() function does not work, reporting the error:</div><div class=""><div class=""><br class=""></div><div class=""><i class="">Error in validObject(.Object) : </i></div><div class=""><i class="">  invalid class “_p_std__vectorT_std__string_std__allocatorT_std__string_t_t” object: invalid object for slot "ref" in class "_p_std__vectorT_std__string_std__allocatorT_std__string_t_t": got class "character", should be or extend class "externalptr"</i></div></div><div class=""><br class=""></div><div class="">Image$GetMetaData(key) also returns an error whatever key value I use (including DICOM keys that I know are included in the series), whether these are passed as as an R character string or SimpleITK VectorString.</div><div class=""><br class=""></div><div class="">I know that the metadata is being read, at least to a certain extent, because  basic info like pixel spacing, image direction, origin etc are all present and correct, and accessible via their dedicated Get.. methods.</div><div class=""><br class=""></div><div class="">If I’m using these functions with incorrect arguments or committing some other error I would be grateful for any pointers.</div><div class=""><br class=""></div><div class="">Cheers</div><div class="">Mat</div></div><br class="">_____________________________________<br class="">
Powered by <a href="http://www.kitware.com/" rel="noreferrer" target="_blank" class="">www.kitware.com</a><br class="">
<br class="">
Visit other Kitware open-source projects at<br class="">
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank" class="">http://www.kitware.com/opensource/opensource.html</a><br class="">
<br class="">
Kitware offers ITK Training Courses, for more information visit:<br class="">
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank" class="">http://www.kitware.com/products/protraining.php</a><br class="">
<br class="">
Please keep messages on-topic and check the ITK FAQ at:<br class="">
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank" class="">http://www.itk.org/Wiki/ITK_FAQ</a><br class="">
<br class="">
Follow this link to subscribe/unsubscribe:<br class="">
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank" class="">http://public.kitware.com/mailman/listinfo/insight-users</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>