-
Notifications
You must be signed in to change notification settings - Fork 1
/
MA_load_mask.m
41 lines (37 loc) · 1.23 KB
/
MA_load_mask.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function [M m_dim m_ind] = MA_load_mask(SPM)
% _
% Load Mask from General Linear Model
% FORMAT [M m_dim m_ind] = MA_load_mask(SPM)
%
% SPM - a structure specifying an estimated GLM
%
% M - a 1 x V mask vector (V: number of voxels)
% m_dim - a 1 x 3 vector indicating mask dimensions
% m_ind - a 1 x v vector indicating in-mask voxels
%
% FORMAT [M m_dim m_ind] = MA_load_mask(SPM) loads the mask image belonging
% to the GLM specified by SPM and returns the mask, its dimensions and
% indices of all in-mask voxels.
%
% Author: Joram Soch, BCCN Berlin
% E-Mail: [email protected]
%
% First edit: 24/10/2014, 18:20 (V0.2/V6)
% Last edit: 01/12/2017, 01:40 (V1.1/V17)
% Init progress bar
%-------------------------------------------------------------------------%
Finter = spm('FigName','MA_load_mask: load');
% Change directory
%-------------------------------------------------------------------------%
try
cd(SPM.swd);
catch
SPM.swd = pwd;
end
% Load mask image
%-------------------------------------------------------------------------%
m_dim = SPM.VM.dim;
m_img = spm_read_vols(SPM.VM);
m_img = reshape(m_img,[1 prod(m_dim)]);
m_ind = find(m_img~=0);
M = m_img;