1. 目的
2. コマンド
3. 使用例
3.1. 前準備
3.2. テンソルの推定(コマンド:dwi2tensor)
3.3. 拡散定量値の算出(コマンド:tensor2metric)
1. 目的
- MRtrixを用いた拡散テンソルイメージング: DTI
2. コマンド
MRtrixを用いて、拡散テンソルイメージング(DTI)をするには、dwi2tensorとtensor2metricコマンドを用いる。
dwi2tensorは拡散MRI画像からテンソルを推定するコマンドで、tensor2metricは推定したテンソルから拡散定量値を算出するコマンドである。
dwi2tensorのヘルプは、次の通り。
クリックして展開
SYNOPSIS
Diffusion (kurtosis) tensor estimation
USAGE
dwi2tensor [ options ] dwi dt
dwi the input dwi image.
dt the output dt image.
DESCRIPTION
By default, the diffusion tensor (and optionally its kurtosis) is fitted
to the log-signal in two steps: firstly, using weighted least-squares
(WLS) with weights based on the empirical signal intensities; secondly, by
further iterated weighted least-squares (IWLS) with weights determined by
the signal predictions from the previous iteration (by default, 2
iterations will be performed). This behaviour can be altered in two ways:
* The -ols option will cause the first fitting step to be performed using
ordinary least-squares (OLS); that is, all measurements contribute equally
to the fit, instead of the default behaviour of weighting based on the
empirical signal intensities.
* The -iter option controls the number of iterations of the IWLS
prodedure. If this is set to zero, then the output model parameters will
be those resulting from the first fitting step only: either WLS by
default, or OLS if the -ols option is used in conjunction with -iter 0.
The tensor coefficients are stored in the output image as follows:
volumes 0-5: D11, D22, D33, D12, D13, D23
If diffusion kurtosis is estimated using the -dkt option, these are stored
as follows:
volumes 0-2: W1111, W2222, W3333
volumes 3-8: W1112, W1113, W1222, W1333, W2223, W2333
volumes 9-11: W1122, W1133, W2233
volumes 12-14: W1123, W1223, W1233
OPTIONS
-ols
perform initial fit using an ordinary least-squares (OLS) fit (see
Description).
-mask image
only perform computation within the specified binary brain mask image.
-b0 image
the output b0 image.
-dkt image
the output dkt image.
-iter integer
number of iterative reweightings for IWLS algorithm (default: 2) (see
Description).
-predicted_signal image
the predicted dwi image.
DW gradient table import options
-grad file
Provide the diffusion-weighted gradient scheme used in the acquisition in
a text file. This should be supplied as a 4xN text file with each line is
in the format [ X Y Z b ], where [ X Y Z ] describe the direction of the
applied gradient, and b gives the b-value in units of s/mm^2. If a
diffusion gradient scheme is present in the input image header, the data
provided with this option will be instead used.
-fslgrad bvecs bvals
Provide the diffusion-weighted gradient scheme used in the acquisition in
FSL bvecs/bvals format files. If a diffusion gradient scheme is present in
the input image header, the data provided with this option will be instead
used.
Standard options
-info
display information messages.
-quiet
do not display information messages or progress status; alternatively,
this can be achieved by setting the MRTRIX_QUIET environment variable to a
non-empty string.
-debug
display debugging messages.
-force
force overwrite of output files (caution: using the same file as input and
output might cause unexpected behaviour).
-nthreads number
use this number of threads in multi-threaded applications (set to 0 to
disable multi-threading).
-config key value (multiple uses permitted)
temporarily set the value of an MRtrix config file entry.
-help
display this information page and exit.
-version
display version information and exit.
tensor2metricのヘルプは、次の通り。
クリックして展開
SYNOPSIS
Generate maps of tensor-derived parameters
USAGE
tensor2metric [ options ] tensor
tensor the input tensor image.
OPTIONS
-adc image
compute the mean apparent diffusion coefficient (ADC) of the diffusion
tensor. (sometimes also referred to as the mean diffusivity (MD))
-fa image
compute the fractional anisotropy (FA) of the diffusion tensor.
-ad image
compute the axial diffusivity (AD) of the diffusion tensor. (equivalent to
the principal eigenvalue)
-rd image
compute the radial diffusivity (RD) of the diffusion tensor. (equivalent
to the mean of the two non-principal eigenvalues)
-cl image
compute the linearity metric of the diffusion tensor. (one of the three
Westin shape metrics)
-cp image
compute the planarity metric of the diffusion tensor. (one of the three
Westin shape metrics)
-cs image
compute the sphericity metric of the diffusion tensor. (one of the three
Westin shape metrics)
-value image
compute the selected eigenvalue(s) of the diffusion tensor.
-vector image
compute the selected eigenvector(s) of the diffusion tensor.
-num sequence
specify the desired eigenvalue/eigenvector(s). Note that several
eigenvalues can be specified as a number sequence. For example, '1,3'
specifies the principal (1) and minor (3) eigenvalues/eigenvectors
(default = 1).
-modulate choice
specify how to modulate the magnitude of the eigenvectors. Valid choices
are: none, FA, eigval (default = FA).
-mask image
only perform computation within the specified binary brain mask image.
Standard options
-info
display information messages.
-quiet
do not display information messages or progress status; alternatively,
this can be achieved by setting the MRTRIX_QUIET environment variable to a
non-empty string.
-debug
display debugging messages.
-force
force overwrite of output files (caution: using the same file as input and
output might cause unexpected behaviour).
-nthreads number
use this number of threads in multi-threaded applications (set to 0 to
disable multi-threading).
-config key value (multiple uses permitted)
temporarily set the value of an MRtrix config file entry.
-help
display this information page and exit.
-version
display version information and exit.
DTI拡散定量値(FA, MD, AD, RD, カラーFA)を計算するための基本的な使い方は、以下の通り。
dwi2tensor <入力画像> <出力画像> tensor2metric -fa <出力画像> -adc <出力画像> -ad <出力画像> -rd <出力画像> -vec <出力画像> tensor.mif
3. 使用例
3.1. 前準備
まず、次のファイルを用意する。
. ├── DWI.nii.gz # 拡散MRI ├── DWI_mask.nii.gz ├── bvals # b-values ├── bvecs # b-vectors └── headers.json # ヘッダー情報の入ったJSONファイル
こちらの記事を参考に、拡散MRI(DWI.nii.gz)とそのMPG軸情報(bvecs, bvals)とヘッダー情報(headers.json)をまとめて、MIF形式(DWI.mif)に変換する。
mrconvert -fslgrad bvecs bvals -json_import headers.json DWI.nii.gz DWI.mif
3.2. テンソルの推定(コマンド:dwi2tensor)
ファイルの用意ができたら、dwi2tensorを次のように実行する
dwi2tensor DWI.mif tensor.mif
mrinfoを使って「tensor.mif」の情報を確認すると、6 volumesのデータであることが分かる。
mrinfo tensor.mif
************************************************
Image name: "tensor.mif"
************************************************
Dimensions: 130 x 130 x 82 x 6
Voxel size: 1.76923 x 1.76923 x 1.8 x 1
Data strides: [ -1 2 3 4 ]
Format: MRtrix
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 1 0 0 -109
-0 1 0 -103.7
-0 0 1 -58.57
それぞれのボリュームは、各方向の拡散係数に相当する。
The tensor coefficients are stored in the output image as follows:
volumes 0-5: D11, D22, D33, D12, D13, D23
3.3. 拡散定量値の算出(コマンド:tensor2metric)
先程推定した、「tensor.mif」を使って拡散定量値を算出する。
tensor2metric -fa FA.mif -adc MD.mif -ad AD.mif -rd RD.mif -vec color_FA.mif tensor.mif
DTIの各拡散定量値画像は、以下。



いつも参考にさせて頂きありがとうございます。初めてDTI解析を行っています。以下の2つの内容について、コメントをいただけたら幸いです。
① ABIS2022年12月の書類を参考に前処理を行っています。step7で行うMRtrix3のmrconvert(.nii.mif)で以下のようなエラーが発生しました(添付リンク, https://xfs.jp/KJRdaQ 、期間3日間)。そして、同じsubで別のコンピュータで実行すると、線が出る場所は変わります。
以下の参考リンクでも同じエラーの書き込みがありました。
まだ、解決方法は実施していませんが、根本先生からもし解決方法があればコメントをいただけたら幸いです。
参考リンク
https://community.mrtrix.org/t/problem-with-sorting-of-dicom-images-using-mrconvert/5493
https://github.com/MRtrix3/mrtrix3/issues/1118
使用データマシン情報
“Manufacturer”: “Philips”,
“ManufacturersModelName”: “Achieva”,
解析パソコン
macOS Monterey (v12.6.3)
Processor: 2.7 Ghz 12-core Intel Xeon E5
mrconvert v3.0.4
② 利用しているDTIデータは、Philipsマシンで撮影を行ったものです。
被験者につき、一つのフォルダーの中にT1,rest、DTIなどのscanデータ(分別されていません)が保存されていました。Scanの同じ数字のscanで保存されるときは、自動でPhilipsが“(2)”を追加します(添付リンク, https://xfs.jp/91ERA2 、期間3日間)。Convertを行った時に、そのファイルを書き変えればいいのでしょうか?①のエラーの原因にはなりますでしょうか?
どうぞよろしくお願いします。
質問を拝見しました。
– まず、2番めの質問から返答します。その方が正解にたどり着きやすい気がするからです。
– sortに関しては、以下をされてはいかがでしょうか。ご自身のデータがDICOMというフォルダに保存されているとします。並列で sorted というフォルダを作成します。
– これで、T1, rest, DTI がそれぞれ sorted の下に別々に保存されると思いますがいかがでしょうか。
– で、最初の質問ですが、mrtrix3のスレッドを確認しましたが、DICOM画像を直接 mif にする際に起きているようですね。
– 元画像のniftiにはしまは入っていないのでしょうか?まずは、niftiの元画像がどうだったのか教えていただけますか。
返信ありがとうございます。
根本先生が教えた頂いた方法で、T1, rest, DTI がそれぞれ sorted の下に別々に保存することができました(添付リンクhttps://xfs.jp/68ZjyQ )、勉強になりました。この方法で、DTIの前処理を行ったところ(step8まで)、しまうま線がまだでます(添付リンク https://xfs.jp/esxE7d )。
元画像のniftiには、しまうま線は出ていないかとおもいます。
念の為、元のniftiをリンクの中に入りました。(添付リンク https://xfs.jp/iDeYJ2 )
どうぞよろしくお願いします。
となると、これは、MRtrix3の問題になりますね。
MRtrix3の最新版を入れて試してもらうしかない気がします。
根本先生、今解析しているデータは子どものデータです(平均年齢は4歳)、先生に説明したことがなかったので、失礼しました。
現在、STEP4.3 eddy options の部分に –estimate_move_by_susceptibility を添加して解析してみたところ、FAとMDの画像も線が出なかったです。(添付リンク https://xfs.jp/eAMSAm、https://xfs.jp/wXsrx9)根本先生の方で、このオプションを追加すると、線が消える理由になるか説明になりますでしょうか?https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/UsersGuide#A–estimate_move_by_susceptibility(参考リンク)
どうぞよろしくお願いします。
お子さんだったら、–estimate_move_by_susceptibility が有効であった理由がわかります。
これは、FSLのEddyのオプションです。
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/UsersGuide#A–estimate_move_by_susceptibility
以下のように説明しています。重要なところを太字にしています。
Specifies that eddy shall attempt to estimate how the susceptibility-induced field changes when the subject moves in the scanner. The default is not to do it (i.e. the –estimate_move_by_susceptibility flag is not set). This is because it increases the execution time, especially when combined with slice-to-volume motion correction. We recommend it is used when scanning populations that move “more than average”, such as babies, children or other subjects that have difficulty remaining still. It can also be needed for studies with long total scan times, such that even in corporative subjects the total range of movement can become big.
ここら辺が説明になるのではないでしょうか。
いつも参考にさせて頂きありがとうございます。解析について詳しくなくて大変恐縮なのですが、MRtrix3でのDTIマップ画像を取得したく、本ページを参考に実行しましたが
mrconvert: [ERROR] can’t split string ”
”
mrconvert: [ERROR] error creating image “DWI.mif”
と表示されました。可能であれば解決策についてお教えいただければ幸いです。
ご多忙な中大変申し訳ありませんが、よろしくお願いたします。
よろしかったら、mrconvert のコマンドをそのままコピペしてもらってよろしいですか?入力画像は input.nii.gz などにしてもらってかまいませんので。
実際のコマンドを見たら想像がつくかなと思います。
早速返信頂きましてありがとうございます。すいませんがよろしくお願いいたします。
mrconvert -fslgrad sample_dti001.bvec sample_dti001.bval -json_import sample_dti001.json sample_edti001.nii.gz DWI.mif
コマンドそのものは悪くなさそうですね。
この場合、少しずつわけたらいいかなと思います。
まずは、
ができるかどうか確認してもらえたらと思います。
その次に
を試していただけますか。
これが問題なくいけたら、jsonファイルの import は必須ではないので、それで進めていいかと思います。
まずは、ここまで確認していただけませんか?
先生、早速ご対応頂き大変感謝しております。先生の通りにコマンドを実行しましたら上手く進むことができました。dwi2tensorやtensor2metricも実行可能でしたありがとうございました。
今回はCL、CP、CSマップの作成を目的にdtifitとfslmathsでλ1-3の計算式を参考に作り、fsleyesで確認したのですが、コントラストやブライトネスを動かしても画像が見えなかったので、MRtrixで確認することにしました。tensor2metric後にmifからniiに変換してfsleyesで見てみましたが同様で、論文で出ているような画像が出来ませんでした。FA、MD、RD、ADは問題ないように思います。今回の内容とは異なり、また具体的な問題点に欠け、大変申し訳ありませんが、もし何かありましたらアドバイスいただけると幸いです。mrconvertの件、誠にありがとうございました。
こちらも実際のコマンドを教えていただけたら、そこに何か課題がないかどうか確認できると思います。