using AimsMorphoDilation in iPython

AIMS library and commands usage

Moderators: denghien, riviere

Post Reply
lmarrakchi
Posts: 6
Joined: Wed Sep 11, 2013 11:09 am

using AimsMorphoDilation in iPython

Post 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?
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: using AimsMorphoDilation in iPython

Post 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
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: using AimsMorphoDilation in iPython

Post 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
lmarrakchi
Posts: 6
Joined: Wed Sep 11, 2013 11:09 am

Re: using AimsMorphoDilation in iPython

Post 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?
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: using AimsMorphoDilation in iPython

Post 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
lmarrakchi
Posts: 6
Joined: Wed Sep 11, 2013 11:09 am

Re: using AimsMorphoDilation in iPython

Post 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.
Post Reply