Quantifying the Perimeter of an ROI/ Making Linear Measurements

Questions about Anatomist manipulation

Moderators: riviere, denghien

bryanwong88
Posts: 2
Joined: Mon Oct 23, 2017 7:24 pm

Quantifying the Perimeter of an ROI/ Making Linear Measurements

Postby bryanwong88 » Fri Dec 01, 2017 10:12 pm

Hello,

This is my first post here.

I was wondering if there is a way to quantify the linear edges making up the perimeter of a ROI on a cortical mesh. Using information from previous posts, I was able to figure out how to use a python script to quantify surface area of a texture file. However, I will admit that I am novice to coding and Anatomist. Any help/direction would be greatly appreciated.

If it helps in describing what I am trying to do, I am examining specific neural structures related to auditory processing. My goal is to stratify different morphological variations into shapes based on linear measurements and surface area.

Thank you!

User avatar
riviere
Site Admin
Posts: 1358
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Quantifying the Perimeter of an ROI/ Making Linear Measurements

Postby riviere » Sun Dec 03, 2017 1:32 pm

Hi,
You mean the perimeter of a ROI drawn in a texture on the cortical surface ? You can do it in a few lines of python code:

Code: Select all

from soma import aims

#read the mesh and the ROI texture
mesh = aims.read('cortical_mesh.gii')
tex = aims.read('roi_texture.gii')

# get the border of a ROI, let's say ROI number 10
roi_id = 10
border = aims.SurfaceManip.meshTextureBoundary(mesh, tex, roi_id)
# sum the length of the polygon lines
length = sum([(border.vertex()[v2] - border.vertex()[v1]).norm()
              for v1, v2 in border.polygon()])

Denis

bryanwong88
Posts: 2
Joined: Mon Oct 23, 2017 7:24 pm

Re: Quantifying the Perimeter of an ROI/ Making Linear Measurements

Postby bryanwong88 » Thu Feb 01, 2018 8:16 am

Thank you so much for your prompt response!
I was able to implement the code to get the perimeter. However, we were aiming to discern the individual measurements of each side length that make up the perimeter. I see that you are summing the vertex 1 and vertex 2, but how are you able to discern exactly what coordinate/vertex is which? As in a square has 4 sides, but how do we find the measurement for side 1,2,3,4 separately. We want to compare the side lengths between different ROIs (drawn on a texture on the cortical surface). Could we do this with a script or would it be easier to use Talairach coordinates to define this?

Also in your last example, I see that you set the ROI ID to 10, I don't think I quite understand what this is referencing. Does each brain have it's own ID? In our code our ROI ID is always 100 and since I inherited it and made changes to it to work for perimeter, I don't quite understand why it stays a fixed number for each brain or what it is used for.

Thanks for your help!
- Bryan

User avatar
riviere
Site Admin
Posts: 1358
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Quantifying the Perimeter of an ROI/ Making Linear Measurements

Postby riviere » Thu Feb 01, 2018 12:04 pm

Hi,
Let's answer the last question first:
Also in your last example, I see that you set the ROI ID to 10, I don't think I quite understand what this is referencing. Does each brain have it's own ID? In our code our ROI ID is always 100 and since I inherited it and made changes to it to work for perimeter, I don't quite understand why it stays a fixed number for each brain or what it is used for.

The ROI ID 10 in my example code was, well, just an example. You want to get the perimeter of a region drawn on a mesh: this region is drawn as a texture, using a given value to identify it: visually in Anatomist, this value is seen as a given color. All mesh vertices in the region get this same value. So it depends on you, on the value you chose to use to draw the region. If you used 100, well it's OK. I guess you used the same value for each brain in your dataset, so it's probably always 100... but I can't tell more, it's your choice, in the way you have drawn regions...

Now for the "side lengths", I'm not sure to understand what you mean by "side". A square has 4 sides, yes, but a region drawn by hand on a cortical mesh is probably made up of many line elements: the mesh is made of maybe about 50000 triangles, your regions probably involve several hundreds of polygons, and the intersection of each polygon with the region makes one line element, so there are probably hundreds of them too, with a variable number from one subject to another, and with no correspondence between them.
If you need to compare the length of different parts of a region border (for instance sides on a more or less square region drawn on the cortical mesh), then you will probably need to draw them with different values, to make them different regions, and measure each of them.
Back to the code, I am not summing "vertex 1 and vertex 2", I just measure the distance between both ends of a line element (it's a difference between v1 and v2, thus), and sum these distances over all line elements making the ROI border. But we cannot compare individually these line elements between subjects, they do not correspond directly (and there are probably hundreds of them).
Did I understand your question ? Is my answer clear ?

Denis


Return to “Anatomist”

Who is online

Users browsing this forum: No registered users and 4 guests