【初心者向け】基礎&実践プログラミング

初心者がつまづきやすいところ、最短で実力が身につく方法をお伝えします。

【脳画像定量値】脳構造解析 (FreeSurfer)

f:id:AIProgrammer:20201209225430p:plain

動かしながら学ぶ PyTorchプログラミング入門

動かしながら学ぶ PyTorchプログラミング入門

  • 作者:斎藤勇哉
  • 発売日: 2020/11/30
  • メディア: Kindle版

目次

目的

  • 構造MRI (3D-T1WI)から、の脳構造を解析

FreeSurferの概要

準備中。。。

準備するデータ

準備するデータは、3D-T1WIのみである。

.
└── Subj001.nii.gz

実行

FreeSurferのrecon-allの基本的な使い方は、次の通り。Subjects DIR-sdは、被験者データが集められているフォルダを指定する。

recon-all -i <Input 3D-T1WI> -subjid <Subject ID> -all -sd .<Subject DIR>

例えば、次のようにコマンドを打ち込むことで、FreeSurferを実行できる。

recon-all -i Subj001.nii.gz -subjid Subj001 -all -sd .

結果

FreeSurferの処理が完了すると、Subj001/mriフォルダに灰白質(aparc+aseg.mgz)と白質wmparc.mgzが各脳領域ごとに分割された画像が生成される。これを脳画像に重ねて表示するには、次のコマンドを実行する。

freeview -v Subj001/mri/brain.mgz \
    Subj001/mri/aparc+aseg.mgz:colormap:lut:opacity=0.2 \
    Subj001/mri/wmparc.mgz:colormap:lut:opacity=0.2

以下のような画像が表示される。

f:id:AIProgrammer:20201210114645p:plain

また、各脳領域の厚さ・面積・体積・脳回の曲率等の情報がSubj001/statsフォルダに保存される。

aparc.stats

aparc.statsには、皮質および深部灰白質の構造情報が記載されている。また、aparc.statsは、左半球 (lh) と右半球 (rh) ごとに保存される(例: lh.aparc.stats)。

lh.aparc.statsの中身は、次の通り。

# Table of FreeSurfer cortical parcellation anatomical statistics 
# 
# CreationTime 2020/12/09-20:01:37-GMT
# generating_program mris_anatomical_stats
# cvs_version $Id: mris_anatomical_stats.c,v 1.79 2016/03/14 15:15:34 greve Exp $
# mrisurf.c-cvs_version $Id: mrisurf.c,v 1.781.2.6 2016/12/27 16:47:14 zkaufman Exp $
# cmdline mris_anatomical_stats -th3 -mgz -cortex ../label/lh.cortex.label -f ../stats/lh.aparc.stats -b -a ../label/lh.aparc.annot -c ../label/aparc.annot.ctab Subj001 lh white 
# sysname  Linux
# hostname neuro
# machine  x86_64
# user     neuro
# 
# SUBJECTS_DIR /home/neuro/Documents/Yuya_S/FreeSurfer/2_ANALYZE
# anatomy_type surface
# subjectname Subj001
# hemi lh
# AnnotationFile ../label/lh.aparc.annot
# AnnotationFileTimeStamp 2020/12/10 04:34:33
# Measure Cortex, NumVert, Number of Vertices, 134464, unitless
# Measure Cortex, WhiteSurfArea, White Surface Total Area, 91536.6, mm^2
# Measure Cortex, MeanThickness, Mean Thickness, 2.5011, mm
# Measure BrainSeg, BrainSegVol, Brain Segmentation Volume, 1249289.000000, mm^3
# Measure BrainSegNotVent, BrainSegVolNotVent, Brain Segmentation Volume Without Ventricles, 1227719.000000, mm^3
# Measure BrainSegNotVentSurf, BrainSegVolNotVentSurf, Brain Segmentation Volume Without Ventricles from Surf, 1227368.805429, mm^3
# Measure Cortex, CortexVol Total cortical gray matter volume, 509668.845191, mm^3
# Measure SupraTentorial, SupraTentorialVol, Supratentorial volume, 1091814.805429, mm^3
# Measure SupraTentorialNotVent, SupraTentorialVolNotVent, Supratentorial volume, 1073466.805429, mm^3
# Measure EstimatedTotalIntraCranialVol, eTIV, Estimated Total Intracranial Volume, 1529098.631452, mm^3
# NTableCols 10
# TableCol  1 ColHeader StructName
# TableCol  1 FieldName Structure Name
# TableCol  1 Units     NA
# TableCol  2 ColHeader NumVert
# TableCol  2 FieldName Number of Vertices
# TableCol  2 Units     unitless
# TableCol  3 ColHeader SurfArea
# TableCol  3 FieldName Surface Area
# TableCol  3 Units     mm^2
# TableCol  4 ColHeader GrayVol
# TableCol  4 FieldName Gray Matter Volume
# TableCol  4 Units     mm^3
# TableCol  5 ColHeader ThickAvg 
# TableCol  5 FieldName Average Thickness
# TableCol  5 Units     mm
# TableCol  6 ColHeader ThickStd
# TableCol  6 FieldName Thickness StdDev
# TableCol  6 Units     mm 
# TableCol  7 ColHeader MeanCurv
# TableCol  7 FieldName Integrated Rectified Mean Curvature
# TableCol  7 Units     mm^-1
# TableCol  8 ColHeader GausCurv 
# TableCol  8 FieldName Integrated Rectified Gaussian Curvature
# TableCol  8 Units     mm^-2
# TableCol  9 ColHeader  FoldInd
# TableCol  9 FieldName  Folding Index 
# TableCol  9 Units      unitless 
# TableCol 10 ColHeader CurvInd
# TableCol 10 FieldName Intrinsic Curvature Index
# TableCol 10 Units     unitless
# ColHeaders StructName NumVert SurfArea GrayVol ThickAvg ThickStd MeanCurv GausCurv FoldInd CurvInd
bankssts                                 1706   1193   3135  2.764 0.427     0.112     0.019       15     1.3
caudalanteriorcingulate                  1136    745   1942  2.368 0.668     0.158     0.026       24     1.1
caudalmiddlefrontal                      3765   2557   6665  2.419 0.421     0.116     0.020       35     3.2
cuneus                                   2066   1395   2739  1.905 0.546     0.151     0.034       29     3.0
entorhinal                                637    497   2185  3.351 0.914     0.119     0.024        5     0.7
fusiform                                 4365   3016   9776  2.901 0.595     0.135     0.029       65     5.2
inferiorparietal                         6556   4462  12218  2.510 0.460     0.122     0.024       81     6.2
inferiortemporal                         5440   3693  12466  2.853 0.620     0.126     0.027       75     6.2
isthmuscingulate                         1738   1138   2947  2.372 0.814     0.127     0.030       24     2.0
lateraloccipital                         7720   5101  12698  2.301 0.458     0.137     0.028      103     8.8
lateralorbitofrontal                     3955   2697   7867  2.600 0.577     0.134     0.031       55     5.0
lingual                                  5496   3835   8069  2.020 0.578     0.144     0.035       77     7.4
medialorbitofrontal                      3388   2238   6023  2.430 0.704     0.120     0.032       47     4.0
middletemporal                           5073   3489  12496  2.881 0.655     0.130     0.026       75     5.4
parahippocampal                          1129    718   2446  2.897 0.776     0.090     0.021        8     0.8
paracentral                              2097   1424   3854  2.502 0.497     0.119     0.026       20     2.0
parsopercularis                          2432   1679   4984  2.566 0.543     0.115     0.021       28     2.1
parsorbitalis                             977    670   2470  2.621 0.598     0.152     0.037       19     1.7
parstriangularis                         1970   1406   4121  2.453 0.467     0.134     0.033       30     2.6
pericalcarine                            2208   1531   1980  1.593 0.432     0.154     0.037       31     3.3
postcentral                              7825   5228  12158  2.086 0.553     0.120     0.022       89     7.0
posteriorcingulate                       1949   1342   3783  2.631 0.793     0.152     0.037       35     2.5
precentral                               8007   5252  14452  2.557 0.498     0.109     0.021       69     6.6
precuneus                                6465   4325  11805  2.509 0.500     0.122     0.026       72     6.6
rostralanteriorcingulate                 1421    964   3191  2.943 0.740     0.130     0.032       27     2.0
rostralmiddlefrontal                     8606   6003  15441  2.212 0.553     0.140     0.034      140    12.7
superiorfrontal                          9981   7035  21086  2.588 0.559     0.133     0.029      118    11.8
superiorparietal                         8285   5587  13849  2.271 0.415     0.123     0.023       96     7.4
superiortemporal                         6222   4206  13988  2.956 0.616     0.115     0.024       78     6.3
supramarginal                            6623   4574  13160  2.579 0.520     0.130     0.028       92     7.8
frontalpole                               347    235   1010  2.809 0.788     0.178     0.056       11     0.8
temporalpole                              673    484   1882  3.001 0.960     0.165     0.071       18     1.8
transversetemporal                        692    435   1114  2.318 0.447     0.096     0.018        5     0.4
insula                                   3655   2496   7826  3.170 0.729     0.121     0.033       37     4.8

wmparc.stats

wmparc.statsには、白質の構造情報が記載されている。

# Title Segmentation Statistics 
# 
# generating_program mri_segstats
# cvs_version $Id: mri_segstats.c,v 1.121 2016/05/31 17:27:11 greve Exp $
# cmdline mri_segstats --seg mri/wmparc.mgz --sum stats/wmparc.stats --pv mri/norm.mgz --excludeid 0 --brainmask mri/brainmask.mgz --in mri/norm.mgz --in-intensity-name norm --in-intensity-units MR --subject Subj001 --surf-wm-vol --ctab /opt/freesurfer/WMParcStatsLUT.txt --etiv 
# sysname  Linux
# hostname neuro
# machine  x86_64
# user     neuro
# anatomy_type volume
# 
# SUBJECTS_DIR /home/neuro/Documents/Yuya_S/FreeSurfer/2_ANALYZE
# subjectname Subj001
# Measure VentricleChoroidVol, VentricleChoroidVol, Volume of ventricles and choroid plexus, 18348.000000, mm^3
# Measure lhCerebralWhiteMatter, lhCerebralWhiteMatterVol, Left hemisphere cerebral white matter volume, 247050.231251, mm^3
# Measure rhCerebralWhiteMatter, rhCerebralWhiteMatterVol, Right hemisphere cerebral white matter volume, 245715.728986, mm^3
# Measure CerebralWhiteMatter, CerebralWhiteMatterVol, Total cerebral white matter volume, 492765.960237, mm^3
# Measure Mask, MaskVol, Mask Volume, 1604897.000000, mm^3
# Measure EstimatedTotalIntraCranialVol, eTIV, Estimated Total Intracranial Volume, 1529098.631452, mm^3
# SegVolFile mri/wmparc.mgz 
# SegVolFileTimeStamp  2020/12/10 05:19:19 
# ColorTable /opt/freesurfer/WMParcStatsLUT.txt 
# ColorTableTimeStamp 2017/01/19 07:00:02 
# InVolFile  mri/norm.mgz 
# InVolFileTimeStamp  2020/12/09 23:13:15 
# InVolFrame 0 
# PVVolFile  mri/norm.mgz 
# PVVolFileTimeStamp  2020/12/09 23:13:15 
# ExcludeSegId 0 
# Only reporting non-empty segmentations
# VoxelVolume_mm3 1 
# TableCol  1 ColHeader Index 
# TableCol  1 FieldName Index 
# TableCol  1 Units     NA 
# TableCol  2 ColHeader SegId 
# TableCol  2 FieldName Segmentation Id
# TableCol  2 Units     NA
# TableCol  3 ColHeader NVoxels 
# TableCol  3 FieldName Number of Voxels
# TableCol  3 Units     unitless
# TableCol  4 ColHeader Volume_mm3
# TableCol  4 FieldName Volume
# TableCol  4 Units     mm^3
# TableCol  5 ColHeader StructName
# TableCol  5 FieldName Structure Name
# TableCol  5 Units     NA
# TableCol  6 ColHeader normMean 
# TableCol  6 FieldName Intensity normMean
# TableCol  6 Units     MR
# TableCol  7 ColHeader normStdDev
# TableCol  7 FieldName Itensity normStdDev
# TableCol  7 Units     MR
# TableCol  8 ColHeader normMin
# TableCol  8 FieldName Intensity normMin
# TableCol  8 Units     MR
# TableCol  9 ColHeader normMax
# TableCol  9 FieldName Intensity normMax
# TableCol  9 Units     MR
# TableCol 10 ColHeader normRange
# TableCol 10 FieldName Intensity normRange
# TableCol 10 Units     MR
# NRows 70 
# NTableCols 10 
# ColHeaders  Index SegId NVoxels Volume_mm3 StructName normMean normStdDev normMin normMax normRange  
  1 3001      3524     3508.1  wm-lh-bankssts                    98.6405     7.9080    71.0000   118.0000    47.0000 
  2 3002      3041     3012.8  wm-lh-caudalanteriorcingulate    106.1743     9.7316    71.0000   126.0000    55.0000 
  3 3003      6943     6929.7  wm-lh-caudalmiddlefrontal         95.6736     9.8735    63.0000   117.0000    54.0000 
  4 3005      2121     2119.2  wm-lh-cuneus                      91.1391    10.4037    66.0000   114.0000    48.0000 
  5 3006      1049     1088.4  wm-lh-entorhinal                  80.1049     8.8624    56.0000   112.0000    56.0000 
  6 3007      6820     6751.2  wm-lh-fusiform                    90.8783    10.4333    56.0000   114.0000    58.0000 
  7 3008      9829     9877.3  wm-lh-inferiorparietal            96.3825    10.2446    63.0000   120.0000    57.0000 
  8 3009      7034     7002.1  wm-lh-inferiortemporal            86.2688    12.7662    51.0000   113.0000    62.0000 
  9 3010      4036     4077.5  wm-lh-isthmuscingulate           105.1016     9.5987    37.0000   124.0000    87.0000 
 10 3011      9108     9298.5  wm-lh-lateraloccipital            90.5220     9.1699    63.0000   114.0000    51.0000 
 11 3012      6634     6595.1  wm-lh-lateralorbitofrontal        99.7825    11.2891    66.0000   126.0000    60.0000 
 12 3013      6526     6406.8  wm-lh-lingual                     89.2861    10.1055    51.0000   117.0000    66.0000 
 13 3014      4776     4756.7  wm-lh-medialorbitofrontal        100.5992    12.2001    24.0000   127.0000   103.0000 
 14 3015      5454     5569.1  wm-lh-middletemporal              85.9773     9.9489    57.0000   112.0000    55.0000 
 15 3016      1589     1661.2  wm-lh-parahippocampal             89.3222     8.3148    65.0000   112.0000    47.0000 
 16 3017      4042     4074.3  wm-lh-paracentral                 92.4000     8.4372    66.0000   115.0000    49.0000 
 17 3018      3752     3724.1  wm-lh-parsopercularis             95.7439    10.4939    68.0000   119.0000    51.0000 
 18 3019       934      925.5  wm-lh-parsorbitalis               84.3351    10.0562    61.0000   106.0000    45.0000 
 19 3020      2889     2864.7  wm-lh-parstriangularis            91.3375    11.1110    62.0000   117.0000    55.0000 
 20 3021      3880     3534.2  wm-lh-pericalcarine               90.3379    10.1190    62.0000   113.0000    51.0000 
 21 3022      9048     9133.1  wm-lh-postcentral                 90.5553    10.1126    63.0000   117.0000    54.0000 
 22 3023      4979     4930.6  wm-lh-posteriorcingulate         102.9735     9.9418    48.0000   122.0000    74.0000 
 23 3024     14565    14538.0  wm-lh-precentral                  93.4461     9.1777    63.0000   119.0000    56.0000 
 24 3025     10517    10495.6  wm-lh-precuneus                   99.6304     9.6149    36.0000   154.0000   118.0000 
 25 3026      2602     2514.4  wm-lh-rostralanteriorcingulate   101.8966    14.8008    35.0000   134.0000    99.0000 
 26 3027     12713    12821.3  wm-lh-rostralmiddlefrontal        98.1206    10.5230    65.0000   120.0000    55.0000 
 27 3028     17112    17150.4  wm-lh-superiorfrontal             94.3707    10.5009    61.0000   123.0000    62.0000 
 28 3029     12917    13041.8  wm-lh-superiorparietal            96.7138    10.0283    62.0000   117.0000    55.0000 
 29 3030      8258     8541.9  wm-lh-superiortemporal            93.0829    10.6918    63.0000   118.0000    55.0000 
 30 3031      9396     9420.8  wm-lh-supramarginal               96.7631    10.6806    63.0000   121.0000    58.0000 
 31 3032       214      221.1  wm-lh-frontalpole                 92.0561     9.4181    74.0000   116.0000    42.0000 
 32 3033       624      687.3  wm-lh-temporalpole                79.2388     7.5813    57.0000   110.0000    53.0000 
 33 3034       642      622.6  wm-lh-transversetemporal          94.6511     8.5727    75.0000   115.0000    40.0000 
 34 3035     10580    10410.0  wm-lh-insula                      96.7245    10.8609    58.0000   124.0000    66.0000 
 35 4001      2904     2910.9  wm-rh-bankssts                    95.7104     7.8693    67.0000   110.0000    43.0000 
 36 4002      2504     2512.0  wm-rh-caudalanteriorcingulate    105.3910     9.3044    69.0000   123.0000    54.0000 
 37 4003      7042     6997.0  wm-rh-caudalmiddlefrontal         96.0454     9.8148    65.0000   116.0000    51.0000 
 38 4005      2412     2543.3  wm-rh-cuneus                      88.8429     8.8231    63.0000   113.0000    50.0000 
 39 4006       692      766.1  wm-rh-entorhinal                  78.1604     8.9138    59.0000   113.0000    54.0000 
 40 4007      7157     7093.4  wm-rh-fusiform                    89.5639     9.5493    59.0000   111.0000    52.0000 
 41 4008     12012    12138.6  wm-rh-inferiorparietal            94.7903     9.8456    65.0000   115.0000    50.0000 
 42 4009      6736     6716.1  wm-rh-inferiortemporal            88.8744    10.5262    59.0000   110.0000    51.0000 
 43 4010      3673     3687.3  wm-rh-isthmuscingulate           103.4236    10.2888    26.0000   124.0000    98.0000 
 44 4011      9750     9938.5  wm-rh-lateraloccipital            89.0627     8.8456    53.0000   109.0000    56.0000 
 45 4012      6075     6100.6  wm-rh-lateralorbitofrontal        94.8914    10.2953    62.0000   118.0000    56.0000 
 46 4013      6756     6633.9  wm-rh-lingual                     86.4899    10.0740    11.0000   111.0000   100.0000 
 47 4014      3719     3732.0  wm-rh-medialorbitofrontal         94.9559    11.6434    30.0000   119.0000    89.0000 
 48 4015      5794     5999.5  wm-rh-middletemporal              88.0036     9.7096    59.0000   110.0000    51.0000 
 49 4016      1574     1625.5  wm-rh-parahippocampal             88.7154     8.8436    44.0000   112.0000    68.0000 
 50 4017      4166     4199.9  wm-rh-paracentral                 93.8337     8.2716    69.0000   116.0000    47.0000 
 51 4018      3510     3504.4  wm-rh-parsopercularis             96.5960    10.2199    66.0000   117.0000    51.0000 
 52 4019      1053     1065.9  wm-rh-parsorbitalis               86.1054     9.5682    62.0000   109.0000    47.0000 
 53 4020      3448     3427.2  wm-rh-parstriangularis            91.6995    10.0940    62.0000   114.0000    52.0000 
 54 4021      2888     2670.2  wm-rh-pericalcarine               86.4228     8.9538    26.0000   108.0000    82.0000 
 55 4022      7978     7981.5  wm-rh-postcentral                 90.6651    10.5013    63.0000   116.0000    53.0000 
 56 4023      4712     4661.9  wm-rh-posteriorcingulate         103.0671     8.9448    49.0000   124.0000    75.0000 
 57 4024     14926    14925.4  wm-rh-precentral                  94.0721     8.5665    67.0000   117.0000    50.0000 
 58 4025     10712    10698.6  wm-rh-precuneus                   99.2039     9.2602    54.0000   121.0000    67.0000 
 59 4026      1870     1846.9  wm-rh-rostralanteriorcingulate   103.8059    10.5876    70.0000   131.0000    61.0000 
 60 4027     11835    12171.9  wm-rh-rostralmiddlefrontal        96.1585     9.2493    66.0000   115.0000    49.0000 
 61 4028     17809    18126.3  wm-rh-superiorfrontal             94.0811     9.3702    63.0000   119.0000    56.0000 
 62 4029     13213    13320.4  wm-rh-superiorparietal            95.6500     9.6784    63.0000   116.0000    53.0000 
 63 4030      7743     7980.9  wm-rh-superiortemporal            93.0976     9.4358    65.0000   113.0000    48.0000 
 64 4031      9885     9909.1  wm-rh-supramarginal               96.7241    10.3698    63.0000   118.0000    55.0000 
 65 4032       240      265.8  wm-rh-frontalpole                 91.2417     7.4440    75.0000   107.0000    32.0000 
 66 4033       723      784.5  wm-rh-temporalpole                78.9391     8.1127    57.0000    98.0000    41.0000 
 67 4034       585      577.1  wm-rh-transversetemporal          96.0513     7.4146    73.0000   112.0000    39.0000 
 68 4035     11695    11518.1  wm-rh-insula                      94.4427    11.1743    41.0000   120.0000    79.0000 
 69 5001     37165    37072.8  Left-UnsegmentedWhiteMatter      103.1510     9.9691    27.0000   127.0000   100.0000 
 70 5002     35548    35459.7  Right-UnsegmentedWhiteMatter     102.0210     9.6094    23.0000   126.0000   103.0000 


頑張れ!喝!!の代わりにB!ブックマークを押していただけるとただただうれしいです(^^)! ↓

動かしながら学ぶ PyTorchプログラミング入門

動かしながら学ぶ PyTorchプログラミング入門

  • 作者:斎藤勇哉
  • 発売日: 2020/11/30
  • メディア: Kindle版