[ITK] [ITK-users] (R wrapping/SimpleITK) AddCommand to ImageRegistrationMethod bug
Bradley Lowekamp
brad at lowekamp.net
Fri Apr 15 09:55:44 EDT 2016
Hi!
Glad to hear you go it working.
SimpleITK wraps the majority of ITK’s image filters, it is however not a complete instantiation of all of ITK. If you find that there are missing filters or functionality that you need please post.
Enjoy!
Brad
> On Apr 15, 2016, at 9:15 AM, Fethallah Benmansour <fethallah at gmail.com <mailto:fethallah at gmail.com>> wrote:
>
> Thanks Richard.
> Followed your advice and found my way. The example script works like a charm :-)
> Are all the itk filters now callable from R, or just a subset ? how can I know this ?
> Thanks for all the great effort.
>
> --
> Fethallah
>
>
> On Thu, Apr 14, 2016 at 11:26 PM, Richard Beare <richard.beare at gmail.com <mailto:richard.beare at gmail.com>> wrote:
> You ought to be OK with bison - can you get that?
>
> The latest version of simpleitk on the github site have support for building swig from github,so you can avoid the manual build. On all the systems I've tested it is bison that appears to be used in the early stages of swig building.
>
> On Fri, Apr 15, 2016 at 6:57 AM, Fethallah Benmansour <fethallah at gmail.com <mailto:fethallah at gmail.com>> wrote:
> Hi there,
>
> Any chance to get it to work on a Redhat 6.3 ?
> The current blocker is yacc, which I couldn't install with yum (EPEL enabled).
>
> Thanks,
>
> --
> Fethallah
>
> On Mon, Apr 11, 2016 at 5:14 PM, Bradley Lowekamp <brad at lowekamp.net <mailto:brad at lowekamp.net>> wrote:
> Hello,
>
> We have R tested with SimpleITK on a number of systems each night. And this morning we have run the tests on several systems, and it is running and passing OK, this was with what every old R version was on the systems
>
> We should focus on getting the tests to pass on your system first. It’s a good sign that you can run the AddCommand with the sitk::Command class. Does the rest of the R tests pass when you run ctest?
>
> I am still suspicious you are not running the latest development version. What is the git hash you are using?
>
> As you were digging into the SimpleITK R code you were on the right track with the ProccessObject::AddCommand and the sitk::Command class. The other two parts you are missing is the RCommand C++ class [1], and the overridden ProcessObject::AddCommand method [2]. These were recently added to SimpleITK since the 0.9 release. You can see that the added procedure wraps the passed callable, into the RCommand class.
>
> HTH,
> Brad
>
>
> [1] https://github.com/SimpleITK/SimpleITK/blob/master/Wrapping/R/sitkRCommand.h <https://github.com/SimpleITK/SimpleITK/blob/master/Wrapping/R/sitkRCommand.h>
> [2] https://github.com/SimpleITK/SimpleITK/blob/2ffffba589b24465a09eed1303bbffd6fe3fe18e/Wrapping/R/R.i#L565-L589 <https://github.com/SimpleITK/SimpleITK/blob/2ffffba589b24465a09eed1303bbffd6fe3fe18e/Wrapping/R/R.i#L565-L589>
>
>> On Apr 11, 2016, at 3:59 AM, Mathew Guilfoyle <mrguilfoyle at gmail.com <mailto:mrguilfoyle at gmail.com>> wrote:
>>
>> I tried running the code below as suggested - both in RStudio and the terminal - and get the same abort/segfault error.
>>
>> Which version of R are you running? - I can install an older version to see if it works.
>>
>>> On 11 Apr 2016, at 01:02, Richard Beare <richard.beare at gmail.com <mailto:richard.beare at gmail.com>> wrote:
>>>
>>> This is a long shot, but lets try testing whether it is the R garbage collection causing issues. Modify the test so that every method call result is assigned to a different variable:
>>>
>>> e.g.
>>>
>>> a1 <- gaussian$SetVariance(2)
>>> a2 <- gaussian$AddCommand( 'sitkStartEvent', f1 )
>>> a3 <- gaussian$AddCommand( 'sitkEndEvent', f2 )
>>>
>>> I was running in a terminal on my mac, with an older version of R.
>>>
>>>
>>> On Mon, Apr 11, 2016 at 9:56 AM, Mathew Guilfoyle <mrguilfoyle at gmail.com <mailto:mrguilfoyle at gmail.com>> wrote:
>>> Richard
>>>
>>> It seems it must be something specific to my setup. I ran your example and get the same hard abort in Rstudio. Running the example in R.app I get the same error but a somewhat more graceful crash with the following error message:
>>>
>>> gaussian$AddCommand( 'sitkStartEvent', f1 )
>>>
>>> *** caught segfault ***
>>> address 0x7ff511000080, cause 'memory not mapped'
>>>
>>> Traceback:
>>> 1: .Call("R_swig_ProcessObject_AddCommand", self, event, cmd, as.logical(.copy), PACKAGE = "SimpleITK")
>>> 2: f(x, ...)
>>> 3: gaussian$AddCommand("sitkStartEvent", f1)
>>>
>>> Possible actions:
>>> 1: abort (with core dump, if enabled)
>>> 2: normal R exit
>>> 3: exit R without saving workspace
>>> 4: exit R saving workspace
>>>
>>> I have tried the version of SimpleITK built without the version of SWIG you patched to correct the character argument error, again I get the same behaviour.
>>>
>>> Bradley - I’m using the latest SimpleITK 0.9 source compiled using the super build on OS X 10.11. I’ve done the build with the supplied SWIG and with a version patched by Richard and available here: https://github.com/richardbeare/swig.git <https://github.com/richardbeare/swig.git>. I’m funning R 3.2.4 in Rstudio IDE.
>>>
>>>
>>>
>>>> On 10 Apr 2016, at 23:17, Bradley Lowekamp <brad at lowekamp.net <mailto:brad at lowekamp.net>> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I would like to know your environment.
>>>>
>>>> What version of SimpleITK? R? OS? Compiler? Did you use simpleITK's super build? If not what version of SWIG?
>>>>
>>>> Thanks
>>>>
>>>>> On Apr 10, 2016, at 9:46 AM, Mathew Guilfoyle <mrguilfoyle at gmail.com <mailto:mrguilfoyle at gmail.com>> wrote:
>>>>>
>>>>> Richard
>>>>>
>>>>> Thanks for the reply. I hadn't appreciated that function being passed in the registration example was a closure. However, in the FiterProgressReporting example it is not a closure.
>>>>>
>>>>> I have modified my code to be a closure but still get a crash/abort; I have also run the code in the examples themselves verbatim and get the same problem.
>>>>>
>>>>> Any further ideas on how to get this working?
>>>>>
>>>>> Cheers
>>>>>
>>>>>
>>>>>> On 10 Apr 2016, at 02:10, Mathew Guilfoyle <mrguilfoyle at gmail.com <mailto:mrguilfoyle at gmail.com>> wrote:
>>>>>>
>>>>>> There seems to be a problem with using the $AddCommand function to ImageRegistrationMethod objects in the R wrapping to SimpleITK.
>>>>>>
>>>>>> Using R 3.2.4 on OS X 10.11
>>>>>>
>>>>>> Example:
>>>>>>
>>>>>> f <- function(x){print(x$GetMetricValue())}
>>>>>>
>>>>>> registration = ImageRegistrationMethod()
>>>>>>
>>>>>> registration$AddCommand(‘sitkIterationEvent’, f(registration))
>>>>>>
>>>>>> This last line causes R to abort/hard crash (no error message). This behaviour is irrespective of which event type I use or the function passed as the second argument (e.g. even something simple like print(‘Hello’))
>>>>>>
>>>>>> The AddCommand method is inherited from the SimpleITK ProcessObject type. Digging around in the SimpleITK.R file I can see that the ProcessObject$AddCommand method expects a second argument of type ‘_p_itk__simple__Command’.
>>>>>>
>>>>>> There is a ‘Command’ method that generates a new object of type ‘_p_itk__simple__Command’. If I pass this resulting object as the second argument to registration$AddCommand then I do not get an error. However, there doesn’t seem to be any way to point the ‘_p_itk__simple__Command’ object to my function or otherwise convert my function to a ‘_p_itk__simple__Command’ type.
>>>>>>
>>>>>> The $AddCommand method is used in a couple of example scripts on the SimpleITK site (using it for monitoring a registration and a filter e.g. https://github.com/SimpleITK/SimpleITK/blob/master/Examples/FilterProgressReporting.R <https://github.com/SimpleITK/SimpleITK/blob/master/Examples/FilterProgressReporting.R>) so I don’t know if it was working previously and a bug has been introduced more recently? (the example scripts cause the same error when I run them now)
>>>>>
>>>>> _____________________________________
>>>>> Powered by www.kitware.com <http://www.kitware.com/>
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html <http://www.kitware.com/opensource/opensource.html>
>>>>>
>>>>> Kitware offers ITK Training Courses, for more information visit:
>>>>> http://www.kitware.com/products/protraining.php <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 <http://www.itk.org/Wiki/ITK_FAQ>
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://public.kitware.com/mailman/listinfo/insight-users <http://public.kitware.com/mailman/listinfo/insight-users>
>>>
>>>
>>
>> _____________________________________
>> Powered by www.kitware.com <http://www.kitware.com/>
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html <http://www.kitware.com/opensource/opensource.html>
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php <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 <http://www.itk.org/Wiki/ITK_FAQ>
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users <http://public.kitware.com/mailman/listinfo/insight-users>
>
>
> _____________________________________
> Powered by www.kitware.com <http://www.kitware.com/>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html <http://www.kitware.com/opensource/opensource.html>
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php <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 <http://www.itk.org/Wiki/ITK_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users <http://public.kitware.com/mailman/listinfo/insight-users>
>
>
>
>
> _____________________________________
> Powered by www.kitware.com <http://www.kitware.com/>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html <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/community/attachments/20160415/d2efeade/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