1. 目的
2. コマンド
3. 使用例
3.1. 前準備
3.2. 拡散MRIのバイアス(信号ムラ)補正
1. 目的
- MRtrixを用いた拡散MRIのバイアス(信号ムラ)補正
2. コマンド
MRtrixを用いて拡散MRIのバイアス(信号ムラ)補正をするには、dwibiascorrect
を使用する。
ここでは、ANTsのN4アルゴリズムを用いたバイアス補正を紹介する。ANTsアルゴリズムを使用する場合は、ANTsを前もってインストールしておく必要がある。
dwibiascorrect
のヘルプは、次の通り。
クリックして展開
SYNOPSIS Perform B1 field inhomogeneity correction for a DWI volume series USAGE dwibiascorrect [ options ] algorithm ... algorithm Select the algorithm to be used to complete the script operation; additional details and options become available once an algorithm is nominated. Options are: ants, fsl Options for importing the diffusion gradient table -grad GRAD Provide the diffusion gradient table in MRtrix format -fslgrad bvecs bvals Provide the diffusion gradient table in FSL bvecs/bvals format Options common to all dwibiascorrect algorithms -mask image Manually provide a mask image for bias field estimation -bias image Output the estimated bias field Additional standard options for Python scripts -nocleanup do not delete intermediate files during script execution, and do not delete scratch directory at script completion. -scratch /path/to/scratch/ manually specify the path in which to generate the scratch directory. -continue <ScratchDir> <LastFile> continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file. 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. -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.
基本的な使い方は、以下の通り。
dwibiascorrect ants <入力画像> <出力画像>
3.使用例
3.1.前準備
まず、こちらの記事を参考に、拡散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.拡散MRIのバイアス(信号ムラ)補正
以下のコマンドを実行する。-bias
オプションを指定することで、バイアスフィールドを出力することができる。
dwibiascorrect ants DWI.mif DWI_unbiased.mif -bias bias.mif
補正後の画像は、以下。
コメント投稿が上手くできていなかったようなので、再投稿します。(重複してしまっていましたら、申し訳ございません。)
お世話になっております。
dwibiascorrect のコマンド実行時に下記のエラーが発生しました。
環境はWSL2(Ubuntu 20.04.5 LTS)で、MRtrix3 バージョンは 3.0.4. (Anacondaでインストールしました)、ANTs のバージョンは 2.4.4.です。
user@DESKTOP: my/working/directory$ dwibiascorrect ants dwi.mif dwi_bc.mif
dwibiascorrect:
dwibiascorrect: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
dwibiascorrect:
dwibiascorrect: Generated scratch directory: /my/working/directory/dwibiascorrect-tmp-UDAIJL/
Command: mrconvert /my/working/directory/dwi.mif /my/working/directory/dwibiascorrect-tmp-UDAIJL/in.mif
dwibiascorrect: Changing to scratch directory (/my/working/directory/dwibiascorrect-tmp-UDAIJL/)
Command: dwi2mask in.mif mask.mif
Command: dwiextract in.mif – -bzero | mrmath – mean mean_bzero.mif -axis 3
Command: mrconvert mean_bzero.mif mean_bzero.nii -strides +1,+2,+3
Command: mrconvert mask.mif mask.nii -strides +1,+2,+3
Command: N4BiasFieldCorrection -d 3 -i mean_bzero.nii -w mask.nii -o [corrected.nii,init_bias.nii] -s 4 -b [100,3] -c [1000,0.0]
Command: mrcalc mean_bzero.mif mask.mif -mult – | mrmath – sum – -axis 0 | mrmath – sum – -axis 1 | mrmath – sum – -axis 2 | mrdump –
Command: mrcalc corrected.nii mask.mif -mult – | mrmath – sum – -axis 0 | mrmath – sum – -axis 1 | mrmath – sum – -axis 2 | mrdump –
dwibiascorrect: [ERROR] mrcalc corrected.nii mask.mif -mult – | mrmath – sum – -axis 0 | mrmath – sum – -axis 1 | mrmath – sum – -axis 2 | mrdump – (ants.py:80)
dwibiascorrect: [ERROR] Information from failed command:
dwibiascorrect:
mrcalc: computing: (corrected.nii * mask.mif)… [==================================================]
mrmath: computing sum along axis 0…
mrmath: [ERROR] error creating temporary file in directory “/my/working/directory/dwibiascorrect-tmp-UDAIJL/”: No such file or directory
mrmath: [ERROR] error creating image “-”
mrmath: [ERROR] no filename supplied to standard input (broken pipe?)
mrmath: [ERROR] error opening image “-”
mrdump: [ERROR] no filename supplied to standard input (broken pipe?)
mrdump: [ERROR] error opening image “-”
dwibiascorrect:
dwibiascorrect: [ERROR] For debugging, inspect contents of scratch directory: /my/working/directory/dwibiascorrect-tmp-UDAIJL/
dwibiascorrect: Scratch directory retained; location: /my/working/directory/dwibiascorrect-tmp-UDAIJL/
コマンド実行時のディレクトリ操作が原因のように見えるのですが、対処法がわからず苦慮しております。
解決策についてご教授頂けましたら幸いです。
宜しくお願い致します。
コメント失礼します。
dwibiascorrectのコマンドで下記のエラーが出現しました。
環境はWSL2(Ubuntu 20.04.5 LTS)で、
MRtrix3のバージョンは3.0.4. です。(Anaconda経由でインストールしました。)
ANTsのバージョンは 2.4.4.です。
コマンドおよびエラーログは下記のようになります:
user@DESKTOP: my/working/directory$ dwibiascorrect ants dwi.mif dwi_bc.mif
dwibiascorrect:
dwibiascorrect: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
dwibiascorrect:
dwibiascorrect: Generated scratch directory: /my/working/directory/dwibiascorrect-tmp-UDAIJL/
Command: mrconvert /my/working/directory/dwi.mif /my/working/directory/dwibiascorrect-tmp-UDAIJL/in.mif
dwibiascorrect: Changing to scratch directory (/my/working/directory/dwibiascorrect-tmp-UDAIJL/)
Command: dwi2mask in.mif mask.mif
Command: dwiextract in.mif – -bzero | mrmath – mean mean_bzero.mif -axis 3
Command: mrconvert mean_bzero.mif mean_bzero.nii -strides +1,+2,+3
Command: mrconvert mask.mif mask.nii -strides +1,+2,+3
Command: N4BiasFieldCorrection -d 3 -i mean_bzero.nii -w mask.nii -o [corrected.nii,init_bias.nii] -s 4 -b [100,3] -c [1000,0.0]
Command: mrcalc mean_bzero.mif mask.mif -mult – | mrmath – sum – -axis 0 | mrmath – sum – -axis 1 | mrmath – sum – -axis 2 | mrdump –
Command: mrcalc corrected.nii mask.mif -mult – | mrmath – sum – -axis 0 | mrmath – sum – -axis 1 | mrmath – sum – -axis 2 | mrdump –
dwibiascorrect: [ERROR] mrcalc corrected.nii mask.mif -mult – | mrmath – sum – -axis 0 | mrmath – sum – -axis 1 | mrmath – sum – -axis 2 | mrdump – (ants.py:80)
dwibiascorrect: [ERROR] Information from failed command:
dwibiascorrect:
mrcalc: computing: (corrected.nii * mask.mif)… [==================================================]
mrmath: computing sum along axis 0…
mrmath: [ERROR] error creating temporary file in directory “/my/working/directory/dwibiascorrect-tmp-UDAIJL/”: No such file or directory
mrmath: [ERROR] error creating image “-”
mrmath: [ERROR] no filename supplied to standard input (broken pipe?)
mrmath: [ERROR] error opening image “-”
mrdump: [ERROR] no filename supplied to standard input (broken pipe?)
mrdump: [ERROR] error opening image “-”
dwibiascorrect:
dwibiascorrect: [ERROR] For debugging, inspect contents of scratch directory: /my/working/directory/dwibiascorrect-tmp-UDAIJL/
dwibiascorrect: Scratch directory retained; location: /my/working/directory/dwibiascorrect-tmp-UDAIJL/
コマンド内でのディレクトリ操作が原因になっているように見えるのですが、どう対応すべきかわからず苦慮しております。
解決策についてご教授頂けましたら幸いです。宜しくお願い致します。
すみません、コメントがスパム判定されていて気づきませんでした。
確認させてください。
実際タイプしたコマンドは
だけということですよね?
ディレクトリ名に日本語が使われているということはないでしょうか?