Skip to content

Commit

Permalink
Imported upstream version 8.4290~dfsg.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mih committed Apr 14, 2011
1 parent f3a1ee7 commit 0e20250
Show file tree
Hide file tree
Showing 635 changed files with 25,477 additions and 8,527 deletions.
4 changes: 2 additions & 2 deletions @file_array/cat.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

%
% $Id: cat.m 1143 2008-02-07 19:33:33Z spm $
% $Id: cat.m 4136 2010-12-09 22:22:28Z guillaume $


if dr>32 || dr<0, error('Unknown command option.'); end;
Expand Down Expand Up @@ -36,5 +36,5 @@
error('All matrices on a row in the bracketed expression must have the same number of rows.');
else
o = vertcat(tmp{:});
o = class(o,'file_array');
o = file_array(o);
end;
4 changes: 2 additions & 2 deletions @file_array/disp.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function disp(obj)
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

%
% $Id: disp.m 1143 2008-02-07 19:33:33Z spm $
% $Id: disp.m 4136 2010-12-09 22:22:28Z guillaume $


if numel(struct(obj))>1,
Expand All @@ -19,7 +19,7 @@ function disp(obj)
fprintf('%d\n',sz(end));
end;
else
display(mystruct(obj))
disp(mystruct(obj))
end;
return;
%=======================================================================
Expand Down
4 changes: 2 additions & 2 deletions @file_array/file_array.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

%
% $Id: file_array.m 1340 2008-04-09 17:11:23Z john $
% $Id: file_array.m 4136 2010-12-09 22:22:28Z guillaume $


if nargin==1
Expand All @@ -38,5 +38,5 @@
if nargin>=7, a = permission(a,varargin{7}); end;

a.pos = ones(size(a.dim));
a = class(a,'file_array');
a = file_array(a);

6 changes: 3 additions & 3 deletions @file_array/private/datatypes.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

%
% $Id: datatypes.m 1143 2008-02-07 19:33:33Z spm $
% $Id: datatypes.m 4136 2010-12-09 22:22:28Z guillaume $


persistent dtype
Expand All @@ -24,10 +24,10 @@
1280,'UINT64' ,'uint64' ,@uint64 ,1,8 ,t,t,f
16 ,'FLOAT32' ,'float32' ,@single ,1,4 ,f,f,t
64 ,'FLOAT64' ,'double' ,@double ,1,8 ,f,f,t
1536,'FLOAT128' ,'float128',@crash ,1,16 ,f,f,f
1536,'FLOAT128' ,'float128',@error ,1,16 ,f,f,f
32 ,'COMPLEX64' ,'float32' ,@single ,2,4 ,f,f,f
1792,'COMPLEX128','double' ,@double ,2,8 ,f,f,f
2048,'COMPLEX256','float128',@crash ,2,16 ,f,f,f
2048,'COMPLEX256','float128',@error ,2,16 ,f,f,f
128 ,'RGB24' ,'uint8' ,@uint8 ,3,1 ,t,t,f};
dtype = struct(...
'code' ,table(:,1),...
Expand Down
8 changes: 4 additions & 4 deletions @file_array/subsasgn.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

%
% $Id: subsasgn.m 1355 2008-04-10 10:52:35Z vladimir $
% $Id: subsasgn.m 4136 2010-12-09 22:22:28Z guillaume $


if isempty(subs)
Expand Down Expand Up @@ -47,7 +47,7 @@
end;

dm = [dm ones(1,16)];
do = ones(1,16);
di = ones(1,16);
args = {};
for i=1:length(subs.subs),
if ischar(subs.subs{i}),
Expand All @@ -56,7 +56,7 @@
else
args{i} = int32(subs.subs{i});
end;
do(i) = length(args{i});
di(i) = length(args{i});
end;
for j=1:length(sobj),
if strcmp(sobj(j).permission,'ro'),
Expand All @@ -69,7 +69,7 @@
if numel(dat)~=1,
subfun(sobj,double(dat),args{:});
else
dat1 = double(dat) + zeros(do);
dat1 = double(dat) + zeros(di);
subfun(sobj,dat1,args{:});
end;
else
Expand Down
8 changes: 4 additions & 4 deletions @file_array/subsref.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

%
% $Id: subsref.m 3958 2010-06-30 16:24:46Z guillaume $
% $Id: subsref.m 4136 2010-12-09 22:22:28Z guillaume $


if isempty(subs), return; end
Expand Down Expand Up @@ -39,7 +39,7 @@
end
end

do = ones(16,1);
di = ones(16,1);
args = cell(1,length(subs.subs));
for i=1:length(subs.subs)
if ischar(subs.subs{i})
Expand All @@ -58,15 +58,15 @@
else
args{i} = subs.subs{i};
end
do(i) = length(args{i});
di(i) = length(args{i});
end

if length(sobj)==1
t = subfun(sobj,args{:});
else
dt = datatypes;
dt = dt([dt.code]==sobj(1).dtype); % assuming identical datatypes
t = zeros(do',func2str(dt.conv));
t = zeros(di',func2str(dt.conv));
for j=1:length(sobj)
ps = [sobj(j).pos ones(1,length(args))];
dm = [sobj(j).dim ones(1,length(args))];
Expand Down
7 changes: 5 additions & 2 deletions @gifti/display.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function display(this)
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Guillaume Flandin
% $Id: display.m 2076 2008-09-10 12:34:08Z guillaume $
% $Id: display.m 4182 2011-02-01 12:29:09Z guillaume $

display_name = inputname(1);
if isempty(display_name)
Expand All @@ -17,6 +17,9 @@ function display(this)
eval([display_name ' = struct(this);']);
eval(['display(' display_name ');']);
else
disp(' ')
disp([display_name ' =']);
disp(' ');
eval([display_name ' = this;']);
eval(['builtin(''display'',' display_name ');']);
eval(['disp(' display_name ');']);
end
4 changes: 2 additions & 2 deletions @gifti/private/read_gifti_file.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Guillaume Flandin
% $Id: read_gifti_file.m 3999 2010-07-19 10:54:18Z guillaume $
% $Id: read_gifti_file.m 4013 2010-07-22 17:12:45Z guillaume $

% Import XML-based GIfTI file
%--------------------------------------------------------------------------
Expand All @@ -23,7 +23,7 @@
error('[GIFTI] %s is not a GIFTI 1.0 file.', filename);
end
attr = cell2mat(attributes(t,'get',root(t)));
attr = cell2struct({attr.val},strrep({attr.key},':','_'),2);
attr = cell2struct({attr.val},strrep({attr.key},':','___'),2);
if ~all(ismember({'Version','NumberOfDataArrays'},fieldnames(attr)))
error('[GIFTI] Missing mandatory attributes for GIFTI root element.');
end
Expand Down
6 changes: 3 additions & 3 deletions @gifti/save.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function save(this,filename,encoding)
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Guillaume Flandin
% $Id: save.m 3999 2010-07-19 10:54:18Z guillaume $
% $Id: save.m 4022 2010-07-28 12:50:20Z guillaume $

error(nargchk(1,3,nargin));

Expand Down Expand Up @@ -66,9 +66,9 @@ function save(this,filename,encoding)
% Defaults for DataArray's attributes
%--------------------------------------------------------------------------
[unused,unused,mach] = fopen(fid);
if ~isempty(strmatch('ieee-be',mach))
if strncmp('ieee-be',mach,7)
def.Endian = 'BigEndian';
elseif ~isempty(strmatch('ieee-le',mach))
elseif strncmp('ieee-le',mach,7)
def.Endian = 'LittleEndian';
else
error('[GIFTI] Unknown byte order "%s".',mach);
Expand Down
5 changes: 3 additions & 2 deletions @gifti/subsref.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Guillaume Flandin
% $Id: subsref.m 3999 2010-07-19 10:54:18Z guillaume $
% $Id: subsref.m 4136 2010-12-09 22:22:28Z guillaume $

if length(this) > 1
if length(this) > 1 && ~strcmp(subs(1).type,'()')
warning('Not implemented.');
for i=1:numel(this)
varargout{i} = subsref(this(i),subs);
end
return;
end

switch subs(1).type
Expand Down
9 changes: 5 additions & 4 deletions @meeg/badchannels.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Stefan Kiebel
% $Id: badchannels.m 3942 2010-06-21 14:03:28Z vladimir $
% $Id: badchannels.m 4040 2010-08-20 23:25:46Z vladimir $


if length(varargin) == 2

if length(varargin) == 2 && ~isempty(varargin{1})
% make sure that the two inputs for set are the same length
if ~(length(varargin{2}) == 1 | (length(varargin{1}) == length(varargin{2})))
error('Use either same vector length or scalar for value');
end
end

if numel(varargin) >= 1
if ~(varargin{1} >= 1 & varargin{1} <= nchannels(this))
if numel(varargin) >= 1 && ~isempty(varargin{1})
if ~(all(varargin{1} >= 1) && all(varargin{1} <= nchannels(this)))
error('Channel number of out range.');
end
end
Expand Down
21 changes: 18 additions & 3 deletions @meeg/clone.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Stefan Kiebel, Vladimir Litvak
% $Id: clone.m 3807 2010-04-06 19:29:08Z vladimir $
% $Id: clone.m 4207 2011-02-22 10:48:36Z christophe $

if nargin < 4
reset = 0;
Expand All @@ -32,11 +32,26 @@
if isempty(pth)
pth = this.path;
end
newFileName = [fullfile(pth,fname),ext];
newFileName = [fullfile(pth,fname),'.dat'];
% copy the file_array
d = this.data.y; %
d.fname = newFileName;
d.dim = dim;
dim_o = d.dim;

% This takes care of an issue specific to data files with a scaling factor
% which are not officially supported in SPM8 (float without scaling).
% Also assuming scaling is the *same* for all channels...
if dim(1)>dim_o(1) && length(d.scl_slope)>1
% adding channel to montage and scl_slope defined for old montage
% -> need to increase size of scl_slope
v_slope = mode(d.scl_slope);
if length(v_slope)>1
warning(['Trying to guess the scaling factor for new channels.',...
' This factor might be wrong now.']);
end
d.scl_slope = [d.scl_slope' ones(1,dim(1)-dim_o(1))*v_slope]';
end
d.dim = dim;

% physically initialise file
if length(dim) == 3
Expand Down
8 changes: 6 additions & 2 deletions @meeg/frequencies.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Stefan Kiebel
% $Id: frequencies.m 3579 2009-11-18 16:21:55Z vladimir $
% $Id: frequencies.m 4015 2010-07-23 16:35:03Z vladimir $

if nargin < 3
if strncmpi(transformtype(this), 'TF',2)
Expand Down Expand Up @@ -34,7 +34,11 @@
error('Wrong frequency axis or indices');
end

this.transform.frequencies(ind) = f;
if length(ind) == size(this.data.y, 2)
this.transform.frequencies = f;
else
this.transform.frequencies(ind) = f;
end

res = this;
end
44 changes: 38 additions & 6 deletions @meeg/private/checkmeeg.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Vladimir Litvak
% $Id: checkmeeg.m 3978 2010-07-08 14:26:39Z vladimir $
% $Id: checkmeeg.m 4207 2011-02-22 10:48:36Z christophe $

if nargin==1
option = 'basic';
Expand Down Expand Up @@ -64,10 +64,24 @@
end

for k = 1:Ntrials
if isnumeric(meegstruct.trials(k).label)
meegstruct.trials(k).label = num2str(meegstruct.trials(k).label);

label = meegstruct.trials(k).label;

if iscell(label) && numel(label) == 1
label = label{1};
end

if isnumeric(label)
label = num2str(label);
end

if isa(label, 'char')
meegstruct.trials(k).label = label;
else
meegstruct.trials(k).label = 'Unknown';
disp('checkmeeg: some trial labels were not strings, changing back to ''Unknown''');
end

if length(meegstruct.trials(k).bad)>1 || ~ismember(meegstruct.trials(k).bad, [0, 1])
disp(['checkmeeg: illegal value for bad flag in trial ' num2str(k) ', setting to zero.']);
meegstruct.trials(k).bad = 0;
Expand Down Expand Up @@ -135,6 +149,11 @@
else
[meegstruct.channels(find(cellfun('isempty', {meegstruct.channels.bad}))).bad] = deal(0);
end

for i = 1:Nchannels
meegstruct.channels(i).bad = double(~~meegstruct.channels(i).bad);
end

if ~isfield(meegstruct.channels, 'type')
disp('checkmeeg: no channel type, assigning default');
[meegstruct.channels.type] = deal('Other');
Expand Down Expand Up @@ -199,12 +218,20 @@
end

if isa(meegstruct.data.y, 'file_array')
% catching up (unlikely case) where filearray.fname is
% different from data.fnamedat -> set data.fnamedat
[junk, yfname, yext] = fileparts(meegstruct.data.y.fname);
[junk, dfname, dext] = fileparts(meegstruct.data.fnamedat);
if ~strcmp([yfname yext],[dfname dext])
meegstruct.data.fnamedat = [yfname yext];
end
% save original file_array scale & offset, just in case
sav_sc = meegstruct.data.y.scl_slope;
sav_os = meegstruct.data.y.offset;
try
% Try reading data, i.e. check if it's a "good" filearray
meegstruct.data.y(1, 1, 1);
catch
% save original file_array scale, just in case
sav_sc = meegstruct.data.y.scl_slope;
meegstruct.data.y = [];
end
end
Expand Down Expand Up @@ -235,9 +262,14 @@
error('Unknown transform type');
end
% and restore original file_array scale, if available (exist) & useful (~=[])
if exist('sav_sc','var') && ~isempty(sav_sc)
if exist('sav_sc','var') && ~isempty(sav_sc) && ...
size(meegstruct.data.y, 1) == length(sav_sc)
meegstruct.data.y.scl_slope = sav_sc;
end
% and restore original file_array offset, if available (exist) & useful (~=0)
if exist('sav_os','var') && sav_os
meegstruct.data.y.offset = sav_os;
end

end

Expand Down
Loading

0 comments on commit 0e20250

Please sign in to comment.