使用fsl進行MRI腦圖像分析

使用fsl進行MRI腦圖像分析

MED620122 生物醫學工程進展

1 安裝教程

軟件與系統版本

  • FLIRT version 6.0
  • Ubuntu 16.04
  • FSLeyes version 0.31.0+build0(這裏有個坑是,fsl本身也自帶fsleyes,但是版本較低,有些功能使用會有問題,需要單獨下載fsleyes然後替換

首先,去官網下載fslinstaller.py 選擇 “Download FSL”
然後參考官網的安裝教程,進行安裝
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FslInstallation/Linux

sudo python2 fslinstaller.py

下載速度比較慢,耐心等待安裝完成後,由於本人是用shell運行的,要配置環境變量,參考如下網頁配置環境變量:
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FslInstallation/ShellSetup

把如下的命令加到~/.bash_profile文件的後面,再重新打開shell即可

FSLDIR=/usr/local/fsl
. ${FSLDIR}/etc/fslconf/fsl.sh
PATH=${FSLDIR}/bin:${PATH}
export FSLDIR PATH

然後如果配置成功,輸入flirt -version可以返回軟件的版本,例如:FLIRT version 6.0

如果想測試安裝是否成功,可以下載FSL評估和示例數據套件(FEEDS),課程學習網址:https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FEEDS

按照教程,下載解壓完成後,輸入/usr/bin/time ./RUN all 即可進行評估

https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/userdoc/latest/

此處有個大坑是,fsleyes默認在fsl裏面有安裝,但是其版本是老版本,我嘗試的時候,3Dview的功能就不能使用,此時需要到fsleyes的網站上單獨安裝

  • fsleyes的網站:https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/userdoc/latest/install.html#
  • fsleyes安裝教程(替換fsl內置版本):https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSLeyes
  • fsleyes UserGuide:https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/userdoc/latest/

2 fsl Course

首先,進入fsl Course的官網下載示例數據,學習圖像分割,http://fsl.fmrib.ox.ac.uk/fslcourse/

示例學習主要是參考:http://fsl.fmrib.ox.ac.uk/fslcourse/lectures/practicals/seg_struc/index.html

主要是用到了以下兩個部分的數據

wget -c http://fsl.fmrib.ox.ac.uk/fslcourse/downloads/structural.tar.gz
wget -c http://fsl.fmrib.ox.ac.uk/fslcourse/downloads/registration.tar.gz

2.1 bet去除顱骨

首先,進入~/fsl/seg_struc/fast目錄,解壓示例圖像,然後再使用bet進行分割

gunzip structural.nii.gz
bet structural.nii structural_brain 
gunzip structural_brain.nii.gz
fsleyes structural.nii structural_brain.nii &

fsleyes用於可視化檢測“去除顱骨的效果”

fsleyes可視化去除顱骨

2.2 fslroi選取感興趣區域

也可以使用fslroi選取感興趣的區域,再加載進fsleye

fslroi structural_brain structural_brain_roi 0 175 0 185 100 5

fsleyes可視化roi

2.3 FAST分割+偏置場校正

示例中還有輸入Fast GUI命令,進行偏置場校正及分割,設置同官網,進行校正。
輸出3類,輸出選項全都勾上,然後iteration共10次

Use the GUI (Fast [or Fast_gui on a Mac]) and turn on the Estimated bias fieldbutton (which saves a copy of the bias field) and **Restored input button **(which corrects the original image with the calculated bias field). For both images also open the Advanced Options tab and change the Number of iterations for bias field removal to 10 to account for the strong bias fields in both cases.

此時並沒有配準到MNI152的空間!

關於爲何選擇輸出3類
Now choose the Number of classes to be segmented. Normally you will want 3 (Grey Matter, White Matter and CSF). However, if there is very poor grey/white contrast you may want to reduce this to 2; alternatively, if there are strong lesions showing up as a fourth class, you may want to increase this. Also, if you are segmenting T2-weighted images, you may need to select 4 classes so that dark non-brain matter is processed correctly (this is not a problem with T1-weighted as CSF and dark non-brain matter look similar).

PS:下圖中選項中是選擇6類,注意改成3類

Fast GUI偏置場校正

2.4 Partial Volume Segmentation 圖像分割結果##

fsleyes structural_brain_roi_restore \
  structural_brain_roi_pve_0 -cm green -dr 0.5 1 \
  structural_brain_roi_pve_1 -cm blue-lightblue -dr 0.5 1 \
  structural_brain_roi_pve_2 -cm red-yellow -dr 0.5 1 &

下圖就是圖像分割結果,不同顏色分別代表GM, WM, CSF;灰質,白質,腦脊液。

  • 腦脊液(綠色pve0)
  • 灰質(藍色pve1)
  • 白質(紅黃pve2)

Partial Volume Segmentation

各種組織分割的結果如下:

  • *pve_*文件表示每類的概率,沒有進行二值化
  • *seg_*文件表示每類分割結果,進行過二值化
  • bias文件爲偏置場。

2.5 fslstats 統計##

第一個數字表示整個圖像上GM(pve1是灰質)的平均體素,就是個百分比,第二個是整張圖體素數目,第三個數字是圖像的總體積(單位:立方毫米),忽略了所有的零體素(就是腦袋外的體素不算在內),將第一和第三個數字相乘可以得到GM的總體積。

fslstats

2.6 FIRST 皮層下結構分割及統計分析##

首先,進入~/fsl/seg_struc/first目錄

run_first_all -i con0047_brain -b -s L_Hipp,L_Amyg \
  -o con0047 -a con0047_brain_to_std_sub.mat

-a指定了仿射配準的矩陣,這個步驟也可以自動完成
-s指定要分割的部分,此處是L_Hipp,L_Amyg

將圖像con0047_brain_to_std_sub.nii.gz與“1mm標準空間模板圖像”一起加載到FSLeyes中。查看皮層下結構的對齊方式,兩者都是MNI152 space,所以非常接近。

與模板的比較

後面對於分割不滿意,還可以Boundary corrected segmentation output,將邊界重新進行調整。

Vertex Analysis

照樣是跟着教程來,換了一個文件夾,在fsl/seg_struc/first/shapeAnalysis下面運行的。

  1. 首先,使用concat_bvars把頂點信息文件bvars整合成一個,注意此時整合的順序和後序design matrix的要保持一致
  2. 接着,打開Glm,按照教程上的進行配置:
  3. Create a design matrix (Don’t worry if you don’t fully understand this part, we will cover this in more detail later in the course).The subject order should match the order in which the .bvars were combined in the concat_bvars call. The design matrix is most easily created using FSL’s Glm tool (a single column file). To do this, start the Glm GUI (Glm_gui on mac). First, choose the Higher-level/non-timeseries design option from the top pull down menu in the small window. Next, set the # inputs option to be 8 (the number of subjects we have in this example).
  4. In the bigger window (of the Glm GUI) set the values of the EV (the numbers in the second column) to be -1 for the first five entries (our five controls) and +1 for the next three entries (our three patients). This will allow us probe the difference between groups. Leave the ‘group’ column as all ones. Once you’ve done this, go to the Contrasts and F-tests tab. Rename the t-contrast (C1) to ‘group difference’, but leave the value set for EV1 as 1. We also need to add an F-test. Change the number in the F-tests box to 1, and then highlight the button on the right hand side (under F1) to select an F-test that operates on the single t-contrast.This F-test will be the main contrast of interest for our vertex analysis as it allows us to test for differences in either direction.
  5. When this is all set up correctly, save everything using the Save button in the smaller Glm window. Choose the current directory and use the name design_con1_dis2 (as we will assume this is the name used below, although for your own studies you can use any name of your choice). Now exit the Glm GUI.
  6. 然後,使用randomise進行統計檢驗
  7. 最後,用fsleyes可視化。

全部命令如下:

concat_bvars all.bvars *L_Hipp*.bvars
# 我的理解是,該步驟把不同subject的bvars整合出來的文件,使用--useReconMNI參數,重構到MNI空間。Reconstructs the meshes in MNI space(native space of the model).
first_utils --usebvars --vertexAnalysis -i all.bvars -o diff_con1_dis2_L_Hipp_mni -d design_con1_dis2.mat --useReconMNI
# 在重構好的空間裏,進行統計檢驗
randomise -i diff_con1_dis2_L_Hipp_mni.nii.gz \
  -m diff_con1_dis2_L_Hipp_mni_mask.nii.gz \
  -o con1_dis2_L_Hipp_rand -d design_con1_dis2.mat \
  -t design_con1_dis2.con -f design_con1_dis2.fts \
  --fonly -D -F 3
# 可視化有差異的地方(都在MNI152空間)
fsleyes -std1mm con1_dis2_L_Hipp_rand_clustere_corrp_fstat1 -cm red-yellow -dr 0.95 1 &

最後可視化,橘黃色部分應該就是存在差異的地方:

可視化統計結果

當然,UserGuide裏面也有相似的內容,也跑了一下,比較坑的是,UserGuide內容較老,裏面有張圖是用FSLView可視化的,現在該工具已經棄用,另一張圖按照示例代碼(見下方),對應着改了下文件,也沒有做出來有不同顏色和箭頭(UserGuide說箭頭要另做)的樣子。做出來的圖如下:

UserGuide鏈接:
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FIRST/UserGuide

# 此處的不同之處在於,是在原來圖像的空間進行重構
# --useReconNative : Reconstructs the meshes in the native space of the image. For vertex-wise stats need to also use --useRigidAlign.
# --useRigidAlign : Uses a 6 Degrees Of Freedom transformation to remove pose from the meshes (see --useScale if you wish to remove size as well). All meshes are aligned to the mean shape from the shape Model. Can be used with either ReconNative or ReconMNI.
first_utils --vertexAnalysis --surfaceout --usebvars -i con_to_dis_L_Hipp.bvars -d con1_dis2.mat -o shape_analysis/con1_dis2_L_Hipp --useReconNative --useRigidAlign -v >& shape_analysis/con1_dis2_L_Hipp_output.txt

# 生成一個有pvals的文件,與之前的vtk文件內容一致
surface_fdr con1_dis2_L_Hipp1.vtk

統計結果

3 Homework data analysis

3.1 bet去除顱骨

使用類似如下命令去除顱骨,然後放入fsleyes進行可視化

bet CC0007_philips_15_62_M.nii CC0007_philips_15_62_M_brain
# fsl可視化
fsleyes *_brain.nii.gz &

作業數據bet去除顱骨

3.2 FAST分割+偏置場校正

使用如下命令進行FAST分割和偏置場校正,具體說明見上面,也是使用Fast GUI設置的

此時的偏置場校正並沒有配準到MNI152的空間!

/usr/local/fsl/bin/fast -t 1 -n 3 -H 0.1 -I 10 -l 20.0 -g -B -b -o /home/wang/BME_Homework/CC0003_philips_15_63_F_brain /home/wang/BME_Homework/CC0003_philips_15_63_F_brain
/usr/local/fsl/bin/fast -t 1 -n 3 -H 0.1 -I 10 -l 20.0 -g -B -b -o /home/wang/BME_Homework/CC0004_philips_15_67_M_brain /home/wang/BME_Homework/CC0004_philips_15_67_M_brain
/usr/local/fsl/bin/fast -t 1 -n 3 -H 0.1 -I 10 -l 20.0 -g -B -b -o /home/wang/BME_Homework/CC0005_philips_15_62_M_brain /home/wang/BME_Homework/CC0005_philips_15_62_M_brain
/usr/local/fsl/bin/fast -t 1 -n 3 -H 0.1 -I 10 -l 20.0 -g -B -b -o /home/wang/BME_Homework/CC0006_philips_15_63_F_brain /home/wang/BME_Homework/CC0006_philips_15_63_F_brain
/usr/local/fsl/bin/fast -t 1 -n 3 -H 0.1 -I 10 -l 20.0 -g -B -b -o /home/wang/BME_Homework/CC0007_philips_15_62_M_brain /home/wang/BME_Homework/CC0007_philips_15_62_M_brain
/usr/local/fsl/bin/fast -t 1 -n 3 -H 0.1 -I 10 -l 20.0 -g -B -b -o /home/wang/BME_Homework/CC0008_philips_15_60_F_brain /home/wang/BME_Homework/CC0008_philips_15_60_F_brain

3.3 Partial Volume Segmentation 圖像分割結果##

fsleyes CC0003_philips_15_63_F_brain \
  CC0003_philips_15_63_F_brain_pve_0 -cm green -dr 0.5 1 \
  CC0003_philips_15_63_F_brain_pve_1 -cm blue-lightblue -dr 0.5 1 \
  CC0003_philips_15_63_F_brain_pve_2 -cm red-yellow -dr 0.5 1 &
fsleyes CC0005_philips_15_62_M_brain \
  CC0005_philips_15_62_M_brain_pve_0 -cm green -dr 0.5 1 \
  CC0005_philips_15_62_M_brain_pve_1 -cm blue-lightblue -dr 0.5 1 \
  CC0005_philips_15_62_M_brain_pve_2 -cm red-yellow -dr 0.5 1 &

作業數據圖像分割結果

  • 腦脊液(綠色pve0)
  • 灰質(藍色pve1)
  • 白質(紅黃pve2)

3.3 fslstats 統計##

使用xargs命令批量拿出來腦脊液,灰質和白質的體積。(-I {} 大括號指定替換的符號)

ls *_pve_*|xargs -I {} $FSLDIR/bin/fslstats {} -M -V
  • 腦脊液(pve0)
  • 灰質(pve1)
  • 白質(pve2)

統計彙總如下:

與使用matlab toolkit中CAT做出來的體積略有不同,差別最大的是CC0007,CAT做出來CC0007的灰質比白質略小,這裏CC0007的灰質比白質略大

病人編號 組織類別 整張圖體素數目 圖像的總體積(立方毫米) 百分比 對應結構的體素數目 對應結構的體積(立方厘米)
CC0003 腦脊液 498338 393750.4688 0.699085 348380.6207 275.2650464
CC0003 灰質 978755 773341.125 0.718218 702959.4586 555.4275161
CC0003 白質 731029 577606 0.789414 577084.527 455.9702629
CC0004 腦脊液 664398 524961.8125 0.714634 474801.4003 375.1555599
CC0004 灰質 1209274 955485.5625 0.720517 871302.4747 688.443591
CC0004 白質 994846 786059.25 0.815883 811677.939 641.3323791
CC0005 腦脊液 600755 474675.2188 0.70273 422168.5612 333.5685165
CC0005 灰質 1201045 948983 0.730482 877341.7537 693.2149998
CC0005 白質 932851 737074.5625 0.79763 744069.9431 587.9127833
CC0006 腦脊液 490649 387674.8125 0.689181 338145.9685 267.178115
CC0006 灰質 1082499 855311.25 0.740182 801246.2748 633.0859916
CC0006 白質 845774 668268.5 0.807705 683135.8887 539.7638088
CC0007 腦脊液 638762 504700.125 0.720264 460077.2732 363.5173308
CC0007 灰質 1183335 934979.3125 0.729251 862948.2321 681.8345986
CC0007 白質 1025489 810261.8125 0.831084 852267.5001 673.3956282
CC0008 腦脊液 467768 369597.4063 0.685212 320520.2468 253.2525779
CC0008 灰質 1026966 811436.3125 0.741014 760996.1835 601.2856677
CC0008 白質 797140 629843.9375 0.805895 642411.1403 507.58808

3.4 FIRST 皮層下結構分割及統計分析##

  • 此處設置分割左右尾狀核
  • 此處沒有設定仿射變換矩陣(Course教程中有指定變換矩陣mat文件,是因爲他配準過了,要節省時間)

結果文件中_to_std_sub.nii.gz纔是配準到了MNI152空間

run_first_all -i CC0003_philips_15_63_F_brain -b -s L_Caud,R_Caud -o CC0003
run_first_all -i CC0004_philips_15_67_M_brain -b -s L_Caud,R_Caud -o CC0004
run_first_all -i CC0005_philips_15_62_M_brain -b -s L_Caud,R_Caud -o CC0005
run_first_all -i CC0006_philips_15_63_F_brain -b -s L_Caud,R_Caud -o CC0006
run_first_all -i CC0007_philips_15_62_M_brain -b -s L_Caud,R_Caud -o CC0007
run_first_all -i CC0008_philips_15_60_F_brain -b -s L_Caud,R_Caud -o CC0008
  • -b specifies that the input image is brain extracted - important when calculating the registration.
  • -s allows a restricted set of structures (one or more) to be selected. For more than one structure the list must be comma separated with no spaces. The list of possible structures is: L_Accu L_Amyg L_Caud L_Hipp L_Pall L_Puta L_Thal R_Accu R_Amyg R_Caud R_Hipp R_Pall R_Puta R_Thal BrStem. 這個參數不指定的話,會把所有結構都分割出來,然後firstseg和origsegs文件裏面就是有很多的結構,並且用不同的數值進行了標記

這一步驟,生成了all_fast_firstseg.nii.gz和all_fast_origsegs.nii.gz兩個文件,其中firstseg是校正過後的文件,origseg是校正前的文件。
一般都是使用firstseg是校正過後的文件,校正前的文件分了組織的“邊界”和“內部”像素,“邊界”的像素=“內部”像素的值+100。

  • The corrected image (*_firstseg) is normally the one that you would use to define an ROI or mask for a particular subcortical structure.
  • For more details on the uncorrected image (*_origsegs) – see the optional practical at the end.

此處,由於我只指定了尾狀核,所以使用如下命令,可視化不同樣本的尾狀核,下圖是三個方向看的結構

Make sure that you look at the axial, coronal and sagittal slices.

first_roi_slicesdir *nii *all_fast_firstseg.nii.gz

後續還可以自己再進行邊界校正**“Boundary Correction”**,具體使用方法爲:first_boundary_corr -s segmented_image -i intensity_image -b method -o output_name,此處我沒有進行校正。

參考文檔:https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FIRST/UserGuide

作業數據圖像分割結果

3.5 Vertex Analysis

這一部分的目的是:localised change in shape and/or size

For vertex analysis, we will be using the .bvars files as they contain the information about the sub-voxel mesh coordinates.

Combine all the mode parameters (.bvars file) into a single file. Each structure (model) that is fit with FIRST will generate a separate .bvars file. For a given structure (e.g. Caud尾狀核) combine all the relevant .bvars files using the concat_bvars script.

Note that the order here is very important, as it must correspond to the order specified in the design matrix to be used later for statistical testing. For this example, combine the .bvars files (all of the left Caud 和 right Caud 分別左右尾狀核) using the command:

concat_bvars命令把bvars文件合併,此處的順序會影響後面design的設計,所以事先指定好,然後輸入Glm創建design分組信息矩陣,具體如何創建分組信息矩陣,可以參考UserGuide:https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FEAT/UserGuide

concat_bvars all.L_Caud.bvars CC0003-L_Caud_first.bvars CC0006-L_Caud_first.bvars CC0008-L_Caud_first.bvars CC0004-L_Caud_first.bvars CC0005-L_Caud_first.bvars CC0007-L_Caud_first.bvars
concat_bvars all.R_Caud.bvars CC0003-R_Caud_first.bvars CC0006-R_Caud_first.bvars CC0008-R_Caud_first.bvars CC0004-R_Caud_first.bvars CC0005-R_Caud_first.bvars CC0007-R_Caud_first.bvars

接着,使用first_utils,選定矩陣,進行Vertex Analysis,然後使用randomise命令進行多重比較(with multiple comparison correction),找到有顯著差異的部分,可視化可以直接用fsleyes中的3Dview功能進行,也可以使用first3Dview

具體可以參考Course:
http://fsl.fmrib.ox.ac.uk/fslcourse/lectures/practicals/seg_struc/index.html#first

# 我的理解是,該步驟把不同subject的bvars整合出來的文件,使用--useReconMNI參數,重構到MNI空間。Reconstructs the meshes in MNI space(native space of the model).
first_utils --usebvars --vertexAnalysis -i all.L_Caud.bvars -o design_F1_M2_L_Caud_mni -d design_F1_M2.mat --useReconMNI
# 在重構好的空間裏,進行統計檢驗
randomise -i design_F1_M2_L_Caud_mni.nii.gz -m design_F1_M2_L_Caud_mni_mask.nii.gz -o F1_M2_L_Caud_rand -d design_F1_M2.mat -t design_F1_M2.con -f design_F1_M2.fts \
  --fonly -D -F 3
# 可視化有差異的地方(都在MNI152空間)
fsleyes -std1mm F1_M2_L_Caud_rand_clustere_corrp_fstat1 -cm red-yellow -dr 0.95 1 &

# 同樣的,對於右尾狀核也進行一樣的操作,也沒有看出來有差異
first_utils --usebvars --vertexAnalysis -i all.L_Caud.bvars -o design_F1_M2_L_Caud_mni -d design_F1_M2.mat --useReconMNI
randomise -i design_F1_M2_L_Caud_mni.nii.gz -m design_F1_M2_L_Caud_mni_mask.nii.gz -o F1_M2_L_Caud_rand -d design_F1_M2.mat -t design_F1_M2.con -f design_F1_M2.fts \
  --fonly -D -F 3
fsleyes -std1mm F1_M2_L_Caud_rand_clustere_corrp_fstat1 -cm red-yellow -dr 0.95 1 &

無橘黃色差異的地方

重點

-dr LO HI, --displayRange LO HI 此處設置的範圍是[0.95,1],圖上無橘黃色,表示頂點分析無顯著性的差異

如果將顯示的範圍調寬,則可以看出少部分不顯著的差異地方,以下兩圖爲同一位置:

差異部位

原圖位置

使用舊版方法檢驗(UserGuide不推薦),嘗試了“使用useRigidAlign”和“不使用useRigidAlign”,surface_fdr也都沒有檢驗出差異,即fdrmaskFthreshFvalspthreshpvals都爲空,
此處“數字醫學研究中心”的學生也只是試了UserGuide裏的方法,沒有嘗試fsl course裏的東西,同樣也只是得出空文件,大概就是沒法檢驗出有統計性的結果。

具體代碼如下:

first_utils --vertexAnalysis --surfaceout --usebvars -i all.L_Caud.bvars -d design_F1_M2.mat -o shape_analysis/F1_M2_L_Caud_rigid --useReconNative --useRigidAlign -v >& shape_analysis/F1_M2_L_Caud_rigid_output.txt
surface_fdr F1_M2_L_Caud_rigid1.vtk

first_utils --vertexAnalysis --surfaceout --usebvars -i all.L_Caud.bvars -d design_F1_M2.mat -o shape_analysis/F1_M2_L_Caud_norigid --useReconNative -v >& shape_analysis/F1_M2_L_Caud_norigid_output.txt
surface_fdr F1_M2_L_Caud_norigid1.vtk

舊版方法檢驗,vtk文件可視化

3.6 Volumetric Analysis

對尾狀核進行體積分析,同樣使用xargs命令批量得到尾狀核的體積。(-I {} 大括號指定替換的符號)

# Left-Caudate
ls *_fast_firstseg.nii.gz |xargs -I {} $FSLDIR/bin/fslstats {} -l 10.5 -u 11.5 -V
# Right-Caudate
ls *_fast_firstseg.nii.gz |xargs -I {} $FSLDIR/bin/fslstats {} -l 49.5 -u 50.5 -V

整理如下:
與使用matlab toolkit中CAT做出來的體積略有不同

病人編號 組織類別 像素數目 體積(立方毫米) 體積(立方厘米)
CC0003 左尾狀核 3463 2736.210945 2.736210945
CC0003 右尾狀核 3494 2760.704892 2.760704892
CC0004 左尾狀核 4586 3623.543375 3.623543375
CC0004 右尾狀核 4374 3456.035482 3.456035482
CC0005 左尾狀核 4461 3524.774828 3.524774828
CC0005 右尾狀核 4629 3657.516852 3.657516852
CC0006 左尾狀核 4029 3183.419978 3.183419978
CC0006 右尾狀核 3980 3144.703776 3.144703776
CC0007 左尾狀核 4612 3644.044224 3.644044224
CC0007 右尾狀核 4602 3636.143001 3.636143001
CC0008 左尾狀核 4214 3329.606493 3.329606493
CC0008 右尾狀核 4699 3712.81939 3.71281939

4 總結

4.1 信息彙總

使用R語言和ggplot統計各組織的體積(單位:立方厘米),統計代碼如下:

library(ggplot2)
setwd("C:/Users/83918/Desktop/BME_Homework")
Data <- read.table("C:/Users/83918/Desktop/BME_Homework/Volume.txt", head=T)
Data$TissueType <- factor(Data$TissueType, levels = c("CSF","GM","WM","Left_Caudate","Right_Caudate"))

Data[which(Data$PatientID=="CC0003"),"gender"] <- "Female"
Data[which(Data$PatientID=="CC0004"),"gender"] <- "Male"
Data[which(Data$PatientID=="CC0005"),"gender"] <- "Male"
Data[which(Data$PatientID=="CC0006"),"gender"] <- "Female"
Data[which(Data$PatientID=="CC0007"),"gender"] <- "Male"
Data[which(Data$PatientID=="CC0008"),"gender"] <- "Female"

ggplot(data=Data, aes(x=gender,y=Volume))+
  geom_boxplot(aes(fill=TissueType))+
  facet_wrap(~ TissueType,nrow = 1, ncol = 5, scales="free")
ggsave("volume.pdf",width = 8,height = 5)

彙總的表格如下:

PatientID TissueType Volume
CC0003 CSF 275.2650464
CC0003 GM 555.4275161
CC0003 WM 455.9702629
CC0004 CSF 375.1555599
CC0004 GM 688.443591
CC0004 WM 641.3323791
CC0005 CSF 333.5685165
CC0005 GM 693.2149998
CC0005 WM 587.9127833
CC0006 CSF 267.178115
CC0006 GM 633.0859916
CC0006 WM 539.7638088
CC0007 CSF 363.5173308
CC0007 GM 681.8345986
CC0007 WM 673.3956282
CC0008 CSF 253.2525779
CC0008 GM 601.2856677
CC0008 WM 507.58808
CC0003 Left_Caudate 2.736210945
CC0003 Right_Caudate 2.760704892
CC0004 Left_Caudate 3.623543375
CC0004 Right_Caudate 3.456035482
CC0005 Left_Caudate 3.524774828
CC0005 Right_Caudate 3.657516852
CC0006 Left_Caudate 3.183419978
CC0006 Right_Caudate 3.144703776
CC0007 Left_Caudate 3.644044224
CC0007 Right_Caudate 3.636143001
CC0008 Left_Caudate 3.329606493
CC0008 Right_Caudate 3.71281939

繪製出的統計圖如下:

各組織體積比較

4.1 結論

作業數據中,三個男性的的白質,灰質,腦脊液,左右尾狀核的體積都比三個女性要大得多,但是其尾狀核的形狀沒有顯著差異。

5 相關參考資料

  • fsl UserGuide: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
  • fsl課程ppt及練習數據: http://fsl.fmrib.ox.ac.uk/fslcourse/
  • 注意看fsl課程practice相應html網頁的時候,對照着網站上的ppt

官網說明的Labels如下:

  • 10 Left-Thalamus-Proper 40
  • 11 Left-Caudate 30
  • 12 Left-Putamen 40
  • 13 Left-Pallidum 40
  • 16 Brain-Stem /4th Ventricle 40
  • 17 Left-Hippocampus 30
  • 18 Left-Amygdala 50
  • 26 Left-Accumbens-area 50
  • 49 Right-Thalamus-Proper 40
  • 50 Right-Caudate 30
  • 51 Right-Putamen 40
  • 52 Right-Pallidum 40
  • 53 Right-Hippocampus 30
  • 54 Right-Amygdala 50
  • 58 Right-Accumbens-area 50
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章