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
April 15, 2009 01:46PM
I think this little script should do what you want. It takes NIFTI or AFNI format datasets as input.

#!/bin/tcsh
# coordstoijk.csh
# usage: coordstoijk.csh dset xx yy zz
# where dset is the name of the dataset (AFNI or NIFTI format)
# xx yy zz are the xyz coordinates (in RAI)
# output is are the corresponding index coordinates (ijk)

# example:

# coordstoijk.csh anat+orig -123.6 -135.4 -62.7
# ++ Using matrix-vector transformation below:
# [ 0.93750 0.00000 0.00000 ] [ -123.62900 ]
# [ 0.00000 0.93750 0.00000 ] [ -135.43400 ]
# [ 0.00000 0.00000 1.20000 ] [ -62.65850 ]
# ++ Wrote 1 vectors
# 0.000000 0.000000 0.000000

set dset = $1

set xyz = ($2 $3 $4)
# placeholder for output ijk coordinates
set coords = (1 2 3)

cat_matvec ${dset}::IJK_TO_DICOM_REAL > ijkmat.1D
# get the ijk coordinates in floating point
set fcoords = `echo $xyz | vecwarp -matvec ijkmat.1D -backward -output - `
foreach ii ( 1 2 3 )
# round off to integer
set coords[$ii] = `ccalc "int($fcoords[${ii}]+.5)"`
end
echo $coords
Subject Author Posted

How to convert xyz to ijk

Jian Lin April 15, 2009 10:32AM

Re: How to convert xyz to ijk

Daniel Glen April 15, 2009 01:46PM