AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
October 22, 2014 02:08PM
There are many ways to get peak voxels including 3dROIstats, 3dExtrema, 3dmaxima, 3dclust, and 3dBrickStat with 3dmaskdump. Here are some examples with atlas regions as masks. Even the clusterize plugin can be made to do this with the help of the InstaCalc plugin. The specific instructions for the other alternatives for finding maxima and minima follow. Each method has it's own idiosyncrasies - no mask option, no positive non-zero minimum, short integer format, odd
default options, inappropriate sorting for this purpose and perhaps more information than you care to know. There is also a Maxima plug-in that is similar to the 3dmaxima command.

% 3dROIstats -nzminmax -mask 'TT_Daemon::amygdala' func_slim+tlrc.'[0]'
File Sub-brick Mean_71 NZMin_71 NZMax_71
func_slim+tlrc.[0] 0 4.193859 0.856051
11.929490

% 3dExtrema -maxima -volume -mask_file 'TT_Daemon::amygdala' -closure
func_slim+tlrc.'[0]' | head -50
++ 3dExtrema: AFNI version=AFNI_2007_05_29_1644 (Jul 17 2007) [32-bit]
++ Authored by: B. Douglas Ward
Reading mask dataset: TT_Daemon::amygdala
Number of voxels above mask threshold = 2296
Reading input dataset: func_slim+tlrc.[0]
Reading input dataset: func_slim+tlrc.[0]
Reading volume #0
Number of volumes = 1

Maxima for Volume #0 (Coordinates Order = RAI):
Index Intensity RL[mm] AP[mm] IS[mm] Count Dist[mm]
----- --------- ------ ------ ------ ----- --------
1 11.929 -28.00 7.00 -17.00 1 5.196
2 11.087 23.00 7.00 -17.00 1 6.083
3 10.273 18.00 4.00 -13.00 1 4.690
4 10.162 -18.00 3.00 -14.00 1 9.849
5 7.898 21.00 2.00 -10.00 1 4.690
6 7.704 23.00 0.00 -17.00 1 6.164
7 6.793 29.00 7.00 -16.00 1 6.083
8 5.854 23.00 8.00 -7.00 1 3.606
9 4.915 21.00 11.00 -10.00 1 3.000
10 4.115 21.00 11.00 -7.00 1 3.000
11 3.894 28.00 7.00 -10.00 1 5.916
12 3.438 -24.00 8.00 -8.00 1 3.317
13 3.134 26.00 2.00 -22.00 1 6.164
14 2.223 -23.00 11.00 -10.00 1 3.000
15 1.809 -28.00 4.00 -22.00 1 2.236
16 1.726 -27.00 6.00 -22.00 1 2.236
17 1.712 -23.00 11.00 -7.00 1 3.000

% 3dExtrema -minima -volume -mask_file 'TT_Daemon::amygdala' -closure
func_slim+tlrc.'[0]' | head -50

++ 3dExtrema: AFNI version=AFNI_2007_05_29_1644 (Jul 17 2007) [32-bit]
++ Authored by: B. Douglas Ward
Reading mask dataset: TT_Daemon::amygdala
Number of voxels above mask threshold = 2296
Reading input dataset: func_slim+tlrc.[0]
Reading input dataset: func_slim+tlrc.[0]
Reading volume #0
Number of volumes = 1

Minima for Volume #0 (Coordinates Order = RAI):
Index Intensity RL[mm] AP[mm] IS[mm] Count Dist[mm]
----- --------- ------ ------ ------ ----- --------
1 0.856 -24.00 10.00 -8.00 1 5.099
2 0.953 -23.00 7.00 -12.00 1 5.099
3 1.118 22.00 10.00 -8.00 1 5.477
4 1.215 -24.00 2.00 -10.00 1 5.000
5 1.270 27.00 7.00 -12.00 1 4.472
6 1.312 18.00 4.00 -22.00 1 9.487
7 1.767 -18.00 7.00 -18.00 1 7.810
8 2.416 17.00 9.00 -10.00 1 5.477
9 2.430 27.00 3.00 -10.00 1 4.472
10 2.458 -24.00 -1.00 -14.00 1 5.000
11 2.817 30.00 3.00 -14.00 1 4.000
12 2.872 28.00 4.00 -18.00 1 2.236
13 2.927 30.00 3.00 -18.00 1 2.236
14 4.115 -30.00 1.00 -14.00 1 4.000
15 4.667 -30.00 1.00 -18.00 1 4.000
16 5.012 25.00 9.00 -18.00 1 5.831

% 3dcalc -a func_float+tlrc. -b 'TT_Daemon::amygdala' -expr 'a * step
(b)' -prefix 'func_mask_amyg' -datum short
% 3dmaxima -min_dist 512 -input func_mask_amyg+tlrc
---------------------------------------------
RAI mm coordinates:

( -28.00 7.00 -17.00) : val = 11.929488

number of extrema = 1
---------------------------------------------

% 3dclust -dxyz=1 1 1 func_mask_amyg+tlrc. | head -20
++ 3dclust: AFNI version=AFNI_2007_05_29_1644 (Jul 17 2007) [32-bit]
++ Authored by: RW Cox et al
#
#Cluster report for file func_mask_amyg+tlrc.
#[Connectivity radius = 1.00 mm Volume threshold = 1.00 ]
#[Single voxel volume = 1.0 (microliters) ]
#[Voxel datum type = short ]
#[Voxel dimensions = 1.000 mm X 1.000 mm X 1.000 mm ]
#[Coordinates Order = RAI ]
#[Fake voxel dimen = 1.000 mm X 1.000 mm X 1.000 mm ]
#Mean and SEM based on Absolute Value of voxel intensities:
#
#Volume CM RL CM AP CM IS minRL maxRL minAP maxAP minIS maxIS Mean SEM Max Int MI RL MI AP MI IS
#------ ----- ----- ----- ----- ----- ----- ----- ----- ----- ------- ------- ------- ----- ----- -----
1149 22.7 4.8 -14.9 16.0 30.0 -1.0 11.0 -22.0
-7.0 4.2531 0.0465 11.087 23.0 7.0 -17.0
1147 -24.2 4.8 -15.0 -30.0 -17.0 -1.0 11.0 -22.0
-7.0 4.1345 0.0635 11.929 -28.0 7.0 -17.0
#------ ----- ----- ----- ----- ----- ----- ----- ----- ----- ------- ------- ------- ----- ----- -----
# 2296 -0.4 4.8
-14.9 4.1939 0.0393


This short script may also do what you want.

#/bin/tcsh
# find maximum within atlas mask on a dataset and show position

set dset = func_float+tlrc'[0]'
set tal_region = 'TT_Daemon::amygdala'

set maskmax = `3dBrickStat -mask ${tal_region} -min -max -non-zero -slow "${dset}"`
echo dataset "${dset}", region, ${tal_region}, min, $maskmax[1], max $maskmax[2]
# print coordinates and value for maximum in region
3dmaskdump -mask $tal_region -cmask "-a $dset -expr step(a+0.001-${maskmax[2]})" \
-xyz -noijk "$dset"
# print coordinates and value for minimum in region
3dmaskdump -mask $tal_region -cmask "-a $dset -expr step(${maskmax[1]} +0.001-a)" \
-xyz -noijk "$dset"



Edited 1 time(s). Last edit at 05/21/2020 03:24PM by Daniel Glen.
Subject Author Posted

Peak voxel in a ROI

Victoria October 22, 2014 10:09AM

Re: Peak voxel in a ROI

Daniel Glen October 22, 2014 02:08PM

Re: Peak voxel in a ROI

Veda April 13, 2016 11:10AM

Re: Peak voxel in a ROI

Daniel Glen April 14, 2016 10:58AM