Page 1 of 1

using AimsMorphoDilation in iPython

Posted: Mon Apr 14, 2014 1:53 pm
by lmarrakchi
Hello,

I am trying to use AimsMorphoDilation in a python environment.

Here is a simple example:
from soma import aims, aimsalgo
vol = aims.Volume_S16( 10,10,10 )
vol.setValue( 1, 5,5,5 )
dilated = aimsalgo.AimsMorphoDilation( vol, 1 )

I get this message of error:

volbin.borderWidth()>0, file /neurospin/brainvisa/sources/aims/aims-free/branches/4.3/aimsalgo/src/aimsalgo/distancemap/chamfer.cc, line 103
terminate called after throwing an instance of 'carto::assert_error'
what(): volbin.borderWidth()>0

I went through the code of chamfer.cc and the problem comes from the test ASSERT(volbin.borderWidth()>0);
in AimsChamferDistanceMap function

I wanted to know if I should add a sort of border to my volume?

Re: using AimsMorphoDilation in iPython

Posted: Tue Apr 15, 2014 4:06 pm
by riviere
Hi Linda,

Yes the dilation algorithm needs to work in a volume with a border. To do so you may use a larger volume (holding the border), with a smaller view in it which is your actual volume:

Code: Select all

from soma import aims, aimsalgo
vol_border = aims.Volume_S16( 12,12,12 )
vol = aims.Volume_S16( vol_border, aims.Volume_S16.Position4Di(1,1,1,0),
    aims.Volume_S16.Position4Di(10,10,10,1) )
# vol is a view in vol_border, so it has a larger border
vol.setValue( 1, 5,5,5 )
dilated = aimsalgo.AimsMorphoDilation( vol, 1 )
Denis

Re: using AimsMorphoDilation in iPython

Posted: Tue Apr 15, 2014 4:08 pm
by riviere
And if you read the volume from a file on disk, you may just specify a border parameter:

Code: Select all

vol = aims.read('mri.nii', 1) # 1 is a 1 voxel border
dilated = aimsalgo.AimsMorphoDilation( vol, 1 )
Denis

Re: using AimsMorphoDilation in iPython

Posted: Tue Apr 22, 2014 5:08 pm
by lmarrakchi
Thank you very much for your helpful answer Denis.
I am sorry to disturb you again, I did not understand this line of code:

Code: Select all

vol = aims.Volume_S16( vol_border, aims.Volume_S16.Position4Di(1,1,1,0),
    aims.Volume_S16.Position4Di(10,10,10,1) )
I got this error: type object 'Volume_S16' has no attribute 'Position4Di'

so I tried :

Code: Select all

vol = aims.Volume_S16( vol_border, aims.VolumeView_S16.Position4Di(1,1,1,0), aims.VolumeView_S16.Position4Di(10,10,10,1) )
and I got this error:

Volume_S16(): arguments did not match any overloaded call.
overload 1: argument 1 has unexpected type 'Volume_S16'
overload 2: too many arguments
overload 3: too many arguments

Is it better (and simpler) if I systematically add a border to my volumes when I read them from a file?

Re: using AimsMorphoDilation in iPython

Posted: Tue Apr 22, 2014 8:13 pm
by riviere
Which version of BrainVisa are you using ?
This API is new in the latest version (4.4).
In earlier versions the "volume view" concept was in a separate class:

Code: Select all

from soma import aims
vol_border = aims.Volume_S16(12, 12, 12, 1)
vol = aims.VolumeView_S16(vol_border, aims.VolumeView_S16.Position4Di(1,1,1,0),
    aims.VolumeView_S16.Position4Di(10,10,10,1))
Denis

Re: using AimsMorphoDilation in iPython

Posted: Thu Apr 24, 2014 10:09 am
by lmarrakchi
I am using the 4.3 that is why it did not work. Thank you very much for the information, I will use the 4.4.