You could do something like the following short script to create a line in space. At each point, in the line you could also run whereami with an xyz coordinate on the command line to find regions at each of the points. Here, whereami -omask gives a convenient way to get all the regions in one step.
#!/bin/tcsh
# compute a line in a dataset
# usage: makeline3D.csh dset x1 y1 z1 x2 y2 z2
# assumes xyz values are in RAI order
set dset = $1
set x1 = $2
set y1 = $3
set z1 = $4
set x2 = $5
set y2 = $6
set z2 = $7
# compute distance
set origdist = `ccalc "sqrt(($x2-$x1)^2+($y2-$y1)^2+($z2-$z1)^2)"`
# create normalized vector
set normx = `ccalc "($x2-$x1)/$origdist"`
set normy = `ccalc "($y2-$y1)/$origdist"`
set normz = `ccalc "($z2-$z1)/$origdist"`
# create xyz file
echo "# x y z" > xyzline.1D
# do this in a minimum number of steps based on voxel size
set voxsize = `@GetAfniRes -min $dset`
set stepdist = `ccalc "$voxsize/$origdist"`
set nsteps = `ccalc "1/$stepdist"`
# create line by fractional increments of distance
foreach disti (`count 1 $nsteps`)
set dist = `ccalc "$disti * $origdist/$nsteps"`
set newx = `ccalc "$x1+$dist*$normx"`
set newy = `ccalc "$y1+$dist*$normy"`
set newz = `ccalc "$z1+$dist*$normz"`
echo $newx $newy $newz >> xyzline.1D
# could query atlases with whereami here for each xyz coordinate
# but let's do it all at once below
end
# create a new dataset from the xyz values
3dUndump -master $dset -prefix xyzline3D.nii.gz -datum byte -xyz \
-orient RAI -overwrite xyzline.1D
whereami -omask xyzline3D.nii.gz