Surface measures on CHARM

hello AFNI team,
I would like to perform surfaces measures on an atlas co-registrated into the individual space (not the template space).
Basically, I would like to have a value for each region of the atlas representing a surface index. Is it something that is possible in AFNI?
I guess I have to go through SUMA? however, I am not very comfortable if that (yet!)
Any advice? tutorial online? or command line that you could advise to do it?

thank you

The CHARM, SARM, D99 atlases are all distributed with simple surfaces for each atlas region. You can also use a whole brain surface too. You can map functions or ROI values onto a surface with 3dVol2Surf. For any particular surface, you can get measures and metrics for a surface with SurfMeasures and SurfaceMetrics. SurfInfo can give some general information too. Even with surface data, most of the 3D tools can also be used for various tasks here too (3dBrickStat, 3dmasktool, 3dROIstats).

Thank you, Daniel!

I now understand better SUMA!

However, if I am not mistaken, 3dVol2Surf allows converting a volume in surface, if in the same space right?

My problem is that my atlases are in the subject space (to measure the surface of each individual).
Is there a way to apply the WARP (template to the subject) that I generated for each subject to the Charm surface atlas?

From what I understand, @animal_warper is generating surface files for atlases through the function atlas_followers, right?
If it is possible to do it with my WARP files, what would be the correct command line?

Finally, I read the doc of SurfaceMetrics and SurfMeasures I don’t really get what would be the measure of surface: n_area_A? -area? (I am not sure what is the “area of each triangle”)

There is another problem, which is that SurfMeasures is asking for a spec file, that I don’t have since the subjects atlas are not generated with freesrufer (or others).

Using @animal_warper I have obtained a .gii file for the atlas with tcsh file
Since SurfaceMetrics doesn’t seem to require a spec file, tried to measure the surface of a given ROI with the command:

SurfaceMetrics -area -i_gii native.k205.gii

However, I have got a file with 15425 rows, should I average all of them to have the total surface area of the ROI?
Finally, I guess that the next step to have the volume of each region, of a whole atlas is to repeat this command on all .gii of the atlas folder?

Thank you!

I’ll try to answer some of these questions:

3dVol2Surf is to move data from the volume into the surface for data in the same space.

I don’t understand this:
If it is possible to do it with my WARP files, what would be the correct command line?

You can make spec files with quickspec. The spec files are fairly straightforward text files, so you could simply edit them too.

For surface area, you could use the triangle output from SurfaceMetrics. The sum of all the triangle areas is the total surface area. Alternatively, SurfMeasures gives several surface output values on a node-wise basis. The stdout includes the total surface area. The “n_area_A” gives the area associated with each node (total triangle area/3) and the average area of the triangles associated with each node (if 6 triangles are are associated with a node, then the total area of the triangles/6). Summing across the n_area_A column should give you something very similar to the total surface area presented to the stdout in the terminal. See this old discussion for the differences among these options.,44933,44952#msg-44952

So if you do something like :

SurfMeasures -info_area -spec tempqs.spec -surf_A mysurface.gii -out_1D testout.1D
-func n_area_A -func n_avearea_A -func n_ntri

You get output in the terminal that says “total area 0 = nnnn.n”

The text file, testout.1D, looks something like this:

nodes n_area_A n_avearea_A n_ntri

---------- ---------- ---------- ----------

        0    0.291586    0.145793           6
        1    0.203118    0.121871           5
        2    0.251291    0.125645           6
        3    1.023988    0.438852           7

You can sum the n_area_A column with this command where the output should be very close to the total area above:
3dTstat -sum -prefix - testout.1D’[1]''

Also note that the product of the last 2 columns (n_avearea_A*n_ntri) divided by 3 is equal to the n_area_A column.

Because SurfaceMetrics uses triangles and not nodes, they add up more directly. The total area of the triangles should be same as the surface area computed by averaging around nodes.

SurfaceMetrics -area -prefix testSM.1D -i mysurf.gii
mv testSM.1D.area testSM.1D
3dTstat -sum -prefix - testSM.1D’[1]''

thank you, Daniel!

SurfaceMetrics and SurfMeasures did really work well!
What would be the unit of the result then?

For this question:
“If it is possible to do it with my WARP files, what would be the correct command line?”

I was wondering if there is a way to apply a classical afni “WARP” to a surface file like a .gii?

sadly I am not sure that I understand how to use quickspec

Can you please give me an example of a command-line that would transform an atlas (.nii) (the dog one for example) into .gii?

thank you very much!

sorry to come back on my previous question,
thank you again for your time!

Sorry, lost track of the remaining questions. I believe the area is in mm2.

There is no simple tool for applying nonlinear warps to surfaces, but you can convert the surface to .asc or .ply and compute the new coordinates with 3dNwarpXYZ. Then you would have to save the new coordinates with the same triangles. Depending on the warp, it will likely make surfaces that flip inside-out and outside-in at various places, but you can try it. Moving surfaces with just an affine transformation can be accomplished with ConvertSurface.

quickspec takes type, name minimally, but you can add fun options like state, anatomical flag, domain parent and an associated label file if you like. You can also add a spec file name for the output; otherwise, it uses quick.spec for the output name.

simplest example of quickspec

quickspec -tn gii mysurface.gii

IsoSurface is our tool for generating surfaces. You can compute a surface for every region in an atlas with a command like this one:

mkdir surfs
cd surfs
IsoSurface -isorois+dsets -input myatlas.nii.gz -o myatlassurfs.gii -Tsmooth 0.01 1500
suma -onestate -i *.gii