AFNI version info (afni -ver
):
Precompiled binary linux_ubuntu_24_64: Oct 1 2024 (Version AFNI_24.3.00 'Elagabalus')
Hi there,
We have some ROIs that we manually drew around some brain activity on the surface with SUMA. We have done some analyses in these ROIs. We now want to do a control analysis, performing the same analyses inside a different ROI - ideally of the same (or at least similar) size, in a different brain region. In this instance our analyses were done in SI and we want a control ROI in a frontal region.
I managed to create ROIs in frontal regions, by clicking on the location I wanted the new ROI to be centred on, getting the closest node value from the terminal output, inputting this node to ROIgrow and playing around with the growth factor to get the right-ish size.
This works ok. But we would like the same number of nodes exactly if possible. My colleagues want to shift our current ROI to be centred on a new location but I can't see any way to do this.
Do you have any suggestions how we could move our ROIs?
Thank you for your help!
Harriet
Hello again,
I would love if anyone had any suggestions at all. I am floundering and my paper is stuck in limbo until I find a solution.
My co-author has suggested a method (below) but I think they must be hallucinated by chatGPT because they don't seem to make sense with my understanding of afni/ suma.
---------------Goal: Shift the ROI on the cortical surface by moving its center to a target node location on the spherical surface while maintaining its shape.-------------
Steps:
- Project ROI onto the spherical surface:
- Use
surf2sphere
to map the ROI on the cortical surface to spherical coordinates (theta, phi).
- Calculate the center of the ROI:
- Find the center of the ROI by averaging the theta and phi values of all the nodes in the ROI.
- Define the target position:
- Identify the target location (node) on the spherical surface where you want to shift the ROI’s center.
- Compute the angular displacement:
- Calculate the difference in angular coordinates (theta and phi) between the ROI’s center and the target node:
delta_theta = target_theta - center_theta
delta_phi = target_phi - center_phi
- Shift the ROI’s nodes:
- Apply the angular displacement to each node in the ROI (add
delta_theta
to each ROI node's theta, and delta_phi
to each ROI node's phi).
- Ensure valid angles:
- Ensure that theta stays between 0 and π, and phi stays between 0 and 2π. If necessary, adjust angles that go beyond these ranges.
- Map the shifted ROI back to the cortical surface:
- Use
sphere2surf
to map the updated spherical coordinates back to the original cortical surface.
AFNI/SUMA Script (untested, but should serve as a decent starting point):
bash
Copy
Edit
#!/bin/bash
# Step 1: Project ROI onto spherical surface using 'surf2sphere'
# Input: ROI on cortical surface
# Output: Spherical coordinates (theta, phi) for ROI
# Example usage: surf2sphere
surf2sphere -input original_ROI_surface -prefix roi_sphere
# Step 2: Calculate the center of the ROI (mean of theta and phi)
# Extract theta, phi values from the output spherical coordinates
roi_theta=$(3dinfo -verb roi_sphere+orig | grep "theta" | awk '{print $2}')
roi_phi=$(3dinfo -verb roi_sphere+orig | grep "phi" | awk '{print $2}')
center_theta=$(echo "$roi_theta" | awk '{sum += $1} END {print sum/NR}')
center_phi=$(echo "$roi_phi" | awk '{sum += $1} END {print sum/NR}')
# Step 3: Define the target node (new center) in spherical coordinates
target_theta=... # Define target theta
target_phi=... # Define target phi
# Step 4: Compute angular displacement
delta_theta=$(echo "$target_theta - $center_theta" | bc)
delta_phi=$(echo "$target_phi - $center_phi" | bc)
# Step 5: Shift the ROI by applying angular displacement to each node in ROI
# Use a script or function to shift all the theta and phi coordinates of the ROI nodes
# Example of shifting theta and phi for each node:
shifted_theta=$(echo "$roi_theta + $delta_theta" | bc)
shifted_phi=$(echo "$roi_phi + $delta_phi" | bc)
# Step 6: Ensure theta is between 0 and pi, and phi is between 0 and 2pi
shifted_theta=$(echo "$shifted_theta" | awk '{if ($1 > 3.14159) print 3.14159; else if ($1 < 0) print 0; else print $1}')
shifted_phi=$(echo "$shifted_phi" | awk '{if ($1 > 6.28319) print $1-6.28319; else if ($1 < 0) print $1+6.28319; else print $1}')
# Step 7: Map the shifted ROI back to the original cortical surface using 'sphere2surf'
sphere2surf -input shifted_ROI_sphere -output shifted_ROI_surface
# Done!
Explanation of the Script:
-
surf2sphere: This command converts your ROI from the folded cortical surface to a spherical surface. The output is in spherical coordinates (theta, phi).
-
Center of the ROI: The center is calculated by averaging the theta and phi values of the ROI nodes. These are extracted from the spherical coordinates.
-
Target Node: The target node is defined in terms of spherical coordinates (theta, phi), where you want to shift the ROI.
-
Angular Displacement: The difference (displacement) between the center of the ROI and the target node is computed and then applied to all nodes in the ROI.
-
Shifting the ROI: The angular displacement is added to each node's theta and phi values to shift the entire ROI.
-
Ensure Valid Angles: Theta is constrained between 0 and π, and phi between 0 and 2π, adjusting any out-of-range values.
-
sphere2surf: Finally, the shifted spherical coordinates are mapped back to the original folded cortical surface.
From what I can tell, with my limited knowledge, there are these issues with the above approach:
- surf2sphere is not an afni/ suma program (I could not find it)
- I can’t see anything anywhere about theta or phi values when I search documentation. The format of the .niml.roi files is below. It is just meta info and node values.
- Regardless, ROIs were initially drawn on an inflated sphere. I think this is indicated in ColPlaneName below.
- Without the theta and phi values it’s not possible to move past step 1.
His response:
-
The surf2sphere step isn't necessary as there should be node correspondence across all surfaces. So, the ROI is "automatically" mapped to all surfaces for an individual - regardless of which one it was drawn on.
-
You can compute spherical coordinates from the Cartesian ones that are available (x, y, z) using a standard formula.
Is there anything in this? I can't find anything.
Any help would be hugely appreciated!!!
H