|
13 | 13 | % OUTPUT
|
14 | 14 | % A single file is generated, msk_BrainParts.nii, with 4 different volumes
|
15 | 15 | % covering the brain:
|
16 |
| -% - cortex without WM, |
17 |
| -% - cortex with WM, |
18 |
| -% - subcortex (pons + basal ganglia), and |
19 |
| -% - cerebellum. |
| 16 | +% 1. cortex without WM, |
| 17 | +% 2. cortex with WM, |
| 18 | +% 3. subcortex (Basal Ganglia, Amygdala, brainstem), |
| 19 | +% 4. cerebellum. |
| 20 | +% 5. subcortex without the Basal Ganglia |
| 21 | +% 6. Basal Ganglia only (pallidum, caudate, putamen, nucleaus accumbens, |
| 22 | +% thamus proper) |
20 | 23 | %
|
21 | 24 | % NOTE
|
22 |
| -% The mask generated include *both* GM ande WM! It is up to the user to |
23 |
| -% also provide a segmented GM or WM map, e.g. c1*.nii and c2*.nii, in order |
24 |
| -% to decide which tissue type to work with. |
25 |
| -% |
| 25 | +% For an individual subject, the masks generated likely include *both* GM |
| 26 | +% and WM voxels! |
| 27 | +% It is up to the user to also provide a segmented GM or WM map, e.g. |
| 28 | +% wc1*.nii and wc2*.nii images, in order to specific voxel values in the |
| 29 | +% brain part(s) of interest. |
26 | 30 | %_______________________________________________________________________
|
27 | 31 | % Copyright (C) 2017 Cyclotron Research Centre
|
28 | 32 |
|
29 | 33 | % Written by C. Phillips.
|
30 | 34 | % Cyclotron Research Centre, University of Liege, Belgium
|
31 | 35 |
|
32 |
| -%% DEFINE a few filenames |
| 36 | +%% DEFINE a few filenames & parameters |
33 | 37 | fn_atlas = 'labels_Neuromorphometrics.nii';
|
34 | 38 | fn_parts = 'msk_BrainParts.nii';
|
35 | 39 | dr_TPM = fullfile(spm('dir'),'tpm'); % SPM's tpm folder
|
36 | 40 | dr_TPMuswl = fullfile(spm_file(which('tbx_cfg_USwLesion.m'),'path'), ...
|
37 | 41 | 'eTPM'); % USwL's eTPM folder
|
38 | 42 | mask_smoothing = 4*ones(1,3); % in mm
|
39 | 43 | sval_thr = .1; % threshold for smoothed volume
|
| 44 | +nVols = 6; |
40 | 45 |
|
41 | 46 | %% LOAD the atlas
|
42 | 47 | Vatlas = spm_vol(fullfile(dr_TPM,fn_atlas));
|
|
59 | 64 | sval_cort_wWM = zeros(SZ);
|
60 | 65 | spm_smooth(val_cort_wWM,sval_cort_wWM,mask_smoothing./vx_sz); % extend a bit by smoothing
|
61 | 66 |
|
62 |
| -%% SUBCORTICAL part |
| 67 | +%% SUBCORTICAL part: Basal Ganglial, Amygdala, brainstem,... |
63 | 68 | l_rois = [ 23 30 31 32 35 36 37 47 48 55 56 57 58 59 60 61 62 75 76 ];
|
64 | 69 | val_subc = zeros(SZ);
|
65 | 70 | sval_subc = zeros(SZ);
|
|
82 | 87 | end
|
83 | 88 | spm_smooth(val_cereb,sval_cereb,mask_smoothing./vx_sz); % extend a bit by smoothing
|
84 | 89 |
|
| 90 | +%% SUBCORTICAL part, without Basal Ganglia |
| 91 | +l_rois = [ 31 32 35 47 48 61 62 75 76 ]; |
| 92 | +val_subc_woBG = zeros(SZ); |
| 93 | +sval_subc_woBG = zeros(SZ); |
| 94 | +for ii=l_rois |
| 95 | + val_subc_woBG = val_subc_woBG + double(val_atl == ii); |
| 96 | +end |
| 97 | +spm_smooth(val_subc_woBG,sval_subc_woBG,mask_smoothing./vx_sz); % extend a bit by smoothing |
| 98 | + |
| 99 | +%% SUBCORTICAL part, Basal Ganglia only |
| 100 | +% BG area includes these bits |
| 101 | +% - pallidum, #55 and #56 |
| 102 | +% - caudate, #36 and #37 |
| 103 | +% - putamen, #57 and #58 |
| 104 | +% - nucleaus accumbens, #23 and #30 |
| 105 | +% - thamus proper, #59 and #60 |
| 106 | +l_rois = [55 56 36 37 57 58 23 30 59 60]; |
| 107 | +val_subc_BG = zeros(SZ); |
| 108 | +sval_subc_BG = zeros(SZ); |
| 109 | +for ii=l_rois |
| 110 | + val_subc_BG = val_subc_BG + double(val_atl == ii); |
| 111 | +end |
| 112 | +spm_smooth(val_subc_BG,sval_subc_BG,mask_smoothing./vx_sz); % extend a bit by smoothing |
| 113 | + |
85 | 114 | %% Build the 4D volume
|
86 | 115 | % Keep a voxel in a mask if sval>.1 and larger than the other 2
|
87 |
| -val_parts = zeros([SZ 3]); |
| 116 | +val_parts = zeros([SZ nVols]); |
88 | 117 | val_parts(:,:,:,1) = sval_cort>sval_thr & ...
|
89 | 118 | sval_cort>sval_cereb & sval_cort>sval_subc; % -> cortical part
|
90 | 119 | val_parts(:,:,:,3) = sval_subc>sval_thr & ...
|
91 |
| - sval_subc>sval_cereb & sval_subc>sval_cort; % -> sub-cortical part |
| 120 | + sval_subc>=sval_cereb & sval_subc>=sval_cort; % -> sub-cortical part |
92 | 121 | val_parts(:,:,:,4) = sval_cereb>sval_thr & ...
|
93 |
| - sval_cereb>sval_cort & sval_cereb>sval_subc; % -> cerebellum part |
| 122 | + sval_cereb>=sval_cort & sval_cereb>=sval_subc; % -> cerebellum part |
94 | 123 |
|
| 124 | +% Keep a voxel if sval>.1 and not part of cerebelum or sub-cortex |
95 | 125 | val_parts(:,:,:,2) = sval_cort_wWM>sval_thr & ...
|
96 |
| - ~val_parts(:,:,:,3) & ~val_parts(:,:,:,3); % -> cortical part with WM |
| 126 | + ~val_parts(:,:,:,3) & ~val_parts(:,:,:,4); % -> cortical part with WM |
| 127 | + |
| 128 | +% Keep a voxel if sval>.1 and in sub-cortex but not in the other one |
| 129 | +val_parts(:,:,:,5) = val_subc_woBG>sval_thr & ... |
| 130 | + val_subc_woBG>=val_subc_BG & val_parts(:,:,:,3); % -> sub-cortical wo BG |
| 131 | +val_parts(:,:,:,6) = val_subc_BG>sval_thr & ... |
| 132 | + val_subc_BG>=val_subc_woBG & val_parts(:,:,:,3); % -> BG only |
97 | 133 |
|
98 | 134 | %% save the 4D volume
|
99 | 135 | fn_mask = fullfile(dr_TPMuswl,fn_parts);
|
100 | 136 | % assuming that Vatlas is a uint8 file -> 1 voxel = 1 byte
|
101 | 137 | descrip = {'Cotical GM mask', 'Cotical GM+WM mask', ...
|
102 |
| - 'Subcortical GM mask','Cerebellar GM mask'}; |
103 |
| -for ii=1:4 |
| 138 | + 'Subcortical GM mask','Cerebellar GM mask', ... |
| 139 | + 'Subcortical wo BG GM mask', 'Basal Ganglia GM mask'}; |
| 140 | +for ii=1:nVols |
104 | 141 | V_mask(ii) = Vatlas; %#ok<*SAGROW>
|
105 | 142 | V_mask(ii).pinfo(1) = 1/255;
|
106 | 143 | V_mask(ii).pinfo(3) = V_mask(ii).pinfo(3) + (ii-1)*prod(SZ);
|
|
0 commit comments