preadNrrd.m File Reference

Functions

 elseif (foundKeyword('DWMRI_GRADIENT_', cs))[iGNr
 elseif (foundKeyword('DWMRI_B-VALUE', cs)) headerInfo.bvalue
 elseif (foundKeyword('MODALITY', cs)) headerInfo.modality
 elseif (foundKeyword('MEASUREMENT FRAME:', cs)) iMF
 elseif (foundKeyword('SPACE ORIGIN:', cs)) iSO
 elseif (foundKeyword('SPACE UNITS:', cs)) headerInfo.spaceunits
 elseif (foundKeyword('CENTERINGS:', cs)) headerInfo.centerings
 elseif (foundKeyword('KINDS:', cs)) headerInfo.kinds
 elseif (foundKeyword('THICKNESSES:', cs)) sThicknesses
 elseif (foundKeyword('SIZES:', cs)) iSizes
end elseif (foundKeyword('SPACE DIRECTIONS:', cs))%in case of a tensor volume there are 4 dimensions
 elseif (foundKeyword('SPACE:', cs)) headerInfo.space
 elseif (foundKeyword('DIMENSION:', cs)) headerInfo.dimension
 elseif (foundKeyword('DATA FILE:', cs)) headerInfo.datafile
 elseif (foundKeyword('ENCODING:', cs)) headerInfo.encoding
 elseif (foundKeyword('ENDIAN:', cs)) headerInfo.endian
 elseif (foundKeyword('TYPE:', cs)) headerInfo.type
return elseif (foundKeyword( 'CONTENT:', cs)) headerInfo.content
function error (['Original measurement frame needed to transform tensor back into original measurement frame'])
 fprintf ('Type has not been adapted, your data type is not unsupported.\n')
otherwise fprintf ('Unknown type:%s\n', headerInfo.type)
else fprintf ('Warning:File is not RAS, make sure subsequent matlab processing is consistent!\n')
headerInfo gradients (iGNr+1,:)
return end if (strcmp(csU(1:lenKeyword), keyWordU)) fk
 if (len< lenKeyword) fk=0
else if (~iLastWasDelimiter) indxList
 if (numDelimiters >=1) sl
 if (isempty(assgnLoc)) dwiGradient
 if (transformDT &strcmp(headerInfo.kinds(1),'3D-masked-symmetric-matrix')) headerInfo
return end if (strcmp(headerInfo.kinds(1),'3D-masked-symmetric-matrix'))%assume tensor data%assumed default centerings for tenssor data
end if (strcmp(headerInfo.data,'')==1) fprintf('No data.\n')
only implemented for RAS if (iLocation >0) iIsRas
 if (strncmp(cs, 'No volume', 9)) fprintf('%s\n'
 iMF (3) iMF(6) iMF(9)]
 iMF (2) iMF(5) iMF(8)
 iSD (3) iSD(6) iSD(9)]
 iSD (2) iSD(5) iSD(8)
 while (iEnd >1 &strList(iEnd)==delim) iEnd
 while (iStart< len &strList(iStart)==delim) iStart
 while (~strcmp(cs, '')) csU

Variables

find where the assignment is assgnLoc = strfind( st, ':=' )
headerInfo centerings = [{'?^} {'cell'} {'cell'} {'cell'}]
 cs = pgetl(p)
else let s see if we are
dealing with a comment 
csTmp = removeExcessDelimiters( cs, ' ' )
assumed default space units
for tenssor 
data = '?^
 dataSize = prod(headerInfo.sizes)
 delimiterIndices = strfind(strList,' ')
headerInfo dimension = '?^
 dwiGradient = extractGradient( cs(length('DWMRI_GRADIENT_')+1:end ) )
headerInfo encoding = '?^
headerInfo endian = '?^
return function fk
default header
function headerInfo
end iEnd = len
for iI
end iLastWasDelimiter = 0
 iLocation = strfind( csU(length('SPACE:')+1:end ), 'RIGHT-ANTERIOR-SUPERIOR')
end indxList = []
return function iNrs
 iSD = extractNumbersWithout( space_dir_tmp, {'(',')',','} )
 iStart = 1
 iThicknesses = []
 keyWordU = upper( keyWord )
tensor has to have headerInfo kinds
end return function kvs
 len = length( strList )
 lenKeyword = length( keyWord )
 lenThicknesses = length( sThicknesses )
end return helper functions from marc
decided that the none is not
needed in 
matlab
headerInfo measurementframe = [NaN NaN NaN
NaN NaN NaN
 numDelimiters = length(delimiterIndices)
these fields are optional
end Now read the data popenType = nrrd2popenType( headerInfo.type )
 return
headerInfo sizes = '?^
end return function sl
headerInfo space = '?^
end but only of them are in space space_dir_tmp = strrep( cs(length('SPACE DIRECTIONS:')+1:end), 'none', 'NaN' )
headerInfo scalar data is
expected to have values
headerInfo 
spacedirections = [NaN NaN NaN
headerInfo spaceorigin = [NaN NaN NaN]
headerInfo spaceunits = {'mm' 'mm' 'mm'}
headerInfo thicknesses = iThicknesses
function transformDT
headerInfo type = '?^

Function Documentation

elseif ( foundKeyword('DWMRI_GRADIENT_', cs  ) 
elseif ( foundKeyword('DWMRI_B-VALUE', cs  ) 
elseif ( foundKeyword('MODALITY', cs  ) 
elseif ( foundKeyword('MEASUREMENT FRAME:', cs  ) 
elseif ( foundKeyword('SPACE ORIGIN:', cs  ) 
elseif ( foundKeyword('SPACE UNITS:', cs  ) 
elseif ( foundKeyword('CENTERINGS:', cs  ) 
elseif ( foundKeyword('KINDS:', cs  ) 
elseif ( foundKeyword('THICKNESSES:', cs  ) 
elseif ( foundKeyword('SIZES:', cs  ) 
end elseif ( foundKeyword('SPACE DIRECTIONS:', cs  ) 
elseif ( foundKeyword('SPACE:', cs  ) 
elseif ( foundKeyword('DIMENSION:', cs  ) 
elseif ( foundKeyword('DATA FILE:', cs  ) 
elseif ( foundKeyword('ENCODING:', cs  ) 
elseif ( foundKeyword('ENDIAN:', cs  ) 
elseif ( foundKeyword('TYPE:', cs  ) 
return elseif ( foundKeyword( 'CONTENT:', cs  ) 
function error (  ) 
fprintf ( 'Type has not been  adapted,
your data type is not unsupported.\n'   
)
otherwise fprintf ( 'Unknown type:%s\n'  ,
headerInfo.  type 
)
else fprintf ( 'Warning:File is not  RAS,
make sure subsequent matlab processing is consistent!\n'   
)
headerInfo gradients ( iGNr+  1,
 
)
return end if ( strcmp(csU(1:lenKeyword), keyWordU  ) 
if (  )  [pure virtual]
else if ( iLastWasDelimiter  ) 
if ( numDelimiters >=  1  ) 

References numDelimiters.

if ( isempty(assgnLoc  ) 
if ( transformDT strcmpheaderInfo.kinds(1),'3D-masked-symmetric-matrix'  ) 
return end if ( strcmp(headerInfo.kinds(1),'3D-masked-symmetric-matrix')   ) 
end if ( strcmp(headerInfo.data,'')  = =1  ) 
only implemented for RAS if ( iLocation  ,
 
)
if ( strncmp(cs, 'No volume', 9)   ) 
iMF (  ) 
iMF (  ) 
iSD (  ) 
iSD (  ) 
while ( iEnd  ,
1 &  strListiEnd = =delim 
)
while (  ) 
while ( strcmpcs, ''  ) 

Variable Documentation

find where the assignment is assgnLoc = strfind( st, ':=' )
headerInfo centerings = [{'?^} {'cell'} {'cell'} {'cell'}]
if ( csTmp(1)~='#' & ~strcmp(cs(1:4),'NRRD') ) fprintf('Warning end end cs = pgetl(p)

Referenced by SlowFT2().

else let s see if we are dealing with a comment csTmp = removeExcessDelimiters( cs, ' ' )
delimiterIndices = strfind(strList,' ')
else dwiGradient = extractGradient( cs(length('DWMRI_GRADIENT_')+1:end ) )
return else fk
Initial value:
 foundKeyword( keyWord, cs )

csU = upper( cs )
default header
end clear headerInfo
Initial value:
 preadNrrd( p, transformDT, original_measurementframe )

% read a nrrd image from a pipe opened by popenr
% input: p pipe
end iEnd = len
for iI
Initial value:
1:lenThicknesses
      iThicknesses = [iThicknesses, str2num( sThicknesses{iI} ) ]
iLocation = strfind( csU(length('SPACE:')+1:end ), 'RIGHT-ANTERIOR-SUPERIOR')
end indxList = []
end iNrs
Initial value:
 extractNumbersWithout( inputString, withoutTokens )

auxStr = inputString
iSD = extractNumbersWithout( space_dir_tmp, {'(',')',','} )
iStart = 1
keyWordU = upper( keyWord )
Initial value:
 [{'3D-masked-symmetric-matrix'} 
% {'space'} {'space'} {'space'}]
else kvs
Initial value:
 extractKeyValueString( st )

assgnLoc = strfind( st, ':=' )
len = length( strList )
lenKeyword = length( keyWord )
lenThicknesses = length( sThicknesses )
end return helper functions from marc
decided that the none is not needed in matlab
these fields are optional
end Now read the data popenType = nrrd2popenType( headerInfo.type )
parse sizes headerInfo sizes = '?^
end end sl
Initial value:
 extractStringList( strList )

strList = removeExcessDelimiters( strList, ' ' )
decided that the none is not needed in it s nicer to have a matrix space_dir_tmp = strrep( cs(length('SPACE DIRECTIONS:')+1:end), 'none', 'NaN' )
if (length(iSD)~=9 & length(iSD)~=10) fprintf('Warning end headerInfo spacedirections = [NaN NaN NaN
if (length(iSO)~=3) % fprintf('Warning end headerInfo spaceorigin = [NaN NaN NaN]
headerInfo spaceunits = {'mm' 'mm' 'mm'}

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1