A Matlab script to generate ROI masks using an Atlas in SPM12

SPM12 introduces some useful functions such as spm_atlas or new atlas “labels_Neuromorphometrics.” We find the description about labels_Neuromorphometrics in SPM12 Release note.

Maximum probability tissue labels derived from the “MICCAI 2012 Grand Challenge and Workshop on Multi-Atlas Labeling” are available in files tpm/labels Neuromorphometrics.{nii,xml}. These
data were released under the Creative Commons Attribution-NonCommercial (CC BY-NC) with no end date. Users should credit the MRI scans as originating from the OASIS project and the labeled
data as “provided by Neuromorphometrics, Inc. under academic subscription”. These references should be included in all workshop and final publications. See spm templates.man for more details about the generation of this file.

I wanted to generate masks of some regions using this labels_Neuromorphometrics.

Below is the tiny script which generates masks from your preferred atlas.
Running script brings up a file selector. You can choose any atlas you want.
Then it brings up another dialog which lists the region within the atlas. You can choose as many regions as you want, and the scripts generates masks whose file name is the name of the regions.


%generate_masks_from_atlas.m
%This script generate mask files from any atlases you prefer.
%K. Nemoto 25 April 2015

xA=spm_atlas('load');
S=spm_atlas('select',xA);

for i = 1:size(S,2)
    fname=strcat(S{i},'.nii');
    VM=spm_atlas('mask',xA,S{i});
    VM.fname=fname;
    spm_write_vol(VM,spm_read_vols(VM));
end

Download generate_masks_from_atlas.m (right click and save as)

Print Friendly, PDF & Email

5 thoughts on “A Matlab script to generate ROI masks using an Atlas in SPM12

  1. Dear Sensei,
    Thank you very much for your replying as always.
    I follow your instruction and I can see the results in ROI.
    However, I would like to ask if it is better to conduct a separate analysis for ROI such as calculating GMV in ROI, then apply the two sample t-test comparing GMV in that ROI between 2 groups to correct for multiple comparisons when we compare for the total GMV between 2 groups?
    Thank you very much!
    Your sincerely,

    Nguyen Anh

    • Hi Anh,

      Okay, I suggest doing the following.

      1. Calculate total brain volume (TBV; GM+WM) or intra-cranial volume (ICV; GM+WM+CSV)
      2. Calculate GM volume in your ROI.
      3. With your stat software (SPSS, R, or any kind), perform 2-sample t-test of GM volume in ROI with TBV or ICV as a covariate.

      That’s what people usually do with their ROI analysis.

      Hope this helps,

      Kiyotaka

      • Dear Sensei,
        Thank you very much !
        I understand that flow to do the ROI analysis.
        Wish you all the best.
        Your sincerely,

        Nguyen Anh

  2. Dear Sensei,
    Sorry for disturbing you again.
    I would like to ask how can we apply ROI analysis in VBM study.
    Could you please explain a bit more detail about which step we should apply the above script.
    As I understadn that, I will use the script to generate the ROI mask for the areas I interested in.
    Then during analysing, instead of using the opthro.nii file generated from normal ” masking” in tool box, I will have to use the ROI masking file and continue other step as normal.
    Sorry if this question is a bit stupid but I am really confusing about ROI analysing in SPM 12.
    Thank you very much
    Your sincerely,

    Anh

    • Hi,

      You don’t need to use masking toolbox.

      Below is what you need to do.

      1. Prepare your ROI.
      2. Results -> Select SPM.mat
      3. Select contrast
      4. Now you’re asked ‘apply masking’
      Here you choose ‘image’
      5. Select ROI image you want to use
      6. nature of mask will be ‘inclusive’
      7. Set statistical threshold (either FWE or none)
      8. Set extent threshold

      Then you will see the results limited in the ROI.

      Hope this helps,
      Kiyotaka

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

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