Getting maxima value voxel within a spatial mask

HI folks,

I’m trying to figure out how to get a fast dump out (text) of the MNI coordinates and value of the max voxels within a spherical ROI (e.g. 2mm radius, centered on a meta-analytic maxima coordinate.) This is because I want to address individual differences in precise spatial localization of what is essentially a canonical activation. 3dExtrema and 3dMaxima seem candidates, but I’m not seeing anything on a spatial mask. Would the mask just BE the data-set invoked? What would be a good quick script/strategy?

Jim

Hi, Jim-

OK. How about the following?

From how you described your question, I was assuming that you have the list of “x y z” coordinates in a certain orientation defined already (your “meta-analytic maxima coordinate(s)”). I call this file “coor_centers.txt”, below. And you can put in the name of the file whose contents you are probing in this variable (in whatever space):
“set vmast = DSET_OF_INTEREST”

One important assumption is that the spheres are not contiguous/overlapping/touching. Here, only one max would be found for such a “chain” of spheres.


#!/bin/tcsh

set coor_sph  = coor_centers.txt
set vmast     = DSET_OF_INTEREST

# make binary mask of *isolated* spheres centered around ${coor_sph} locations
3dUndump                              \
    -overwrite                        \
    -xyz                              \
    -orient RAI                       \
    -prefix f00_roi_sph.nii.gz        \
    -master "${vmast}"                \
    -datum byte                       \
    -srad 2.1                         \
    ${coor_sph}

# multiple that mask of spheres times the dset of interest-- i.e., punch out sphere regions from that dset of interest
3dcalc                                \
    -overwrite                        \
    -a "${vmast}"                     \
    -b f00_roi_sph.nii.gz             \
    -expr 'step(b)*a'                 \
    -prefix f01_dset_sph.nii.gz

# for each isolated sphere, make a map of single maximum value
3dROIMaker                            \
    -overwrite                        \
    -inset  f01_dset_sph.nii.gz       \
    -prefix f02_dset_sph_max          \
    -only_some_top 1                  \
    -nifti

# dump the max locations+values to a text file
3dmaskdump                            \
    -xyz                              \
    -noijk                            \
    -mask f02_dset_sph_max_GM.nii.gz  \
    "${vmast}"                        \
    > f03_sph_max_loc.txt

How does that look?

–pt

I think 3dExtrema has a -mask_file option.

  • rick

Some more ideas to add here:
https://afni.nimh.nih.gov/afni/community/board/read.php?1,146533,146537#msg-146537

Thanks folks! No shortage of approaches here. -Jim