forked from JoramSoch/MACS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMA_load_data.m
51 lines (45 loc) · 1.56 KB
/
MA_load_data.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
42
43
44
45
46
47
48
49
50
51
function Y = MA_load_data(SPM, m_ind)
% _
% Load Data from General Linear Model
% FORMAT Y = MA_load_data(SPM, m_ind)
%
% SPM - a structure specifying an estimated GLM
% m_ind - a 1 x v vector indexing in-mask voxels
%
% Y - an n x v data matrix (n: scans; v: voxels)
%
% FORMAT Y = MA_load_data(SPM, m_ind) loads only in-mask time series
% belonging to the GLM specified by SPM and returns a data matrix.
%
% Author: Joram Soch, BCCN Berlin
% E-Mail: joram.soch@bccn-berlin.de
%
% First edit: 24/10/2014, 18:30 (V0.2/V6)
% Last edit: 08/08/2017, 15:10 (V1.1/V17)
% Load mask if necessary
%-------------------------------------------------------------------------%
if nargin < 2 || isempty(m_ind)
[M m_dim m_ind] = MA_load_mask(SPM);
end;
clear M m_dim
% Get data dimensions
%-------------------------------------------------------------------------%
n = length(SPM.xY.VY);
v = numel(m_ind);
d = ceil(n/100);
% Init progress bar
%-------------------------------------------------------------------------%
Finter = spm('FigName','MA_load_data: load');
spm_progress_bar('Init',100,'Load in-mask time series...','');
% Load time series
%-------------------------------------------------------------------------%
Y = zeros(n,v);
for i = 1:n
y_img = spm_read_vols(SPM.xY.VY(i));
Y(i,:) = y_img(m_ind);
if mod(i,d) == 0, spm_progress_bar('Set',(i/n)*100); end;
end;
clear y_img
% Clear progress bar
%-------------------------------------------------------------------------%
spm_progress_bar('Clear');