Page 1 Medical Image File Formats
Justin Senseney, DCB/CIT/NIHhttp://mipav.cit.nih.gov
http://dcb.cit.nih.gov/~senseneyj
Page 2 Overview• Part 1 – Basics
– Data– Image
• Part 2 – Medical File Formats– Practical: See underlying data
• Part 3 – General File Formats• Part 4 – All together and everything
else– Practical: Use file formats
2
Page 3 Imaging – Why?• NIH has 27 institutes and centers
– 14 are here• http://
www.idoimaging.com/index.shtml
3
Page 4 Imaging – How?
• Data communication• Standards
4
Page 5 Part 1.A – Data Basics
• Bits vs Bytes
• Endianess
• Sign
• Compression
• Data types5
Page 6 Bits vs Bytes
• Bit – a number system
• Byte – a language
6
Page 7 Bits vs BytesBits 1 1 0 1 0 1 0 1
7
Decimal Binary bits Hexadecimal
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
Byte = 8 bits:D5
CT image with HU = 213at position (4,9)
binary
Page 8 Sign
• 2’s complement– Unsigned 213 = -43 signed, just fat
– Recognize sign bits
• Offset scaling– Discrete to decimal– Common in dicom
8
Bits 1 1 0 1 0 1 0 1
Comp.
0 0 1 0 1 0 1 1
Sub 1 1 1 0 1 0 1 0 0
Page 9 Endianness
• Big Endian – most sig. = lowest address
– In DICOM: Film destination
• Little Endian - least sig. = lowest address
– In DICOM: Image comments 9
Little (0020, 4000)
Big (2000, 0040)
Address
0 1 2 3
Bytes 20 00 00 40
Page 10 Compression
• RLE – run length
• LZW - dictionary
• Huffman – variable length
• DCT - discrete cosine transform– lossy
10
Page 11 Data Types• Boolean – 1 bit
• Byte – 1 byte
• Short – 2 bytes– Dicom
• Int – 4 bytes
• Long – 8 bytes11
Page 12 Data Types (2)
• Decimal – IEEE standard
– Float – 4 bytes
– Double – 8 bytes
12
Page 13 Raw Data Demo• Hex Editor NEO
13
Page 14 Part 1.B – Image Basics
• Resolution• Dimensions/Extents• Color• Orientation• Origin• Transformations• Encoding
14
Page 15 Resolution
• Level of detail
• Width of dimension unit– Computing area, volume
– Time in seconds
15
Page 16 Dimensions/Extents
• 3D– As stacks
• 4D – Multi-file
• Complex– Multi-channel
16
Page 17 Color
• Channels– RGB or HSV
– CMYK
• N-bit color is 2^n possible colors
17
Page 18 Orientation
• Axial/Transverse
• Sagittal
• Coronal
18
Page 19 Origin
• In n-dimensions
• Scanner space vs image space
19
Page 20 Transformations
• Image space to scanner space
• Dicom
• NIfTI
20
Page 21 Encoding
• Encapsulating image – JPEG compression in DICOM, Tiff
• Embedding image– Thumbnail image
21
Page 22 Header• Text based
• Binary
• XML
22
Page 23 Header Demo
23
Bruker BioSpin format
Page 24 Part 2 – Medical File Formats
• XML
• DICOM
• NIfTI
24
Page 25 XML - Basic
• Instance is .xml file
• Schema is .xsd file
25
Page 27 DICOM
• NEMA standard– ftp://medical.nema.org/medical/dicom/2
011/
• Header– Communication– Storage
27
Page 28 Dicom - Tags
• Chapter 6
• Group – 2 bytes• Element – 2 bytes
• Public vs private
28
Page 29 Dicom – Tag values
• Chapter 5
• Value representation (VR)
• Little endian, explicit VR default
29
Page 30 Dicom – Tag construction
30
• VR can be implicit for public tags
From 2011 standard
Page 31 Dicomv.3.0 -
Standard
31
• Chapter 3From 2011 standard
Page 32 Dicom properties
• Dimensions– (0028,0010) and (0028,0011)
• Image– (7FE0, 0010)
• Transfer syntax– (0002, 0010)
32
Page 33 Dicom – Pixel map
• (0028, 1052) is slope• (0028, 1053) is intercept
• Y (true value) = ax+b for x short
33
Page 34 DICOM Mosaic
• Matrix of image slices:
– Concatenate into 3D/4D volume
– Calculate relevant DICOM tags
34
Page 36 NIfTI
• Standard for ANALYZE by NIMH
• See : http://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1.h
36
Page 37 NIfTI - Data
• Allows complex data, 64 bit integer
• Provides patient-space coordinates
37
Page 38 NIfTI - Orientation
• +x = right
• +y = anterior
• +z = superior
• Is default, but in Analyze 7.5, +x = left
38
Page 39 NIfTI – q_form, s_form
• Matrix of offsets
• Codes for orientation
39
Page 41 Part 3 – Image File Formats
• Vector Images
• Graphics/Bitmap Images
41
Page 42 Vector Images
• CAD applications
• Lines/ROI/VOI
42
Page 43 Graphics Images• GIF
• TIFF
• BMP
• PNG
• JPEG43
Page 44 GIF
• LZW
• Small (8 bit) color range
• Little endian
• Sequence of 2D possible
44
Page 45 TIFF
• RLE, JPEG
• Larger color range (to 24 bit)
• Microscopy
• Image File Directory
45
Page 46 BMP
• RLE
• Up to 32-bit
46
Page 47 PNG
• 48 bit color range (outside of vision)
• Best for large, lossless compression
47
Page 48 JPEG
• DCT (lossy), Huffman
• Down-sampling
• Markers
48
Page 49 General Image Demo• ImageJ + batteriesn =Fiji
49
Page 50 Part 4 – All together
• Afni• Bruker BioSpin• GESigna• LSM• Minc• MATLAB• Parrec• Raw
50
Page 51 Afni
• Needed to use AFNI tools for fMRI
• Latest paper: http://dx.doi.org/10.1016/j.neuroimage.2011.08.056
• .BRIK with data, .HEAD header
• Allows PET, CT, SPECT
51
Page 52 Bruker BioSpin
• Unlike Siemens/GE DICOM data
• Text based header
• Raw data
52
Page 53 GESigna
• Predecessor to DICOM
• Fixed image data bit location
53
Page 54 LSM
• Microscopy extension of Tiff
• Pixel resolution
• Uses LZW
54
Page 55 Minc
• Based on NetCDF
• Extends using:– Intensity scaling– Resolution– Position
55
Page 56 Matlab
• *.mat files (not *.m)
• Array data as “raw” image
• No encoding of image information
• http://www.mathworks.com/help/pdf_doc/matlab/matfile_format.pdf
56
Page 57 Parrec
• Raw Philips format
• Easy to convert to DICOM MR
57
Page 58 Raw
• Raw images as described in previous formats
• Byte, Long, Complex, Float, Double
58
Page 60 Conclusion
• http://www.idoimaging.com/index.shtml
60
Page 61 Questions
• SenseneyJ@mail.nih.gov• http://dcb.cit.nih.gov/~senseneyj• http://mipav.cit.nih.gov• http://imagej.nih.gov
61
Page 62 Contact Us
• SenseneyJ@mail.nih.gov
• bug@mipav.cit.nih.gov
62