nifty 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #------------------------------------------------------------------------------
  2. # $File: nifty,v 1.1 2022/02/14 16:51:15 christos Exp $
  3. # file(1) magic for the NIfTI file format
  4. # Type: NIfTI, Neuroimaging file format
  5. # URL: https://nifti.nimh.nih.gov/
  6. # From: Yann Leprince <yann.leprince@cea.fr>, 2022
  7. 344 string n+1\0 NIfTI-1 neuroimaging data,
  8. !:mime image/x.nifti
  9. !:ext nii
  10. >0 use nifti1
  11. 344 string ni1\0 NIfTI-1 neuroimaging data header,
  12. !:mime image/x.nifti
  13. !:ext hdr
  14. >0 use nifti1
  15. 4 string n+2\0\r\n\032\n NIfTI-2 neuroimaging data,
  16. !:mime image/x.nifti
  17. !:ext nii
  18. >0 use nifti2
  19. 4 string ni2\0\r\n\032\n NIfTI-2 neuroimaging data header,
  20. !:mime image/x.nifti
  21. !:ext hdr
  22. >0 use nifti2
  23. # Main subroutine for NIfTI-1
  24. 0 name nifti1
  25. >0 clear x
  26. >0 lelong =348 little endian
  27. >>70 use nifti-datatype-le
  28. >>112 lefloat !0 with scaling
  29. >>0 use nifti1-dim-le
  30. >>252 leshort >0 \b, with qform
  31. >>>252 use xform-code-nifti1-le
  32. >>254 leshort >0 \b, with sform
  33. >>>254 use xform-code-nifti1-le
  34. >>136 string >\0 \b, description: %s
  35. >0 belong =348 big endian
  36. >>70 use \^nifti-datatype-le
  37. >>112 befloat !0 with scaling
  38. >>0 use \^nifti1-dim-le
  39. >>252 beshort >0 \b, with qform
  40. >>>252 use \^xform-code-nifti1-le
  41. >>254 beshort >0 \b, with sform
  42. >>>254 use \^xform-code-nifti1-le
  43. >>136 string >\0 \b, description: %s
  44. >0 default x
  45. >>0 long x invalid sizeof_hdr=%d
  46. # Main subroutine for NIfTI-2
  47. 0 name nifti2
  48. >0 clear x
  49. >0 lelong =540 little endian
  50. >>12 use nifti-datatype-le
  51. >>176 lefloat !0 with scaling
  52. >>0 use nifti2-dim-le
  53. >>344 lelong >0 \b, with qform
  54. >>>344 use xform-code-nifti2-le
  55. >>348 lelong >0 \b, with sform
  56. >>>348 use xform-code-nifti2-le
  57. >>240 string >\0 \b, description: %s
  58. >0 belong =540 big endian
  59. >>12 use \^nifti-datatype-le
  60. >>176 befloat !0 with scaling
  61. >>0 use \^nifti2-dim-le
  62. >>344 lelong >0 \b, with qform
  63. >>>344 use \^xform-code-nifti2-le
  64. >>348 lelong >0 \b, with sform
  65. >>>348 use \^xform-code-nifti2-le
  66. >>240 string >\0 \b, description: %s
  67. >0 default x
  68. >>0 long x invalid sizeof_hdr=%d
  69. # Other subroutines for details of NIfTI files
  70. 0 name nifti-datatype-le
  71. >0 clear x
  72. >0 leshort =1 \b, binary datatype
  73. >0 leshort =2 \b, uint8 datatype
  74. >0 leshort =4 \b, int16 datatype
  75. >0 leshort =8 \b, int32 datatype
  76. >0 leshort =16 \b, float32 datatype
  77. >0 leshort =32 \b, complex64 datatype
  78. >0 leshort =64 \b, float64 datatype
  79. >0 leshort =128 \b, RGB24 datatype
  80. >0 leshort =256 \b, int8 datatype
  81. >0 leshort =512 \b, uint16 datatype
  82. >0 leshort =768 \b, uint32 datatype
  83. >0 leshort =1024 \b, int64 datatype
  84. >0 leshort =1280 \b, uint64 datatype
  85. >0 leshort =1536 \b, float128 datatype
  86. >0 leshort =1792 \b, complex128 datatype
  87. >0 leshort =2048 \b, complex256 datatype
  88. >0 leshort =2304 \b, RGBA32 datatype
  89. >0 default x
  90. >>0 leshort x \b, unknown datatype 0x%x
  91. >>2 leshort x (%d bits/pixel)
  92. 0 name nifti1-dim-le
  93. >0 clear x
  94. >40 leshort <0 \b, INVALID dim[0]=%d
  95. >40 leshort >7 \b, INVALID dim[0]=%d
  96. >0 default x
  97. >>40 leshort x \b, %d-dimensional (size
  98. >>42 leshort x %d
  99. >>40 leshort >1
  100. >>>44 leshort x \bx%d
  101. >>40 leshort >2
  102. >>>46 leshort x \bx%d
  103. >>40 leshort >3
  104. >>>48 leshort x \bx%d
  105. >>40 leshort >4
  106. >>>50 leshort x \bx%d
  107. >>40 leshort >5
  108. >>>52 leshort x \bx%d
  109. >>40 leshort >6
  110. >>>54 leshort x \bx%d
  111. >>80 lefloat x \b, voxel size %f
  112. >>40 leshort >1
  113. >>>84 lefloat x x %f
  114. >>40 leshort >2
  115. >>>88 lefloat x x %f
  116. >>123 use nifti1-xyz-unit
  117. >>40 leshort >3
  118. >>>92 lefloat x x %f
  119. >>>123 use nifti1-t-unit
  120. >>40 leshort x \b)
  121. 0 name nifti2-dim-le
  122. >0 clear x
  123. >16 lequad <0 \b, INVALID dim[0]=%lld
  124. >16 lequad >7 \b, INVALID dim[0]=%lld
  125. >0 default x
  126. >>16 lequad x \b, %lld-dimensional (size
  127. >>24 lequad x %lld
  128. >>16 lequad >1
  129. >>>32 lequad x \bx%lld
  130. >>16 lequad >2
  131. >>>40 lequad x \bx%lld
  132. >>16 lequad >3
  133. >>>48 lequad x \bx%lld
  134. >>16 lequad >4
  135. >>>56 lequad x \bx%lld
  136. >>16 lequad >5
  137. >>>64 lequad x \bx%lld
  138. >>16 lequad >6
  139. >>>72 lequad x \bx%lld,
  140. >>112 ledouble x \b, voxel size %f
  141. >>16 lequad >1
  142. >>>120 ledouble x x %f
  143. >>16 lequad >2
  144. >>>128 ledouble x x %f
  145. >>500 use nifti2-xyz-unit
  146. >>16 lequad >3
  147. >>>136 ledouble x x %f
  148. >>>500 use nifti2-t-unit
  149. >>16 lequad x \b)
  150. 0 name xform-code-nifti1-le
  151. >0 leshort =1 to scanner-based coordinates
  152. >0 leshort =2 to aligned coordinates
  153. >0 leshort =3 to Talairach coordinates
  154. >0 leshort =4 to MNI152 coordinates
  155. >0 leshort =5 to template coordinates
  156. 0 name xform-code-nifti2-le
  157. >0 lelong =1 to scanner-based coordinates
  158. >0 lelong =2 to aligned coordinates
  159. >0 lelong =3 to Talairach coordinates
  160. >0 lelong =4 to MNI152 coordinates
  161. >0 lelong =5 to template coordinates
  162. 0 name nifti1-xyz-unit
  163. >0 byte &0x01
  164. >>0 byte ^0x02 m
  165. >>0 byte &0x02 micron
  166. >0 byte ^0x01
  167. >>0 byte &0x02 mm
  168. 0 name nifti1-t-unit
  169. >0 byte &0x08
  170. >>0 byte ^0x10 s
  171. >>0 byte &0x10 ms
  172. >0 byte ^0x08
  173. >>0 byte &0x10 microsecond
  174. 0 name nifti2-xyz-unit
  175. >0 lelong &0x01
  176. >>0 lelong ^0x02 m
  177. >>0 lelong &0x02 micron
  178. >0 lelong ^0x01
  179. >>0 lelong &0x02 mm
  180. 0 name nifti2-t-unit
  181. >0 lelong &0x08
  182. >>0 lelong ^0x10 s
  183. >>0 lelong &0x10 ms
  184. >0 lelong ^0x08
  185. >>0 lelong &0x10 microsecond