1
Image Registration by using
SimpleITK
Macy Kung
2019/06/06
2
Outline
- Foreword
- DICOM Image Information
- Pixel Data
- Bits Allocated
- Bits Stored
- High Bit
- pixel Representation
- Image position (patient)
- Image orientation (patient)
- Pixel Spacing
- Spacing Between Slices
- Slice Thickness
- Image Registration
- SimpleITK Image Registration Framework
3
Foreword
- Doctors using medical image annotation tools need to mark the same
series of images at the same time.
- Tools support image registration to help
doctors mark symptoms.
- Interpret various medical images to
help doctors find lesions in the clinic.
CT MRI Fused image
CTPET Fused image
MRI SPECT Fused image
4
DICOM - Pixel Data (7FE0,0010)
- Pixel data The pixel order of each image plane is encoded from
left to right, top to bottom
5
DICOM - Bits Allocated (0028,0100)
- Number of bits allocated for each pixel sample. Each sample shall
have the same number of bits allocated.
- Bits Allocated (0028,0100) shall either be 1, or a multiple of 8.
- 8bit (2 bytes) 2^8
- 16bit 2^16
6
DICOM - Bits Stored (0028,0101)
- Number of bits stored for each pixel sample. Each sample shall
have the same number of bits stored.
- Bits Stored (0028,0101) defines the total number of these
allocated bits that will be used to represent a Pixel Sample
Value.
- Bits Stored (0028,0101) shall never be larger than Bits Allocated
(0028,0100).
7
DICOM - High Bit (0028,0102)
- High Bit (0028,0102) specifies where the high order bit of the
Bits Stored (0028,0101) is to be placed with respect to the Bits
Allocated (0028,0100) specification.
- High Bit (0028,0102) shall be one less than Bits Stored
(0028,0101).
8
DICOM - Pixel Representation (0028,0103)
- Pixel sample 是 0001H(2’s complement) or 0000H(unsigned integer)
- 2’s complement
- if High Bit is 11, the range of High Bit for Bits Stored is -
2048(2^11)~2047(2^11-1)
- unsigned integer
- 0~(2^11 - 1)
9
DICOM - Image Position (Patient) (0020,0032)
- Describe the coordinates of the first pixel of the image ("top
left")
- The first pixel of each slice ("upper left") (x, y, z) triple
10
DICOM - Image Orientation (Patient) (0020,0037)
- Specifies the direction cosine of the first row and the first
column relative to the patient. The first three x, y, and z axis
values are rows, and the last three x, y, and z axis values are
columns, which exist in pairs.
- (1,0,0,0,1,0)
X+
X-
Z+
Z-
Y+
Y-
11
- Transverse plane(1,0,0,0,1,0)
- Coronal plane(1,0,0,0,0,-1)
- Sagittal plane(0,1,0,0,0,-1)
Coronal Cut
Saggital Cut Transverse(Axial) Cut
12
DICOM - Pixel Spacing (0028,0030)
- The distance between the center points of the pixels, in mm
- All attributes related to pixel spacing should have positive non-
zero values unless there are pixels with only a single row or
column or data, in which case the corresponding value can be zero
Pixel Spacing = Row Spacing  Column Spacing = 0.300.25
13
DICOM - Spacing Between Slices (0018,0088)
- Distance between slices
MRI sequence with 5.5 mm spacing between slices.
14
DICOM - Slice Thickness (0018,0050)
- The thickness of the slice in mm
Slice thickness
eq. 6mm
15
Image Registration
- The process of aligning a target image to a source image
- More generally, determining the transform that maps points in the
target image to points in the source image
16
SimpleITK Registration Framework
- 2 input images, fixed and moving
- Transform - map the coordinate (x, y) of an image to a new
coordinate (x′,y′).
- Metric - determines the “fitness” of the current registration
iteration
- Optimizer - adjust the transform in an attempt to improve the
metric
- Interpolator - applies transform to image and computes sub-pixel
values
17
Transform Type
- Rigid (rotate, translate)
- Affine (rigid + scale & shear)
- Deformable =
non-rigid (affine + vector field)
- Many others
18
SimpleITK - How to process image registration
- load DICOM, 2 series
- specific fixed image and moving image
- stored to mha data
- special medicine image format used in ITK
- initial transform
- optimizer
Group the series
with the same Image
Orientation Patient
under study
Aligning one series
or more series
(moving) to another
series (fixed)
19
Thanks to all the pictures of scholars from the google network like
papers, bloggers, DICOM NEMA
Sorry, no source is attached.
Don't learn from me :P

Image registration by using SimpleITK

  • 1.
    1 Image Registration byusing SimpleITK Macy Kung 2019/06/06
  • 2.
    2 Outline - Foreword - DICOMImage Information - Pixel Data - Bits Allocated - Bits Stored - High Bit - pixel Representation - Image position (patient) - Image orientation (patient) - Pixel Spacing - Spacing Between Slices - Slice Thickness - Image Registration - SimpleITK Image Registration Framework
  • 3.
    3 Foreword - Doctors usingmedical image annotation tools need to mark the same series of images at the same time. - Tools support image registration to help doctors mark symptoms. - Interpret various medical images to help doctors find lesions in the clinic. CT MRI Fused image CTPET Fused image MRI SPECT Fused image
  • 4.
    4 DICOM - PixelData (7FE0,0010) - Pixel data The pixel order of each image plane is encoded from left to right, top to bottom
  • 5.
    5 DICOM - BitsAllocated (0028,0100) - Number of bits allocated for each pixel sample. Each sample shall have the same number of bits allocated. - Bits Allocated (0028,0100) shall either be 1, or a multiple of 8. - 8bit (2 bytes) 2^8 - 16bit 2^16
  • 6.
    6 DICOM - BitsStored (0028,0101) - Number of bits stored for each pixel sample. Each sample shall have the same number of bits stored. - Bits Stored (0028,0101) defines the total number of these allocated bits that will be used to represent a Pixel Sample Value. - Bits Stored (0028,0101) shall never be larger than Bits Allocated (0028,0100).
  • 7.
    7 DICOM - HighBit (0028,0102) - High Bit (0028,0102) specifies where the high order bit of the Bits Stored (0028,0101) is to be placed with respect to the Bits Allocated (0028,0100) specification. - High Bit (0028,0102) shall be one less than Bits Stored (0028,0101).
  • 8.
    8 DICOM - PixelRepresentation (0028,0103) - Pixel sample 是 0001H(2’s complement) or 0000H(unsigned integer) - 2’s complement - if High Bit is 11, the range of High Bit for Bits Stored is - 2048(2^11)~2047(2^11-1) - unsigned integer - 0~(2^11 - 1)
  • 9.
    9 DICOM - ImagePosition (Patient) (0020,0032) - Describe the coordinates of the first pixel of the image ("top left") - The first pixel of each slice ("upper left") (x, y, z) triple
  • 10.
    10 DICOM - ImageOrientation (Patient) (0020,0037) - Specifies the direction cosine of the first row and the first column relative to the patient. The first three x, y, and z axis values are rows, and the last three x, y, and z axis values are columns, which exist in pairs. - (1,0,0,0,1,0) X+ X- Z+ Z- Y+ Y-
  • 11.
    11 - Transverse plane(1,0,0,0,1,0) -Coronal plane(1,0,0,0,0,-1) - Sagittal plane(0,1,0,0,0,-1) Coronal Cut Saggital Cut Transverse(Axial) Cut
  • 12.
    12 DICOM - PixelSpacing (0028,0030) - The distance between the center points of the pixels, in mm - All attributes related to pixel spacing should have positive non- zero values unless there are pixels with only a single row or column or data, in which case the corresponding value can be zero Pixel Spacing = Row Spacing Column Spacing = 0.300.25
  • 13.
    13 DICOM - SpacingBetween Slices (0018,0088) - Distance between slices MRI sequence with 5.5 mm spacing between slices.
  • 14.
    14 DICOM - SliceThickness (0018,0050) - The thickness of the slice in mm Slice thickness eq. 6mm
  • 15.
    15 Image Registration - Theprocess of aligning a target image to a source image - More generally, determining the transform that maps points in the target image to points in the source image
  • 16.
    16 SimpleITK Registration Framework -2 input images, fixed and moving - Transform - map the coordinate (x, y) of an image to a new coordinate (x′,y′). - Metric - determines the “fitness” of the current registration iteration - Optimizer - adjust the transform in an attempt to improve the metric - Interpolator - applies transform to image and computes sub-pixel values
  • 17.
    17 Transform Type - Rigid(rotate, translate) - Affine (rigid + scale & shear) - Deformable = non-rigid (affine + vector field) - Many others
  • 18.
    18 SimpleITK - Howto process image registration - load DICOM, 2 series - specific fixed image and moving image - stored to mha data - special medicine image format used in ITK - initial transform - optimizer Group the series with the same Image Orientation Patient under study Aligning one series or more series (moving) to another series (fixed)
  • 19.
    19 Thanks to allthe pictures of scholars from the google network like papers, bloggers, DICOM NEMA Sorry, no source is attached. Don't learn from me :P

Editor's Notes

  • #4 在講image registration之前 我們要知道為什麼要做image registration 像是我們產品aim aip想要同時在不同series做標註,除此之外,在醫學臨床上,醫生會需要判斷多種造影影像來幫助找到病灶,以這圖例來看,在同一個study底下 不同series 不同造影機器... 那這是image registration後的結果 如果都是MRI在同切面,通常位置差不多,可能差那零點幾,但是不同造影機器出來的成像,同一切面的成像位置,影像大小都不一樣,若要在aip aim上同時標註不同series, 首先要解決的就是兩個影像alignment的問題,也就是兩個影像在同一個空間位置上的對準 https://www.e-sciencecentral.org/articles/pubreader/SC000024130#!po=7.14286 PET 「正電子放射斷層攝影(Positron Emission Tomography)」「正子造影」是一種分子影像檢查,利用「迴旋加速器」產生能射出正電子之放射核種,然後將之與細胞代謝需要的物質(如葡萄糖)結合,做成藥劑注入受檢者體內,最後利用正電子放射斷層攝影儀,將身體放出的訊號偵測記錄下來,由電腦處理,便可做成身體各切面的影像,而顯示出細胞的代謝情形,正子放射藥劑是氟化去氧葡萄糖(FDG),其化學性質與葡萄糖非常相近。因此氟化去氧葡萄糖正子造影(FDG-PET)可顯示細胞的葡萄糖代謝情形。氟化去氧葡萄糖(FDG)藥劑的半衰期很短 (109分鐘),不會殘留在體內,也不會造成人體的傷害。多數惡性腫瘤細胞其葡萄糖代謝較正常細胞旺盛,所以會較正常細胞吸收更多的氟化去氧葡萄糖,因而在正子造影上呈現高度攝取現象 。正子造影的優點為高解析度、高準確度,可全身斷層掃描。其缺點為某些相關解剖位置不容易精確定位,而最近發展出的PET/CT Scanner,結合了PET scan的分子影像及CT scan的解剖影像,有效的克服了單獨PET Scan定位不易的缺點。 http://www.csh.org.tw/into/nuclear/intro.html 單光子射出電腦斷層掃描 - SPECT 觀察腦血流量, 通常沒有症狀的病人在做MRI的時候不易看出, 但是SPECT診斷率卻比MRI高,合併影像看的話, 可以增加空間感 還有一點好處是區別正常或殘餘腫瘤組織準確 包括平面X-光照影、CT (X-光電腦斷層) 及 MRI (磁振造影) 影像,解析度相當高,可查覺細微的解剖細節的變化,而偵測到微小的病灶,但也常常因為缺乏功能或代謝的資訊,無法判別病灶的性質 床上有許多病況,往往解剖組織外觀尚未發生變化,但該部位的血流、細胞活性及新陳代謝已經有變化了,此時核醫功能及代謝影像可更早偵測到病灶的的存在。核子醫學的功能及代謝影像檢查,就是利用各種核醫藥物來評估病灶的功能及代謝,以達到更正確的診斷,目前已成為疾病診斷的一項利器。單光子射出電腦斷層掃描 (SPECT) 與 正子射出電腦斷層掃描 (PET) 就是核子醫學的功能及代謝的斷層掃描造影。 無論SPECT 或PET的影像都較缺乏相關解剖位置對照,看到病灶卻常常無法精確的指出病灶位置。臨床上,我們常將核醫影像和解剖影像互相比較對照 http://w3.tpsh.tp.edu.tw/organization/osa/osa05oldnew/health/615.htm 要對多個不同的image進行分析,首先要解決的就是兩個影像alignment的問題,也就是兩個影像在同一個空間位置上的對準,後續才可以做image fusion,或是image
  • #5 7fe0,0010 針對每個圖像平面編碼的像素的順序是從左到右,從上到下 左上像素(標記為1,1)首先編碼,然後是行1的剩餘部分,接著是第2行的第一個像素(標記為2,1)然後是第2行的其餘部分,依此類推。
  • #6 DICOM Image 像素單元的大小應由Bit Allocated(0028,0100)指定, 他的value為1或8的倍數, 每個像素單元應包含單個像素採樣值。 一個像素取樣點存儲時分配到的位數,一般RGB的圖像,每一個顏色通道都使用8位,所以一般取值爲8。對於灰度圖像,如果是256級灰階,一般就是8位。如果高於256級灰階,一般就採用16位。
  • #7 BitsStored一個像素取樣點存儲時使用到的位數, 所以BitsStored不可以比BitsAllocated大
  • #8 高位(0028,0102)應比存儲的位數(0028,0101)小1
  • #9 有效存儲位(BitsStored)中的最高位為符號位,此時數據表示範圍為-2048(即2 ^ 11)~2043(即2 ^ 11-1);
  • #10 每個切片中第一個像素的PatientPositions(x,y,z)三元組
  • #11 指定第一行和第一列相對於患者的direction cosine。這些value是成對存在。 x,y和z軸的行值分別後跟x,y和z軸的Column值。 在DICOM 中座標軸指向完全以病人為準,以病人中心為原點,病人左手指向的方向為X軸正向,病人背後的方向為ý軸的正向,往病人頭部的方向為ž軸的正向.DICOM3.0標準中第三章附錄C.7.6.1.1.1,定義病人方位,圖像解剖的方向由首字母指定:A(前面),P(後面),R(右邊),L(左邊),H(首部),F(底部)。每個值的方向屬性都被指定,然後它們由一個或兩個附加的字母指明。在每個值中,字母用指定於第一個字符中的首方向排序。 https://itk.org/Wiki/Proposals:Orientation (0020,0037)的前三個數字代表分別代表行向量(行遞增方向)和X,Y,X軸夾角分別的餘弦值(Cosine),後三個數字分別代表列向量(列遞增方向)和X,Y,Z軸夾角分別的餘弦值。 Image Orientation 在配合Image Position這樣就能精確計算出出該張影像中每一個像素點在座標系中的位置,對於多排螺旋CT產生的影像序列來說,這個意義尤其重大。
  • #13 Pixel Spacing = Row Spacing \ Column Spacing = 0.30\0.25.
  • #14 但是,在處理從醫院獲取的CT數據時,卻發現這組數據的Spacing Between Slices的Tag是沒有值的。而且,通過閱讀相關的Dicom文檔,也說明用Spacing Between Slices不是最好的解決方案,因為在CT中很多都沒有這個值。 在CT數據中,通過讀取相鄰兩幅Dicom切片的Image Position(Patient), 然後將這兩個Image Position進行相減,得到的結果中非零的那個值便是這個體數據在z方向的像素間距。
  • #15 會出現在MRI
  • #16 講完重要幾個Dicom image tag....那什麼是registration 他是一個將target image 也就是要被transform的image 和source image對齊的過程 將target image的point transform 之後 可以mapping到source image Transform 過後直線上各點之間的距離比例維持不變 https://people.cas.sc.edu/rorden/mricro/mritut.html 常見醫療影像處理步驟 https://www.itread01.com/content/1544094552.html
  • #17 1、變換 配準的最終目標是獲得從一個圖像的坐標繫到另一個圖像坐標系的映射關係。在ITK中變換對象壓縮映射點和從輸入空間到輸出空間的向量。如果變換是可逆的,那麼同時也提供了反變換方法。通常,會根據具體的配准問題用ITK來實現各種不同的算法。其中常用的是剛性變換、仿射變換、相似變換等。 2. Metric 準度,相似性測度,是基於均方差,互信息等準則來量化變換後圖像之間的相似性。經過坐標變換後,兩幅圖像中相關點的幾何關係已經一一對應,進一步的工作需要找到一種相似性測度來衡量兩幅圖像的相似程度,並且通過優化器不斷地改變變換參數,優化後的參數將返回疊代再進行配准,使得相似性測度達到最優,即最終轉化為多參數多峰值離散最優化問題。它的輸入包括:參考圖像和待配准圖像,變換函數和interpolator(插值器)。在ITK中,相似性測度從數量上通過比較圖像亮度的灰度值來估計變換後的待配准圖像與參考圖像的匹配質量。相似性測度是配准框架中最關鍵的部分。採用何種相似性測度,很大程度上依靠需要去解決的配准問題,沒有一個明確的標準。例如,有些相似性測度有較大的捕捉範圍而另外的需要接近於最優化位置的初始值。另外,一些相似性測度僅僅適合比較從相同模式下成像的醫學圖像而另外一些則可以比較多模態醫學圖像。目前經常採用的相似性測度有均方根距離、倒數均方差分、歸一化互相關、互信息等。 3、優化器 優化器被用來找到變換參數去最優化相似性測度。配准過程可以看作是—個參數尋優的問題。配准框架中,優化器是根據相似性測度中得到的經過量化的測度來優化變換參數。從一組參數初值開始,優化過程循環搜索變換參數搜索空間中的不同位置,根據相似性測度進行判斷並最終得到最優策略。在ITK中,優化算法有兩種,一種是適合處理返回單值的代價函數;另一種是適合處理每次階躍中返回多值的代價函數。在具體應用中,優化算法需根據使用的變換方法來配合選擇。 4、插值 內插器用來計算待配准圖像在非網格位置的值。在配准過程中,當一個變換將一個點從一個空間映射到另一個空間時,一般情況下該點會被映射到非網格區域,即參考圖像的網格位置不會正好映射到待配准圖像的網格位置上。因此,插值就是用來計算待配准圖像中非網格位置上的亮度值。常用的插值方法有最近點插值、線性插值、B樣條插值。 原文網址:https://read01.com/ORo4xP.html 原文網址:https://read01.com/ORo4xP.html 原文網址:https://read01.com/ORo4xP.html 原文網址:https://read01.com/ORo4xP.html
  • #18 - Rigid (rotate, translate) - Affine (rigid + scale & shear) - Deformable = non-rigid (affine + vector field) Many others Transform有很多種 SimpleITK 已經提供很多科學家常用的方法
  • #19 - MetaImage - The MHA (mhd + raw) file extension is related to MetaImage is a special medicine image format used in the Insight Segmentation and Registration Toolkit (ITK). MetaImage is a text-based tagged file format for medical images. Conversion between numpy and SimpleITK - GetArrayFromImage