MRIConvertにおけるNIfTIとFSL_NIfTIの違い (qformとsformの理解)

MRIConvertを使って、DICOM画像をNIFTI画像に変換しようとすると、FSL_NIfTIとNIfTIの2つのオプションがあることに気づきます。

MRIConvert_screenshot

この違いは何なのでしょうか?

Short Answer:
SPMで解析をするならば、どちらでもかまいません。ただ、どちらかに統一してください。FSLで解析をするならば、FSL_NIFTIを勧めます。

Long Answer:
これは、NIfTI画像のヘッダー情報に対しての多少の知識が必要です。

NIfTI画像には、ヘッダーの中に座標系の情報を保存するところが2箇所あります。
qformとsformというものです。

qformとsformの違いは、ものすごくシンプルに説明してしまうならば、
qform: MRIスキャナーから来る情報
sform: 画像ソフトで位置を変換した後の情報

のようにとらえるといいかもしれません。

もっと解説を知りたい人は、以下の2つのサイトをご覧ください。

ヘッダーのqformとsformを見る簡単な方法は、FSLをお使いの場合は、”fslhd”というコマンドで見ることができます。

で、MRIConvertでNIFTIとFSL_NIFTIを選んだ際、このqformに書き込まれる値が変わってきます。

MRIConvertのヘルプの中に”File formats”というものがあります。その内容を引用します。

NIfTI
NIfTI output is based on the most straightforward conversion of DICOM to NIfTI according to the NIfTI standard. Image data is not rewritten, and the image orientation relative to NIfTI’s standard RAS axes is given by the qform fields. You can expect axial images to be stored LPS. How they are displayed and interpreted will (as always) depend entirely on the software you use to read them, its assumption about data order, and its support (or lack thereof) for the qform information. Any software fully compliant with the NIfTI standard should be able to read these files and their orientations.

FSL/NIfTI
This is an output format specifically designed for use with FSL. It should be emphasized that this is a fully compliant NIfTI file, and not an FSL-specific variant. However, data order and some header fields have been modified to make use with FSL a bit smoother. Data is flipped top bottom, as in the Analyze 7.5 output, to avoid problems with FSL’s coordinate system. This will also result in a more intuitive view in FSLView and other FSL-generated reports. All transformations are accounted for in the qform fields. Also, the data type for unsigned 16 bit data has been changed to signed 16 bit, as FSL does not yet support the unsigned 16 bit data type. This should not be a problem for MRI data, as it uses only the lower 12 bits. Also, for Siemen’s diffusion images, bvals and bvecs files will be created automically. The values in these files will reflect any rotation of the image volume relative to the gradient coordinates, and will be correspond to the order of the data on disk.

ポイントは、FSL_NIfTIでは、

  • 上下がひっくり返る
  • 16bitのUnsignedデータが16bitのSignedデータに変わる

の2つです。後者はさほど影響がないので、前者が一番大きな変化があるところです。

試しに、ある3D-T1画像の矢状断を、MRIConvertで変換した後のqformとsformは以下のようになります。

  1. NIFTIオプションで変換した場合
  2. qform_name     Scanner Anat
    qform_code     1
    qto_xyz:1      0.046728  -0.019294  0.598874  -100.824997
    qto_xyz:2      -0.975481  0.000099  0.028700  162.692993
    qto_xyz:3      -0.001022  -0.976409  -0.011831  119.240997
    qto_xyz:4      0.000000  0.000000  0.000000  1.000000
    qform_xorient  Anterior-to-Posterior
    qform_yorient  Superior-to-Inferior
    qform_zorient  Left-to-Right
    sform_name     Unknown
    sform_code     0
    sto_xyz:1      0.000000  0.000000  0.000000  0.000000
    sto_xyz:2      0.000000  0.000000  0.000000  0.000000
    sto_xyz:3      0.000000  0.000000  0.000000  0.000000
    sto_xyz:4      0.000000  0.000000  0.000000  0.000000
    sform_xorient  Unknown
    sform_yorient  Unknown
    sform_zorient  Unknown
    file_type      NIFTI-1+
    file_code      1
    descrip        Ax FSPGR-IR 3DSag
    

    qformのxorient, yorient, zorientに注目してください。

    qform_xorient Anterior-to-Posterior
    qform_yorient Superior-to-Inferior
    qform_zorient Left-to-Right

    となっていますね。

    これを、FSLViewで表示すると、以下になります。

    subj1_NIFTI

    なんか変になっていますね。本当は、以下のような表示にしたいわけです。

    subj1_standard

    この場合の、qformは下記になっています。
    qform_xorient Left-to-Right
    qform_yorient Posterior-to-Anterior
    qform_zorient Inferior-to-Superior

    3つの画像を見ると理解が難しいので、ひとつに絞って考えます。
    FSLViewの左下の画面(標準では、水平断が表示される部分)に着目します。

    水平断で表示される軸はX軸とY軸です。

    標準画像では、

    qform_xorient Left-to-Right
    qform_yorient Posterior-to-Anterior

    となっています。これはRightが正の値、Anteriorが正の値という意味になります。
    X軸がプラス(今はプラスが画面の左側です)になればなるほど、脳のRightであり、Y軸がプラス(プラスが画面の上側です)になればなるほど、脳のAnteriorに行くということです。

    それが、上記のNIFTI画像では、

    qform_xorient Anterior-to-Posterior
    qform_yorient Superior-to-Inferior

    となっていますから、

    X軸方向が、プラスになればなるほど、脳のPosteriorになり、Y軸がプラスになればなるほど、脳のInferiorになるわけです。

    確かにそう言われれば、そのとおりになっていますね。

  3. FSL_NIFTIオプションで変換した場合
  4. それでは、FSL_NIFTIの場合は、どうなるでしょうか。
    その時の、ヘッダーは以下のようになります。

    qform_name     Scanner Anat
    qform_code     1
    qto_xyz:1      0.046642  0.019297  0.598877  -105.775185
    qto_xyz:2      -0.975485  -0.000097  0.028647  163.694595
    qto_xyz:3      -0.001018  0.976409  -0.011833  -130.693604
    qto_xyz:4      0.000000  0.000000  0.000000  1.000000
    qform_xorient  Anterior-to-Posterior
    qform_yorient  Inferior-to-Superior
    qform_zorient  Left-to-Right
    sform_name     Unknown
    sform_code     0
    sto_xyz:1      0.000000  0.000000  0.000000  0.000000
    sto_xyz:2      0.000000  0.000000  0.000000  0.000000
    sto_xyz:3      0.000000  0.000000  0.000000  0.000000
    sto_xyz:4      0.000000  0.000000  0.000000  0.000000
    sform_xorient  Unknown
    sform_yorient  Unknown
    sform_zorient  Unknown
    file_type      NIFTI-1+
    file_code      1
    descrip        Ax FSPGR-IR 3DSag
    

    qformについては、以下のようになっています。

    qform_xorient Anterior-to-Posterior
    qform_yorient Inferior-to-Superior
    qform_zorient Left-to-Right

    そして、画像は、以下のようになります。

    subj1_FSLNIFTI

    先ほどと同じように、左下の画面だけで考えると、
    qform_xorient Anterior-to-Posterior
    qform_yorient Inferior-to-Superior

    となり、X軸がプラスになると、脳のPosteriorの方向に、
    Y軸がプラスになると、脳のSuperiorの方向に

    となります。

    MRIConvertの説明にあるように、脳の上下がひっくり帰りましたね。

    つまり、これからわかることは、FSLViewは(sformの値がない場合は、)qformの値を見て、それに従って表示しているということになります。
    ちなみに、sformは今はすべて0です。その場合、sformは入っていないと判断されるとのことです。

  5. SPMの場合
  6. 同じ画像をSPM12で表示すると、下記のようになります。上側にNIFTIオプション、下側にFSL_NIFTIオプションで変換した画像を表示します。

    subj1_spm

    これからわかるように、どちらでも変わりません。なおかつ、標準脳の座標空間と同じになっています。

    SPMのメーリングリストで、John Ashburnerが以下のように発言しています。
    引用元はこちら

    When orientations are read, the sform is used in preference to the qform. If
    the sform is not specified, then the qform is used. If qform is not
    specified, then SPM assumes that images are stored axially and their
    left-right is determined by spm_flip_analyze_images.

    これから推察するに、SPMでは、sformなりqformをみる際に、そのOrientationを判断し、そして、標準空間で表示するわけです。

これは、どちらが優れているとかそういうものではなく、その裏側にある哲学の相違に過ぎません。
いずれにしろ、NIfTI画像のヘッダー情報に、画像のOrientationに関係するものとして、qformとsformというものがあり、種々のソフトウェアはその情報を元に画像を表示しているということがわかりました。
ちなみに、FSLで、標準脳と同じ空間で表示するには、fslreorient2stdというコマンドを使って一度変換してあげる必要があります。その方法は、別の記事(FSLViewで画像が正しい向きで表示されない時)にまとめてありますので、そちらをご覧ください。

Print Friendly, PDF & Email

3 thoughts on “MRIConvertにおけるNIfTIとFSL_NIfTIの違い (qformとsformの理解)

  1. ピングバック: 【FSL/MRtrix】 NIfTIヘッダーの確認

  2. Dear Sensei,
    I am a totally newbie in VBM research.
    I read all the すぐできる VBM book and it is really a very useful book for a freshman for me.
    Actually it took me more than 1 week to finnish the book cause my Japanese is very bad but I do appreciate this book very much.
    I tried on the sample data.
    However I met some trouble during using Anatomy toolbox.
    I already download the toolbox and copy the Anatomy folder into SPM12’s toolbox folder.
    When I try to run this Anatomy toolbox verson 2.0, error happens as below:

    Error using uicontrol
    While setting the ‘Max’ property of UIControl:
    Value must be numeric or logical.

    Error in spm_input_ui (line 1093)
    h = uicontrol(Finter,’Style’,’Pushbutton’,…

    Error in se_anatomy (line 838)
    xSPM(1).xVOL.orig = spm_input_ui(‘Coordinates’,’!+1′,’b’,’Anatomical|MNI’,[1
    2],2,’Select mode’); set(xF,’visible’,’on’),

    Error in se_anatomy (line 55)
    se_anatomy(‘init’,fg);

    Error while evaluating DestroyedObject Callback

    Then I tried with version1.8 as you present in your book but same thing happen.
    Would you mind helping me to solve this problem. I am now using SPM12 base on Matlab 2014b
    Once again, I am sorry for this disturbance. I would like to thank you very much if you can give me some advice.
    Finally, I am looking forward to hearing from you soon.
    Wish you all the best!
    Your sincerely,

    NGUYEN ANH
    From Tokyo Medical and Dental University

    • Dear Nguyen Anh,

      Thank you for your comment. I appreciate you read through すぐできるVBM.

      First of all, have you tried updating SPM12?

      From the Matlab command window, type the following;

      >> spm_update

      This will check if there is SPM update for you. If update exists, you can update easily with the following command;

      >> spm_update(1)

      Next, please check the order of the path.
      The path for Anatomy toolbox should be BELOW SPM12.
      From your error message, I suspect the path setting for Anatomy toolbox is ABOVE SPM12.

      Please let me know if these solve your problem.

kiyotaka へ返信するコメントをキャンセル

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください