How to split a cortical segment? Please help!

AIMS library and commands usage

Moderators: denghien, riviere

Post Reply
ruslana
Posts: 14
Joined: Thu Mar 31, 2016 9:19 pm

How to split a cortical segment? Please help!

Post by ruslana »

Hello guys,

I have noticed that when cortical fold has a Y pattern, sometimes there are two segments, and sometimes there are three segments (see images) in a cortical graph.

I don't have any neurological background, so please forgive me my ignorance. But I am interested to understand if there is any anatomical difference between the 2 cases, and would highly appreciate any clarification if there is a reason to have two different topologies (2 segments vrs. 3 segments). I would expect to have 3 segments for any Y pattern, so why is it not always the case?

Now, suppose I am interested to consider a 3 segments topology for the branching, and thus would need to split the longer segment (when there are only 2 segments for a pattern) into 2 smaller segments at a branching location - to get a 3 segments pattern. What would be the easiest way to implement this? Essentially, I would like to recalculate the morphometric descriptor (size, depth, orientation, etc.) for two split parts separately (I don't need new meshes, or update graph relationships, if it makes the solution easier). Any suggestions are more than warmly welcome, since I have no idea how to handle this...

Thanks a lot,
Ruslana.
Attachments
3 segments pattern
3 segments pattern
branching_4.jpg (47.53 KiB) Viewed 38969 times
2 segments pattern
2 segments pattern
branching_2.jpg (38.39 KiB) Viewed 38969 times
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to split a cortical segment? Please help!

Post by riviere »

Hi Ruslana,

Folds forming a Y may be split in 2 or 3 parts. It depends if one branch is smaller or shallower than the other, and if the other is aligned with the "base" part with no discontinuity (in depth and curvature). It's geometrical criteria which drive this split ot not split decision. But the limit between the different situations is sometimes not so clear...
It is possible to cut manually, yes. To do so you may use the "fold split control":
* view the sulci graph in a 3D window as you did to do the snapshots you posted here
* select the "fold split" control (scissors icon) in the left toolbar of the window
* then you can click on a fold at a position you want to split: it will try to make a line from the bottom of the fold to the external point. The cut line is drawnd with "voxels" (little cubes). You can cancel the cut line if you're not happy with it (escape key), and/or click somewhere else.
* Alternately you may guide the split line stronger using several control points: set them using ctrl+left click, then the "S" key to draw the line between them
* When the split line is visible, you can actually perform the split by (re) pressing "S".

When done, don't forget to save the folds graph (right click on it in Anatomist main window, in the objects panel, then select "File/Save".

If you don't need meshes and relations, that's enough. But if you need them back, the graph will need a bit of re-processing, which can be done for instance from Brainvisa, using the process "compute cortical folds graph from old", which is visible in expert userLevel, in morphologist/sulci/graph manipulations.

Denis
ruslana
Posts: 14
Joined: Thu Mar 31, 2016 9:19 pm

Re: How to split a cortical segment? Please help!

Post by ruslana »

Denis,

Thank you very much for your detailed instructions. I was able to perform all the steps manually. However, I would now like to automate them in python using AIMS library.
In documentation, I found a class aims::FoldArgOverSegment that seems to have exactly the functionality I am looking for (http://brainvisa.info/aimsalgo-4.5/doxy ... gment.html). Does it have a python wrapper I could use in my python script? Or could it be used as a pre-compiled command line? If the only way to use it is though the C++ code - do you have any online help on how to configure C++ project to use aims library and/or some examples of C++ code using aims classes to manipulate cortical fold graph?

Thanks a lot for your help!
Ruslana.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to split a cortical segment? Please help!

Post by riviere »

Hi Ruslana,

Yes the class FoldArgOverSegment has a python wrapping. Actually the commandline using it is written in python (AimsFoldsGraphOverSegmentation.py). Basically in python you have to do:

Code: Select all

from soma import aims, aimsalgo

sulci_file = "something.arg"
output_sulci_file = "something_else.arg"

graph = aims.read(sulci_file)
fov = aims.FoldArgOverSegment(graph)

# then you can use the different methods of FoldArgOverSegment
# at the end, save the sulci graph
aims.write(graph, output_sulci_file)
To use python and brainvisa libs, you have to source the correct environment variables in the terminal from where you will run the script:

Code: Select all

source <brainvisa_dir>/bin/bv_env.sh
(don't set in in a .bashrc or .bash_profile settings because it will override some system libs and the system python and it may break system programs).

Denis
ruslana
Posts: 14
Joined: Thu Mar 31, 2016 9:19 pm

Re: How to split a cortical segment? Please help!

Post by ruslana »

Denis,
Thanks a lot for your help. It is highly appreciated!
I was trying to call a splitVertex method with one or few points for second argument. It worked fine with only one point, but when I tried to send a list of points, it failed. Here is an error I get:
TypeError: FoldArgOverSegment.splitVertex(): arguments did not match any overloaded call:
overload 1: argument 2 has unexpected type 'list'
overload 2: argument 2 has unexpected type 'list'
overload 3: argument 2 has unexpected type 'list'
overload 4: argument 2 has unexpected type 'list'

In C++ class FoldArgOverSegment there are indeed 4 overloaded methods for splitVertex(), and 2 of them have points list as an argument (namely, const std::list<> with different types of points). So it looks like all these functions were attempted, but for some reason none was successful.
Am I doing something wrong? How could I send a list of points to the splitVertex method?
Thanks a lot,
Ruslana.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: How to split a cortical segment? Please help!

Post by riviere »

Hi,
The automatic conversion between C++ objects and python lists has some limitations (until we improve them, at least), for now the python bindings cannot recognize lists of lists as C++ std::list<Point3d> for instance, so an explicit conversion is needed for points.
If you are using millimetric (float) coordinates:

Code: Select all

converted_coords = [aims.Point3df(*x) for x in coords]
fov.splitVertex(vertex, converted_coords)
If you are using voxel (int) coordinates:

Code: Select all

converted_coords = [aims.Point3d(*x) for x in coords]
fov.splitVertex(vertex, converted_coords)
I guess that should work.
Denis
ruslana
Posts: 14
Joined: Thu Mar 31, 2016 9:19 pm

Re: How to split a cortical segment? Please help!

Post by ruslana »

Denis,
Thanks you very much!
This worked.
Ruslana.
Post Reply