How to calculate grey/white matter volume from segmented images

We can calculate grey/white matter volume from segmented images.
You need the following script and SPM plugin.

As of images, I recommend using the segmented image by VBM8. Note that you need to do modulation of the option “affine + non-linear (SPM8 default).” The grey matter image generated by VBM8 should look like mwrp1xxx.nii.

  1. Basic
  2. First, let’s get the total grey matter volume.

    Type the following from Matlab command window.

    get_totals

    The dialog pops out to choose images. Select the grey matter images you want to know the volume.

    Then, the volume appears in Matlab window.

    ans =
    739.8652

  3. Calculate regional volume
  4. By defining ROI mask, you can get the regional volume within mask.

    Here, we would like to get the GM volume of left hemisphere.

    Type the following in Matlab window.

    help get_totals

    You get the following message.

      get_totals – Returns image totals (sum over all voxels), in ml
    t = get_totals
    [t files] = get_totals(files, thr, msk)
    GUI file-selection is used if files not specified as argument (or empty).

    Point is get_totals(files, thr, msk). You can specify threshold or mask images. However, entering these files manually is annoying, so we specify [], which leads to pop up the GUI file selection dialogue.

    • prepare mask images
    • We make mask image using WFU PickAtlas. Start PickAtlas by selecting pickatlas from SPM8 toolbox.

      Now We would like to generate mask of lt. hemisphere. So We choose “TD Hemispheres” on the left panel of the window, and double-click Left Brainstem, Left Cerebellum, and Left Cereberum. These regions should be moved to the right panel (Working Region 1)

      Then click “SAVE MASK” and save mask image. I named it lt_hemisphere.nii.

      You can display mask image using SPM display function. Note that the voxel size of the mask is 2x2x2.

    • Change the voxel size of the mask image
    • As we saw in SPM Display, the voxel dimension of mas images generated by PickAtlas is 2x2x2. However, the voxel dimension of segmented image using DARTEL is 1.5×1.5×1.5. Since voxel dimension is different between two, we cannot do multiplication of the images. So we need to change the voxel size of the mask image. We use “Coregister (Reslice)” to achieve this.

      Select “Coregister (Reslice)” on SPM menu.

      coregister_reslice

      Then, a window like below appears.

      Specify grey matter image as “Image Defining Space.”
      Specify mask image as “Images to Reslice.”
      Set the Interpolation to Nearest neighbour so that the resliced mask remains binary.

      You can leave other parameters as default.

      reslice_settings

      Then you will get the new mask file with prefix “r”. This time the file should be rlt_hemisphere.nii.

      Display this file with SPM8 and this time the voxel size is -1.5 x 1.5 x 1.5.

    • Calculate GM volume of left hemisphere using get_totals
    • Now type the following in Matlab window.

      get_totals([],[],[])

      This will pop up the dialog to choose GM images.

      Next, another dialog pops up. This time select mask images, i.e., rlt_hemisphere.nii this time.

      Threshold is set to 0 if it is blank. If you want to calculate volumes with the signal >=0.1, you set 0.1 instead of [].

      Then, you’ll get the following in Matlab window.

      ans =
      350.6627

      We see the value is almost half of the total grey matter volume.

    That’s it. I thank Ged Ridgway for his advice.

    Print Friendly, PDF & Email

37 thoughts on “How to calculate grey/white matter volume from segmented images

  1. Dear Sensei,
    I would like to ask about the voxel size.
    My MRI originial photos are set at 1x1x1 mm voxel size
    However, I just figure out that after doing segmetation the voxel size are different for file ^c1, ^c2.. ( 1x1x1) and ^rc1 ang rc2 and u_rc1,u_rc2 (1.5 x 1.5x 1.5)
    There fore the template files becomes 1.5×1.5×1.5 after using those rc1 rc2 files to create template.

    In the next step of normalize to MNI we use both template_6.nii ( voxel size is `1.5 x1.5 x 1.5) and ^c1 files which are 1x1x1.

    I think it will cause uncorrect result.

    Would you please give me some suggestion for this problem?
    May I use the Coregister for Template and all 1.5 voxel size files to make it becom 1x1x1 mm size cause I want to analysis at 1mm size.

    I am looking forward to hearing from you soon.
    Thnk you very much.

    • Dear Sensei,
      Today I tried get_totals with a mask create by WFU Atlas.
      Unfortunately, I get an error like below:

      Error in get_totals (line 55)
      img = img .* msk;

      Get_totals work well when I calculate GMV or WMV.
      Would you please help me solve this problem?
      Thank you very much!

      your sincerely,

      Nguyen Anh

      • I am sorry the full error statement is:
        >> get_totals([],[],[])
        Error using .*
        Array dimensions must match for binary array op.

        Error in get_totals (line 55)
        img = img .* msk;

    • Dear Anh,

      When the segmented files (c1 or c2) are normalized, it will be resliced that the voxel size will be 1.5×1.5×1.5.
      So it will be no problem.

      • Dear Sensei,
        After normalizing, I got smw file but the voxel size is 1x 1 x1
        That’s why I am confusing cause my rc1 files are 1.5 x 1.5 x 1.5
        So far, I can not use the get_total script for calculating ROI GMV yet.
        I keep going error as I mentioned above.
        Is it because the voxel size is 1 x 1 x 1?
        I am looking for hearing from you soon.
        Thank you very much.
        Your sincerely,

        Nguyen Anh

        • Hi Anh,

          OK, there are two options for normalizing.
          1) Through segmentation. This is kind of low-dimensional warping. The file you get is this. the voxel size will be 1x1x1
          2) Through DARTEL.

          I think you got your normalized file with option 1.

          Anyway,below is what you can do.

          Through coregister -> reslice,

          image defining space: your smw file with voxel size 1x1x1
          images to reslice: your ROI file with (perhaps) voxel size 1.5×1.5×1.5

          Then you will get new ROI file beginning with r.

          You can use this file as a mask for get_totals.m

          Hope this helps,

          Kiyotaka

          • Dear Sensei,
            Thank you very much for your suggestion.
            Anyway, I checked and it was not because of voxel sized but due to the script get_totals.m.
            I fixed it and it worked. Now I can calculate ROI already.
            Wish you all the best.
            Your sincerely,

            Nguyen Anh

          • Dear Anh,

            Glad to know that it worked, but could you explain what you fixed?
            That might help others.

            Best regards,

            Kiyotaka

  2. Dear Kiyota sensei,
    Thank you very much for your precious book as well as your page.
    I can study VBM easily stick to your book.
    However, I have a question. When I use SPM: Tissue volumes to calculate GMV, WMV and TBV, the results are slightly different with what I use get_totals script.
    I read above comment that you mentioned which files we used.
    However I saw that SPM might accept only seg8.mat files. So, could you please explain a little bit more about this? And if so, which one we should use to calculate the volumes.
    One more little thing, would you mind inform me information for adding “get_totals” as my reference.
    Thank you very much !
    Yours sincerely,
    QUYNH ANH

    Tokyo Medical and Dental University

      • Dear Sensei,
        Thank you for your comment.
        I tried with get_totals for c1 and Tissue Volume for seg8.mat file.
        However the results are 0.6073 and 0.6062, a little different.
        So, I am wondering which one is better.
        Yours Sincerely,
        Nguyen Anh

        • Personally, I prefer Tissue volume for seg8.mat file.
          I think you saved modulated file in the segmentation process.
          If you did so, Tissue volume calculation use modulation image, that can be a little different from get_totals for c1.

          However, as you see, the difference is so small, so you may choose whichever you like. The point is once you choose, stick to it.

          Hope this helps,

          Kiyotaka

          • Dear Sensei,
            Thank you very much for your reply.
            I understand now.
            Wish you all the best.
            Yours sincerely,
            Nguyen Anh

          • I understand now.
            Thank you very much as always.
            Your sincerely,
            Nguyen Anh

  3. Quick question- when I use VBM8 and calculate the raw volumes I get very different grey and white matter volumes than I get when I use the get total script for the same data. Can you let me know why?

    • Thank you for the question.
      It depends on which image you specify.

      If you specify m0wp1*.nii, the results will be different.
      If you specify mwp1*.nii, the results should be the same.

      It is due to the different approach for modulation.
      “m0” means modulation using non-linear paramater only, so it includes TBV adjustment.
      “m” means classical SPM modulation, which should preserve absolute volume.

      Hope this helps,

      Kiyotaka

  4. Dear KIyotaka
    If I use new segment of Spm which images should I use.
    rc1 or c1..Can I use smwc1 images as well.
    Thanks
    Regards

  5. Dear Kiyotaka,

    My test subjects are all health control subjects.
    It seems that I have to find other ways to analysis GM volumes.

    thanks for your suggestions.
    best regards!

    joke

    • Dear Joke,

      Instead of VBM8, you can try New Segment in SPM8 or SPM12.
      Values can be different, so it’s worth trying.

      Best regards,

      Kiyotaka

      • Dear Kiyotaka,

        Is the subject you analysis in this article a young health people ?

        I think the reason why our results are different maybe is the age of subjects are different .
        Old person’s total GMV is smaller than young person, right ?

        what do you think ?
        best regards

        joke

        • Dear Joke,

          You’re right. The example is young subject.
          I checked the result of an old subject (MCI subject), and the GMV was only 420ml.

          So I agree that your result is affected by aging factor.

          Best regards,

          Kiyotaka

  6. Dear Kiyotaka,

    The segmented image by VBM8 in your article, is the one processed after First Module: “Estimate and write” in VBM8. Does it need some normalisation or smoothing after “Estimate and write” ?

    I used your method to calculate total GM of my images, the result seems a little small, only 648.0975 to a man.

    Hope to get your advice
    Best regards !

    JOKE

    • Dear JOKE,

      If you use VBM8, you should find a text file after preprocessing.
      That includes 3 values which corresponds to GM, WM, CSF.
      What value does your text file say?

      Best regards,

      Kiyotaka

      • Dear Kiyotaka,

        I read that text file. the values is 525.980, 505.195, 394.586.
        it’s less than the value calculated by get_totals.

        It looks very strange, right ?

        Best regards,
        joke

        • Dear Kiyotaka,

          I have been waiting for your suggestion
          and I read this article many times but can’t find what I mistakes are.

          My workflow is:
          1. download row sMRI from ADNI site
          2. convert DICOM to nii by using MRIcron
          3. segment image by “Estimate and write” in VBM8, and get mwrp1xxx.nii
          4. using gettotals script to calculate total GM volume

          I used some subjects to try this method, and all their total GM volumes are under 600.
          what exactly am I doing wrong?
          please help me !

          thanks
          joke

          • Dear JOKE,

            Your workflow seems fine to me.
            When you say ADNI data, is it control subjects or AD subjects?

            Other than that, I’m not sure what causes this phenomenon.

            Best regards,

            Kiyotaka

  7. Dear Kiyotaka

    Thanks for your sharing, It’s much useful for me.
    This time, I have another question and hope to get your advice.

    Do raw MRIs need some pre-processing(e.g. b1 correction, N3, scaled) before segmented by VBM8 ?

    I downloaded two MRI from ADNI, one is pre-processing image(i.e. gradwarp, B1 correction, N3 and scaled), another is raw image.
    and then, I calculate their total GM volume, the result is different.
    Which one is more accurate?

    Best regards
    Joke

    • Dear Joke,

      In my opinion, preprocessing is preferred for multi-site data such as ADNI.
      As of inhomogeneity correction, bias correction of SPM is as good as N3 now, so it doesn’t affect the result so much.
      However, geometric distortion will affect much since the brain shape can be changed. You can see some examples in ADNI site.

      So it’s natural you get the different results using raw data and preprocessed data. I think preprocessed data would be more accurate.

      Best regards,

      Kiyotaka

  8. Dear Kiyotaka

    Hi, I am a freshman.

    I have some problem about your example

    I saw you calulate the gray matter volume of whole brain is 739.8652

    it seems a little small, and there is a question.

    to a normal person, how much should the normal value be?

    • Hi Joke,

      There are several studies which investigated the whole gray matter volume of healthy subjects.
      One example is http://www.genling.nw.ru/Staff/Psycholinguistics/Brain%20Size.pdf

      According to the article, Lueders reported the gray matter volume as follows;
      (They employ VBM using SPM99)

      male: 0.82±0.06; range 0.71-0.98 dm^3
      female: 0.74±0.06; range 0.61-0.86 dm^3

      so 740ml, which is 0.74 dm^3 is within normal range I think.

      Hope this hleps,

      Kiyotaka

  9. Dear Kiyotaka,

    Thanks for your reply. sorry for these simple and basic questions I am new to VBM .I want to compare the volume of hippocampus by using two different methods (manual tracing and atlas based method using VBM and WFU-Pickatlas) I did step by step according to your blog article. I used Human Atlas : TD brodman areas + TD lobes I do not know whether it is ALL atlas or not. The only difference was that when I coregistered my ROI image(hippocampus) I used mwrp1xxx.nii as ” image defining space” instead of using mwc1xx.nii . as an example one of my result was 0.0525 and in comparison with my manual tracing result it was very small. Maybe I am missing some steps.

    could you please give me some advise to get the correct result?

    best regards
    mahsa,

    • Dear Mahsa,

      Hippocampus ROI of TD brodmann areas are pretty small. If you calculate the volume of e.g. lt Hippocampus of TD brodmann areas, the result is only 1112mm^3, which is only 1.1ml. This is very small which can explain why your result is very small.
      If you select Hippocampus ROI from AAL, the left hippocampal volume of mask is around 7ml. So different atlas can produce totally different results. Your method sounds right, so look at ROI carefully and select one which covers your intended regions. If you are not so sure, Try the following

      Human Atlas -> aal -> Hippocampus_L or R
      Human Atlas -> IBASPM71 -> hippocampal formation left or right
      Human Atlas -> IBASPM116 -> Hippocampus_L or R

      Hope this helps,

      Kiyotaka

  10. hi ,
    can we you this method to calculate hippocmpus volume? I tried using VBM and WFU pickatlas but unfortunately the results were strange and now I am not sure whether it is a reliable method for calculating hippocampal volume?

    thanks in avdance
    best regards

    mahsa,

    • Dear Mahsa,

      It depends on what ROI you use. If you use AAL atlas, hippocampal ROI is too large, so the result might be strange.
      You gonna check how accurate the ROI is by visually checking ROI using PickAtlas.

コメントを残す

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