Hi AFNI experts,
I have one question about how to draw ROIs in the volume.
How to draw a line to connect the two ROIs according to the peak coordinates? And then how to find each ROIs along the line?
Thanks a lot in advance.
-Xin
Hi AFNI experts,
I have one question about how to draw ROIs in the volume.
How to draw a line to connect the two ROIs according to the peak coordinates? And then how to find each ROIs along the line?
Thanks a lot in advance.
-Xin
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
set dset = $1
set x1 = $2
set y1 = $3
set z1 = $4
set x2 = $5
set y2 = $6
set z2 = $7
set origdist = ccalc "sqrt(($x2-$x1)^2+($y2-$y1)^2+($z2-$z1)^2)"
set normx = ccalc "($x2-$x1)/$origdist"
set normy = ccalc "($y2-$y1)/$origdist"
set normz = ccalc "($z2-$z1)/$origdist"
echo “# x y z” > xyzline.1D
set voxsize = @GetAfniRes -min $dset
set stepdist = ccalc "$voxsize/$origdist"
set nsteps = ccalc "1/$stepdist"
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
end
3dUndump -master $dset -prefix xyzline3D.nii.gz -datum byte -xyz
-orient RAI -overwrite xyzline.1D
whereami -omask xyzline3D.nii.gz
Hi Daniel,
Thank you so much for your assistance!
I ran makeline3D.csh, then it did work. However, there is only 1 voxel in ROI.
Furthermore, how to draw a sphere ROI according to coordinates and radius (i.e., 40 voxels) ?
Thank you very much again!
-Xin
This little script takes 7 inputs - the name of the input dataset, an initial point in xyz RAI coordinates, and an ending point also in xyz RAI coordinates. You should get a line between the points at the grid of the input dataset. There may be only one voxel in any particular image slice. If you want a sphere down at each voxel instead of single voxel, use the -srad option for a default radius. Alternatively, add a fourth and fifth column to the text file with a value and a radius, meaning put a sphere down of radius and specified value.
x y z val radius
If you reduce the step size (and take more steps), then you will get something like a cylinder with rounded ends.
Hi Daniel,
Because these masks were draw in the volume, it is not sure whether the white matter is included in these masks.
Furthermore, how to remove the white matter from each mask?
Thanks a lot in advance.
-Xin
One option is to combine the spheres with white matter with 3dcalc. You can generate white matter masks with FreeSurfer or even 3dSeg. Mask out the data with something like this:
3dcalc -a masks+orig. -b wm_mask+orig -expr ‘a*not(b)’ -prefix masks_no_wm
The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.
Freedom of Information Act |
HHS Vulnerability Disclosure
National Institute of Mental
Health | National Institutes of Health | U.S.
Department of Health and Human Services |