Introducing VoxLogicA -- a declarative language and interpreter for image analysis using ITK, based on "spatial model checking"

Hi all,

I’m new to the forum, I’m here to introduce a new project, ask a question related to a possible bug in SimpleITK, and beg for some support :slight_smile:

  1. The VoxLogicA project

At the ISTI-CNR in Pisa (Italy) we have been working a lot on spatial logics and spatial model checking in the last 6 years, and at some point we realised that the concept was really apt to be used for medical image analysis. Then we designed and wrote a new tool using SimpleITK (in fsharp). The tool accepts a (usually extremely short) declarative program and computes a concurrent execution plan which, besides “parallelizing a lot” and automatically, never computes things twice (so that it’s really declarative, do things as many times as you prefer, write code the way you understand it, write complex functions in few lines of code, things like this). The tool – still a research prototype, but with ambitions – runs the plan using SimpleITK, which results in really really fast execution.

For instance, a 10-lines-of-text logical specification automatically delineates glioblastoma for radiotherapy on BRATS cases in like 10 seconds, with very good accuracy (paper to be presented at the TACAS 2019 conference in Prague in April, preprint on arxiv: https://arxiv.org/abs/1811.05677).

Here is the tool, with binary releases for linux, osx and windows

  1. QUESTION / BUG

I found that under heavy concurrent load, in roughly 2% of executions, it can happen that images saved by voxlogica are “mixed” from 2 different images that have been computed. Investigating more, I came to the conclusion that allocation and deallocation of images in SimpleITK/dotnet (CSharp if you please) is NOT THREAD SAFE. This is certainly a bug. I compiled the .dll and .so files (see below) myself, they contain the string “SimpleITK_CSharp C# anycpu wrapper 1.2.0.dev36-g8801b, compiled with Mono 4.6.2, using ITK 4.13.0”. Is the bug known already? Was it addressed?

  1. Begging some support for .NET core on multiple platforms

I had to compile the .simpleitk so and .dll files for C#/.net myself on osx, windows and linux. This is my major concern for deployment of VoxLogicA at the moment, since this is a difficult operation that I have to repeat and I don’t have a proper setup (I only have a linux laptop, compiled for other operating systems on colleagues laptops, this is not stable…). Ideally I need a nuget package which is maintained for each operating system and kept up to date by the ITK maintainers. I can certainly contribute by maintaining the linux package if you need that, but I really need the thing to be on nuget, official from the ITK team, and updated for new versions / bugfixes. Do you think this is possible?

  1. if you are interested in VoxLogicA we are open to any type of collaboration!

Thanks for reading so far, and have a good day

Vincenzo

4 Likes

Welcome!

  1. This sounds like an awesome project! Thanks for sharing. Looks like you are making excellent use of SimpleITK here.

  2. SimpleITK in wrapped languages does lend itself very easily to using ITK concurrently in separate threads like traditional ITK programming. Most of the ITK pipeline seems to work very well this way but there are some issues that need to be tracked down.

I suspect that your corruption issues have more to do with the IO than the allocation/deallocation of ITK images from my experience. This could be verified by generating an MD5 check some of the image buffer before writing to disk. When saving the image create a separate file with the check some. This can be used to verify corruption caused by writing.

The core ITK ImageIO from my inspection appears to be concurrent thread safe. However, some if the implementation of ImageIO for a particular file format may not be.

We have a test for concurrent reading:

It does occasionally fail for metaIO/mha files especially on OSX. I would suggest contributing to SimpleITK a similar CSharp test for reading and writing.

While not ideal, a quick solution to you problem is to use a global mutex lock on writing image to ensure only one image is being written at a time.

  1. I am not familiar with NuGet. It looks like an excellent opportunity to distribute CSharp binaries for SimpleITK. Currently, we are working on redoing the continuous build infrastructure and improve automation of the SimpleITK packaging. Understanding the requirement of creating a NuGet package now would be a great way to start helping to C# packaging.

  2. We would love your help with SimpleITK to get it packaged for C# into Nuget.

Thanks!
Brad

3 Likes

Hi,

sorry for reopening an old thread. It took a long time to get here, but as also discussed on other channels, I’m now ready to provide help for csharp packaging, but I don’t have an azure account at the moment. In case it is possible for me to test the scripts on your system I could definitely try first of all to compile simpleitk/csharp on all platforms and then to prepare a nuget package.

The first step is actually not very difficult on linux. One needs to set the flag in CMake to compile the csharp bindings and install mono in the VM. For osx I don’t know if the “new” dotnet can be used, or mono is needed. I did not find instructions on that.

1 Like