首页 > 解决方案 > 使用 SPM 进行脑干分割

问题描述

我是 SPM 和 Matlab 的新手。我已经安装了 SPM12,带有 Matlab 版本(2019b)。除此之外,我正在使用 CAT 工具箱。我试图从 T1 加权 MPRAGE 图像中掩盖脑干。下面,您可以找到代码。

    spm;
    cat12 expert;
    % structural mri data to be normalized and brainstem masked
    % note: the same mask might be applied to co-registered mri data
    mri_input_data  ={'D:/CourseMaterials/DZNE/tryingcat_onceagain/MPRAGE/CEK769_0003_dzne_MPRAGE_1iso_PAT2.nii,1'};
    matlabbatch{1}.spm.tools.cat.estwrite.data = mri_input_data;
    matlabbatch{1}.spm.tools.cat.estwrite.data_wmh = {''};
    matlabbatch{1}.spm.tools.cat.estwrite.nproc = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.useprior = '';
    matlabbatch{1}.spm.tools.cat.estwrite.opts.tpm = {'D:/softwares/spm12/tpm/TPM.nii'};
    matlabbatch{1}.spm.tools.cat.estwrite.opts.affreg = 'mni';
    matlabbatch{1}.spm.tools.cat.estwrite.opts.biasstr = 0.5;
    matlabbatch{1}.spm.tools.cat.estwrite.opts.accstr = 0.5;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.restypes.optimal = [1 0.1];
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.setCOM = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.APP = 1070;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.affmod = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.NCstr = -Inf;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.spm_kamap = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.LASstr = 0.5;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.gcutstr = 2;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.cleanupstr = 0.5;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.BVCstr = 0.5;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.WMHC = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.SLC = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.segmentation.mrf = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.registration.regmethod.shooting.shootingtpm = {'D:/softwares/spm12/toolbox/cat12/templates_volumes/Template_0_IXI555_MNI152_GS.nii'};
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.registration.regmethod.shooting.regstr = 0.5;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.registration.vox = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.pbtres = 0.5;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.pbtmethod = 'pbt2x';
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.pbtlas = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.collcorr = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.reduce_mesh = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.vdist = 1.33333333333333;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.scale_cortex = 0.7;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.add_parahipp = 0.1;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.surface.close_parahipp = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.admin.experimental = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.admin.new_release = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.admin.lazy = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.admin.ignoreErrors = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.admin.verb = 2;
    matlabbatch{1}.spm.tools.cat.estwrite.extopts.admin.print = 2;
    matlabbatch{1}.spm.tools.cat.estwrite.output.surface = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.surf_measures = 1;
    % these are the atlasses which also could be used
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.neuromorphometrics = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.lpba40 = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.cobra = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.hammers = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.ibsr = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.aal3 = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.mori = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.anatomy3 = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.julichbrain = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_100Parcels_17Networks_order = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_200Parcels_17Networks_order = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_400Parcels_17Networks_order = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.Schaefer2018_600Parcels_17Networks_order = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ROImenu.atlases.ownatlas = {''};
    matlabbatch{1}.spm.tools.cat.estwrite.output.GM.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.GM.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.GM.mod = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.GM.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.WM.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.WM.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.WM.mod = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.WM.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.mod = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.CSF.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ct.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ct.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.ct.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.pp.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.pp.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.pp.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.WMH.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.WMH.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.WMH.mod = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.WMH.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.SL.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.SL.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.SL.mod = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.SL.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.mod = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.TPMC.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.atlas.native = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.atlas.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.atlas.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.label.native = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.label.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.label.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.labelnative = 1;
    matlabbatch{1}.spm.tools.cat.estwrite.output.bias.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.bias.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.bias.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.las.native = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.las.warped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.las.dartel = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.jacobianwarped = 0;
    matlabbatch{1}.spm.tools.cat.estwrite.output.warps = [0 0];
    matlabbatch{1}.spm.tools.cat.estwrite.output.rmat = 0;
    
    spm_jobman('run',matlabbatch);
     
    % include numbers of ROIs for cat's atlas provided in a0 images
    cat.extopts.LAB.NB =  0; % no brain 
    cat.extopts.LAB.CT =  1; % cortex
    cat.extopts.LAB.CB =  3; % Cerebellum
    cat.extopts.LAB.BG =  5; % BasalGanglia 
    cat.extopts.LAB.BV =  7; % Blood Vessels
    cat.extopts.LAB.TH =  9; % Hypothalamus (its not)
    cat.extopts.LAB.ON = 11; % Optical Nerve
    cat.extopts.LAB.MB = 13; % MidBrain
    cat.extopts.LAB.BS = 13; % BrainStem
    cat.extopts.LAB.VT = 15; % Ventricle
    cat.extopts.LAB.NV = 17; % no Ventricle
    cat.extopts.LAB.HC = 19; % Hippocampus 
    cat.extopts.LAB.HD = 21; % Head
    cat.extopts.LAB.HI = 23; % WM hyperintensities
    cat.extopts.LAB.PH = 25; % Gyrus parahippocampalis
    cat.extopts.LAB.LE = 27; % lesions
     
    % this is the rois included from the atlas 
    ind_ROI = [13,5,9];
    ind_ROI = union(ind_ROI,ind_ROI+1);
     
    % lets loop over images files 
    for i=1:numel(mri_input_data)
        
    
        % get the structural image
        structural = mri_input_data{i};
        [p,f,e]    = fileparts(structural);
            
    
        % get atlas in native space
        atlas = fullfile(p,'mri',['a0' f '.nii']);
        a0 = spm_data_read(atlas); 
        
    
        % create a duplicate image with same intensities in ROI
        hdr0       = spm_vol(structural);
        hdr1       = hdr0;
        hdr1.fname = fullfile(p,'mri',[f '_masked.nii']);
        vol0 = spm_data_read(structural);
        vol1 = zeros(size(vol0));
         
    
        % loop around and mask out
        for roi=1:numel(ind_ROI)
            ind=find(a0==ind_ROI(roi));
            mask = zeros(size(vol0));
            mask(ind)=1;
            for j=1:2
            mask=cat_vol_morph(mask,'d');
            end
            %spm_smooth(mask,mask,[1,1,1]);
            %vol1(mask>0)=vol0(mask>0);
            tmp=vol0.*mask;
            vol1(mask>0)=tmp(mask>0);
        end
        
    
        % write masked image 
        spm_data_write(hdr1,vol1);
     
    end

我遇到的错误如下:

Item segmentation: No field(s) named
setCOM
affmod
Item registration: No field(s) named
regmethod
vox
Error using spm_jobman>fill_run_job (line 472)

没有可执行模块,但仍然存在未解决的依赖关系或不完整的模块输入。

    Error in spm_jobman (line 247)
            sts = fill_run_job('run', cjob, varargin{3:end});
    
    Error in seg_cat (line 114)
    spm_jobman('run',matlabbatch);
     
    472     error('spm:spm_jobman:jobNotFilled', 'No executable modules, but still unresolved dependencies or incomplete module inputs.');
    Your version of CAT12 is up to date.

当我运行我的代码时,我遇到了这些错误。请帮忙!

标签: matlab-spm

解决方案


推荐阅读