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