Home > vbmeg > functions > tool_box > dmri_processor > functions > util > get_mask_coordinate.m

get_mask_coordinate

PURPOSE ^

Get mm coordinates of mask voxels

SYNOPSIS ^

function [mcoord] = get_mask_coordinate(vfile, qfile, Nx, Ny, Nz)

DESCRIPTION ^

 Get mm coordinates of mask voxels
 Input
  vfile: Ascii voxel image file made by 'fsl2ascii'
  qfile: Ascii qform values from 'fslorient -getqform > (filename)'
  Nx, Ny, Nz: Numbers of voxels in MRI
 Output
  mcoord: mm coodinate of all the voxels in the mask image

 2012/06/13 M.Fukushima
 2013/08/03 M.Fukushima

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [mcoord] = get_mask_coordinate(vfile, qfile, Nx, Ny, Nz)
0002 % Get mm coordinates of mask voxels
0003 % Input
0004 %  vfile: Ascii voxel image file made by 'fsl2ascii'
0005 %  qfile: Ascii qform values from 'fslorient -getqform > (filename)'
0006 %  Nx, Ny, Nz: Numbers of voxels in MRI
0007 % Output
0008 %  mcoord: mm coodinate of all the voxels in the mask image
0009 %
0010 % 2012/06/13 M.Fukushima
0011 % 2013/08/03 M.Fukushima
0012 %
0013 % Copyright (C) 2011, ATR All Rights Reserved.
0014 % License : New BSD License(see VBMEG_LICENSE.txt)
0015 
0016 % Load 0/1 ascii image
0017 vimage = load(vfile,'ascii');
0018 [indyz,indx] = find(vimage==1);
0019 indy = mod(indyz,Ny);
0020 indz = (indyz - indy)/Ny + 1;
0021 
0022 % 1-base -> 0-base
0023 indx = indx - 1;
0024 indy = indy - 1;
0025 indz = indz - 1;
0026 % Voxel coordinate
0027 vcoord = [indx indy indz];
0028 
0029 % Load qform matrix
0030 qform = load(qfile,'-ascii');
0031 qform = reshape(qform,[4,4])';
0032 
0033 % mm coordinate
0034 mcoord = (qform(1:3,1:3)*vcoord' + repmat(qform(1:3,4),[1 size(indx,1)]))';

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005