-
Notifications
You must be signed in to change notification settings - Fork 7
/
swe_data_write.m
45 lines (43 loc) · 1.31 KB
/
swe_data_write.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
function V = swe_data_write(V, Y, varargin)
% Write data to disk [V(I) = Y]
% FORMAT V = swe_data_write(V,Y)
% V - a structure array (see swe_data_hdr_read)
% Y - an array of data values
%
% FORMAT V = swe_data_write(V,Y,I)
% V - a structure array (see swe_data_hdr_read)
% Y - an array of data values
% I - linear index to data values
% =========================================================================
% Bryan Guillaume
% Version Info: $Format:%ci$ $Format:%h$
if isfield(V,'private')
cl = class(V.private);
elseif isfield(V,'dat')
cl = 'struct';
else
error('Unkwown data type.');
end
if strcmpi(cl, 'swe_cifti')
if isempty(varargin)
V.private.dat = subsasgn(V.private.dat, substruct('()',{':'}), Y);
else
try
V.private.dat(varargin{1}) = reshape(Y,size(varargin{1}));
catch
V.private.dat(varargin{1}) = reshape(Y,size(varargin{1}))';
end
end
elseif strcmpi(cl, 'gifti') && ~isempty(varargin) && exist('OCTAVE_VERSION','builtin')
D = V.private.private.data{1};
tmp = reshape(Y,size(varargin{1}));
try
D.data(varargin{1}) = tmp;
catch
D.data(varargin{1}) = tmp';
end
V.private.private.data{1} = D;
else
V = spm_data_write(V, Y, varargin{:});
end
end