Skip to content

Commit 83d3582

Browse files
Updates brain parts masks
Adding the "subcortex wo BG" (#5) and "BG only" (#6) masks Fixing small error in other mak generation.
1 parent 2a3f7d0 commit 83d3582

File tree

2 files changed

+53
-16
lines changed

2 files changed

+53
-16
lines changed

eTPM/generate_corticalMask.m

+53-16
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,35 @@
1313
% OUTPUT
1414
% A single file is generated, msk_BrainParts.nii, with 4 different volumes
1515
% 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)
2023
%
2124
% 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.
2630
%_______________________________________________________________________
2731
% Copyright (C) 2017 Cyclotron Research Centre
2832

2933
% Written by C. Phillips.
3034
% Cyclotron Research Centre, University of Liege, Belgium
3135

32-
%% DEFINE a few filenames
36+
%% DEFINE a few filenames & parameters
3337
fn_atlas = 'labels_Neuromorphometrics.nii';
3438
fn_parts = 'msk_BrainParts.nii';
3539
dr_TPM = fullfile(spm('dir'),'tpm'); % SPM's tpm folder
3640
dr_TPMuswl = fullfile(spm_file(which('tbx_cfg_USwLesion.m'),'path'), ...
3741
'eTPM'); % USwL's eTPM folder
3842
mask_smoothing = 4*ones(1,3); % in mm
3943
sval_thr = .1; % threshold for smoothed volume
44+
nVols = 6;
4045

4146
%% LOAD the atlas
4247
Vatlas = spm_vol(fullfile(dr_TPM,fn_atlas));
@@ -59,7 +64,7 @@
5964
sval_cort_wWM = zeros(SZ);
6065
spm_smooth(val_cort_wWM,sval_cort_wWM,mask_smoothing./vx_sz); % extend a bit by smoothing
6166

62-
%% SUBCORTICAL part
67+
%% SUBCORTICAL part: Basal Ganglial, Amygdala, brainstem,...
6368
l_rois = [ 23 30 31 32 35 36 37 47 48 55 56 57 58 59 60 61 62 75 76 ];
6469
val_subc = zeros(SZ);
6570
sval_subc = zeros(SZ);
@@ -82,25 +87,57 @@
8287
end
8388
spm_smooth(val_cereb,sval_cereb,mask_smoothing./vx_sz); % extend a bit by smoothing
8489

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+
85114
%% Build the 4D volume
86115
% 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]);
88117
val_parts(:,:,:,1) = sval_cort>sval_thr & ...
89118
sval_cort>sval_cereb & sval_cort>sval_subc; % -> cortical part
90119
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
92121
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
94123

124+
% Keep a voxel if sval>.1 and not part of cerebelum or sub-cortex
95125
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
97133

98134
%% save the 4D volume
99135
fn_mask = fullfile(dr_TPMuswl,fn_parts);
100136
% assuming that Vatlas is a uint8 file -> 1 voxel = 1 byte
101137
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
104141
V_mask(ii) = Vatlas; %#ok<*SAGROW>
105142
V_mask(ii).pinfo(1) = 1/255;
106143
V_mask(ii).pinfo(3) = V_mask(ii).pinfo(3) + (ii-1)*prod(SZ);

eTPM/msk_BrainParts.nii

4.05 MB
Binary file not shown.

0 commit comments

Comments
 (0)