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  

|
Daniel Glen
March 11, 2009 02:28PM
Before I give up on this for a while, the map of iteratively eroding may be a useful measure too. Versus interiorosity, erosion levels can be computed faster, especially for very large ROIs. For generally blob shaped objects, it has the pleasing property of being uniformly low on all outer edges and reaching a maximum at a single voxel. For hollow objects or ROIs that have a narrow neck, the maximum can be in multiple voxels, but all these measures have that characteristic. Attached is an image of the erosion levels of an anatomical dataset.

Okay, that's it. Back to real work...

#!/bin/tcsh
# erodemulti.csh
# erode a dataset repeatedly to separate datasets until nothing left
# add up all the erosions at the end to get erosionlevels dataset
# and normalize to get erosionnorm dataset

# usage:
# erodemulti.csh dsetmask+orig

# the output could then be used to select an interior or periphery mask
# with 3dcalc, or the maximum can be used as a center of mass equivalent

set base = `@GetAfniPrefix $1`
set view = `@GetAfniView $1`
set nvox = `3dBrickStat -count -non-zero $1`
rm -f __tt_${base}_erode_??${view}.*
set iter = `printf "%2.2d" 0`
set iterp1 = `printf "%2.2d" 1`

# put copy of original dset in 1st iteration as mask and for easier bookkeeping
3dcalc -a $1 -prefix __tt_${base}_erode_$iter -expr 'step(a)'

# iterate until no more voxels in mask
while ( $nvox != 0 )
# erode facing voxels with 3dcalc
3dcalc -a __tt_${base}_erode_${iter}${view} \
-b a+i -c a-i -d a+j -e a-j -f a+k -g a-k \
-expr 'and(a,b,c,d,e,f,g)' \
-prefix __tt_${base}_erode_${iterp1}${view}

set iter = $iterp1
@ iterp1++
set iterp1 = `printf "%2.2d" $iterp1`

# count the voxels left
set nvox = `3dBrickStat -count -non-zero __tt_${base}_erode_${iter}${view}`
end
rm -rf ${base}_erosionlevels${view}.*
# add all the erosions together for a continuous map of the erosion
3dMean -sum -prefix ${base}_erosionlevels __tt_${base}_erode_??${view}.HEAD
rm -rf ${base}_erosionnorm${view}.*
# compute normalized erosion, to range from 0-1
3dcalc -a ${base}_erosionlevels${view} -expr "a / $iter" -prefix ${base}_erosionnorm

# cleanup all the erosion iterations
rm -f __tt_${base}_erode_??${view}.*
Subject Author Posted

Boundary coordinates

AFNI User March 09, 2009 12:56PM

Re: Boundary coordinates

Bob Cox March 09, 2009 01:26PM

Edges, periphery and interiorosity

Daniel Glen March 09, 2009 05:23PM

Re: Edges, periphery and interiorosity

bob cox March 09, 2009 06:01PM

Re: Edges, periphery and interiorosity

Daniel Glen March 10, 2009 04:27PM

Re: Edges, periphery and interiorosity

Daniel Glen March 11, 2009 02:28PM

Re: Boundary coordinates

AFNI User March 10, 2009 07:59AM