Skip to content

Commit

Permalink
Merge commit 'b1127f4' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoostenveld committed Dec 20, 2023
2 parents 21951b5 + b1127f4 commit 40afa92
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 26 deletions.
19 changes: 19 additions & 0 deletions fileio/ft_read_header.m
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,11 @@
hdr.nChans = info.nchan;
hdr.Fs = info.sfreq;

if ft_senstype(hdr, 'fieldline') && isempty(coilaccuracy)
ft_warning('FieldLine data requires coilaccuracy>=1');
coilaccuracy = 1;
end

% add a gradiometer structure for forward and inverse modelling
try
[grad, elec] = mne2grad(info, strcmp(coordsys, 'dewar'), coilaccuracy, coildeffile);
Expand All @@ -1930,6 +1935,20 @@
disp(lasterr);
end

% remove the electronics chassis number from the fieldline channel names
if ft_senstype(hdr, 'fieldline_v3') && any(contains(hdr.label, '-s'))
for i=1:length(hdr.label)
tok = split(hdr.label{i}, '-');
hdr.label{i} = tok{1};
end
end
if isfield(hdr, 'grad') && ft_senstype(hdr.grad, 'fieldline_v3') && any(contains(hdr.grad.label, '-s'))
for i=1:length(hdr.grad.label)
tok = split(hdr.grad.label{i}, '-');
hdr.grad.label{i} = tok{1};
end
end

iscontinuous = 0;
isepoched = 0;
isaverage = 0;
Expand Down
30 changes: 24 additions & 6 deletions fileio/private/ft_senstype.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
% 'babysquid74' this is a BabySQUID system from Tristan Technologies
% 'artemis123' this is a BabySQUID system from Tristan Technologies
% 'magview' this is a BabySQUID system from Tristan Technologies
% 'fieldline_v2'
% 'fieldline_v3'
% 'egi32'
% 'egi64'
% 'egi128'
Expand Down Expand Up @@ -81,6 +83,7 @@
% 'yokogawa'
% 'itab'
% 'babysquid'
% 'fieldline'
% If you specify the desired type, this function will return a boolean flag
% indicating true/false depending on the input data.
%
Expand All @@ -96,7 +99,7 @@
%
% See also FT_SENSLABEL, FT_CHANTYPE, FT_READ_SENS, FT_COMPUTE_LEADFIELD, FT_DATATYPE_SENS

% Copyright (C) 2007-2017, Robert Oostenveld
% Copyright (C) 2007-2023, Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
Expand Down Expand Up @@ -305,9 +308,13 @@
type = 'yokogawa440';
end

elseif issubfield(input, 'orig.raw.info')
elseif issubfield(input, 'orig.raw.info') && mean(ismember(input.orig.raw.info.ch_names, ft_senstype('neuromag306')))>0.5
% this is a complete header that was read from a FIF file
type = 'neuromag';
type = 'neuromag306';

elseif issubfield(input, 'orig.raw.info') && mean(ismember(input.orig.raw.info.ch_names, ft_senstype('neuromag122')))>0.5
% this is a complete header that was read from a FIF file
type = 'neuromag122';

elseif issubfield(input, 'orig.FILE.Ext') && strcmp(input.orig.FILE.Ext, 'edf')
% this is a complete header that was read from an EDF or EDF+ dataset
Expand Down Expand Up @@ -429,7 +436,15 @@
type = 'neuromag122_combined';
elseif all(mean(ismember(ft_senslabel('neuromag122'), sens.label)) > 0.4)
type = 'neuromag122';


% FieldLine OPM system
elseif (mean(~cellfun(@isempty, regexp(sens.label, '\d\d:\d\d-B.*'))) > 0.5)
type = 'fieldline_v2'; % like 00:01-BZ_OL
elseif (mean(startsWith(sens.label, {'L', 'R'}) & endsWith(sens.label, {'bx', 'by', 'bz'})) > 0.5)
type = 'fieldline_v3'; % like R407_bz
elseif (mean(startsWith(sens.label, {'L', 'R'}) & contains(sens.label, {'bx-s', 'by-s', 'bz-s'})) > 0.5)
type = 'fieldline_v3'; % like R407_bz-s32, including the electronics chassis number

elseif (mean(ismember(ft_senslabel('biosemi256'), sens.label)) > 0.8)
type = 'biosemi256';
elseif (mean(ismember(ft_senslabel('biosemi128'), sens.label)) > 0.8)
Expand Down Expand Up @@ -521,7 +536,7 @@
case 'egi'
type = any(strcmp(type, {'egi' 'egi32' 'egi64' 'egi128' 'egi256'}));
case 'meg'
type = any(strcmp(type, {'meg' 'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar' 'neuromag' 'neuromag122' 'neuromag306' 'neuromag306_combined' 'bti' 'bti148' 'bti148_planar' 'bti248' 'bti248_planar' 'bti248grad' 'bti248grad_planar' 'yokogawa' 'yokogawa9' 'yokogawa160' 'yokogawa160_planar' 'yokogawa64' 'yokogawa64_planar' 'yokogawa440' 'itab' 'itab28' 'itab153' 'itab153_planar' 'babysquid' 'babysquid74' 'artenis123' 'magview' 'yorkinstruments248'}));
type = any(strcmp(type, {'meg' 'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar' 'neuromag' 'neuromag122' 'neuromag306' 'neuromag306_combined' 'bti' 'bti148' 'bti148_planar' 'bti248' 'bti248_planar' 'bti248grad' 'bti248grad_planar' 'yokogawa' 'yokogawa9' 'yokogawa160' 'yokogawa160_planar' 'yokogawa64' 'yokogawa64_planar' 'yokogawa440' 'itab' 'itab28' 'itab153' 'itab153_planar' 'babysquid' 'babysquid74' 'artenis123' 'magview' 'yorkinstruments248', 'fieldline_v2', 'fieldline_v3'}));
case 'ctf'
type = any(strcmp(type, {'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar'}));
case 'bti'
Expand All @@ -534,9 +549,12 @@
type = any(strcmp(type, {'yokogawa' 'yokogawa9' 'yokogawa64' 'yokogawa64_planar' 'yokogawa160' 'yokogawa160_planar' 'yokogawa208' 'yokogawa208_planar' 'yokogawa440'}));
case 'itab'
type = any(strcmp(type, {'itab' 'itab28' 'itab153' 'itab153_planar'}));
case 'fieldline'
type = any(strcmp(type, {'fieldline_v2' 'fieldline_v3'}));
case 'meg_axial'
% note that neuromag306 is mixed planar and axial
type = any(strcmp(type, {'neuromag306' 'ctf64' 'ctf151' 'ctf275' 'bti148' 'bti248' 'bti248grad' 'yokogawa9' 'yokogawa64' 'yokogawa160' 'yokogawa440'}));
% note that fieldline_v3 might include tangential magnetometers
type = any(strcmp(type, {'neuromag306' 'ctf64' 'ctf151' 'ctf275' 'bti148' 'bti248' 'bti248grad' 'yokogawa9' 'yokogawa64' 'yokogawa160' 'yokogawa440', 'fieldline_v2', 'fieldline_v3'}));
case 'meg_planar'
% note that neuromag306 is mixed planar and axial
type = any(strcmp(type, {'neuromag122' 'neuromag306' 'ctf151_planar' 'ctf275_planar' 'bti148_planar' 'bti248_planar' 'bti248grad_planar' 'yokogawa208_planar' 'yokogawa160_planar' 'yokogawa64_planar'}));
Expand Down
30 changes: 24 additions & 6 deletions forward/ft_senstype.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
% 'babysquid74' this is a BabySQUID system from Tristan Technologies
% 'artemis123' this is a BabySQUID system from Tristan Technologies
% 'magview' this is a BabySQUID system from Tristan Technologies
% 'fieldline_v2'
% 'fieldline_v3'
% 'egi32'
% 'egi64'
% 'egi128'
Expand Down Expand Up @@ -81,6 +83,7 @@
% 'yokogawa'
% 'itab'
% 'babysquid'
% 'fieldline'
% If you specify the desired type, this function will return a boolean flag
% indicating true/false depending on the input data.
%
Expand All @@ -96,7 +99,7 @@
%
% See also FT_SENSLABEL, FT_CHANTYPE, FT_READ_SENS, FT_COMPUTE_LEADFIELD, FT_DATATYPE_SENS

% Copyright (C) 2007-2017, Robert Oostenveld
% Copyright (C) 2007-2023, Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
Expand Down Expand Up @@ -305,9 +308,13 @@
type = 'yokogawa440';
end

elseif issubfield(input, 'orig.raw.info')
elseif issubfield(input, 'orig.raw.info') && mean(ismember(input.orig.raw.info.ch_names, ft_senstype('neuromag306')))>0.5
% this is a complete header that was read from a FIF file
type = 'neuromag';
type = 'neuromag306';

elseif issubfield(input, 'orig.raw.info') && mean(ismember(input.orig.raw.info.ch_names, ft_senstype('neuromag122')))>0.5
% this is a complete header that was read from a FIF file
type = 'neuromag122';

elseif issubfield(input, 'orig.FILE.Ext') && strcmp(input.orig.FILE.Ext, 'edf')
% this is a complete header that was read from an EDF or EDF+ dataset
Expand Down Expand Up @@ -429,7 +436,15 @@
type = 'neuromag122_combined';
elseif all(mean(ismember(ft_senslabel('neuromag122'), sens.label)) > 0.4)
type = 'neuromag122';


% FieldLine OPM system
elseif (mean(~cellfun(@isempty, regexp(sens.label, '\d\d:\d\d-B.*'))) > 0.5)
type = 'fieldline_v2'; % like 00:01-BZ_OL
elseif (mean(startsWith(sens.label, {'L', 'R'}) & endsWith(sens.label, {'bx', 'by', 'bz'})) > 0.5)
type = 'fieldline_v3'; % like R407_bz
elseif (mean(startsWith(sens.label, {'L', 'R'}) & contains(sens.label, {'bx-s', 'by-s', 'bz-s'})) > 0.5)
type = 'fieldline_v3'; % like R407_bz-s32, including the electronics chassis number

elseif (mean(ismember(ft_senslabel('biosemi256'), sens.label)) > 0.8)
type = 'biosemi256';
elseif (mean(ismember(ft_senslabel('biosemi128'), sens.label)) > 0.8)
Expand Down Expand Up @@ -521,7 +536,7 @@
case 'egi'
type = any(strcmp(type, {'egi' 'egi32' 'egi64' 'egi128' 'egi256'}));
case 'meg'
type = any(strcmp(type, {'meg' 'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar' 'neuromag' 'neuromag122' 'neuromag306' 'neuromag306_combined' 'bti' 'bti148' 'bti148_planar' 'bti248' 'bti248_planar' 'bti248grad' 'bti248grad_planar' 'yokogawa' 'yokogawa9' 'yokogawa160' 'yokogawa160_planar' 'yokogawa64' 'yokogawa64_planar' 'yokogawa440' 'itab' 'itab28' 'itab153' 'itab153_planar' 'babysquid' 'babysquid74' 'artenis123' 'magview' 'yorkinstruments248'}));
type = any(strcmp(type, {'meg' 'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar' 'neuromag' 'neuromag122' 'neuromag306' 'neuromag306_combined' 'bti' 'bti148' 'bti148_planar' 'bti248' 'bti248_planar' 'bti248grad' 'bti248grad_planar' 'yokogawa' 'yokogawa9' 'yokogawa160' 'yokogawa160_planar' 'yokogawa64' 'yokogawa64_planar' 'yokogawa440' 'itab' 'itab28' 'itab153' 'itab153_planar' 'babysquid' 'babysquid74' 'artenis123' 'magview' 'yorkinstruments248', 'fieldline_v2', 'fieldline_v3'}));
case 'ctf'
type = any(strcmp(type, {'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar'}));
case 'bti'
Expand All @@ -534,9 +549,12 @@
type = any(strcmp(type, {'yokogawa' 'yokogawa9' 'yokogawa64' 'yokogawa64_planar' 'yokogawa160' 'yokogawa160_planar' 'yokogawa208' 'yokogawa208_planar' 'yokogawa440'}));
case 'itab'
type = any(strcmp(type, {'itab' 'itab28' 'itab153' 'itab153_planar'}));
case 'fieldline'
type = any(strcmp(type, {'fieldline_v2' 'fieldline_v3'}));
case 'meg_axial'
% note that neuromag306 is mixed planar and axial
type = any(strcmp(type, {'neuromag306' 'ctf64' 'ctf151' 'ctf275' 'bti148' 'bti248' 'bti248grad' 'yokogawa9' 'yokogawa64' 'yokogawa160' 'yokogawa440'}));
% note that fieldline_v3 might include tangential magnetometers
type = any(strcmp(type, {'neuromag306' 'ctf64' 'ctf151' 'ctf275' 'bti148' 'bti248' 'bti248grad' 'yokogawa9' 'yokogawa64' 'yokogawa160' 'yokogawa440', 'fieldline_v2', 'fieldline_v3'}));
case 'meg_planar'
% note that neuromag306 is mixed planar and axial
type = any(strcmp(type, {'neuromag122' 'neuromag306' 'ctf151_planar' 'ctf275_planar' 'bti148_planar' 'bti248_planar' 'bti248grad_planar' 'yokogawa208_planar' 'yokogawa160_planar' 'yokogawa64_planar'}));
Expand Down
10 changes: 8 additions & 2 deletions ft_math.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
cfg = ft_checkconfig(cfg, 'renamedval', {'funparameter', 'avg.coh', 'coh'});
cfg = ft_checkconfig(cfg, 'renamedval', {'funparameter', 'avg.mom', 'mom'});

% set the defaults
cfg.feedback = ft_getopt(cfg, 'feedback', 'text');

if ~iscell(cfg.parameter)
cfg.parameter = {cfg.parameter};
end
Expand Down Expand Up @@ -427,9 +430,11 @@
y = feval(operation, arginval{:});
end
else
ft_progress('init', cfg.feedback, 'Processing trials...')
y = cell(size(x1));
% do the same thing, but now for each element of the cell-array
for i=1:numel(y)
ft_progress(i/numel(y), 'Processing trial %d from %d', i, numel(y))
for j=1:length(varargin)
% rather than working with x1 and x2, we need to work on its elements
% xx1 is one element of the x1 cell-array
Expand All @@ -445,15 +450,16 @@
else
y{i} = feval(operation, arginval{:});
end
end % for each element
end % for i over each element
ft_progress('close');
end % iscell or not

end % switch
end % one or multiple input data structures

% store the result of the operation in the output structure
data = setsubfield(data, cfg.parameter{p}, y);
end % p over length(cfg.parameter)
end % for p over all parameters

% certain fields should remain in the output, but only if they are identical in all inputs
keepfield = {'grad', 'elec', 'opto', 'inside', 'trialinfo', 'sampleinfo', 'tri', 'brainordinate'};
Expand Down
30 changes: 24 additions & 6 deletions inverse/private/ft_senstype.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
% 'babysquid74' this is a BabySQUID system from Tristan Technologies
% 'artemis123' this is a BabySQUID system from Tristan Technologies
% 'magview' this is a BabySQUID system from Tristan Technologies
% 'fieldline_v2'
% 'fieldline_v3'
% 'egi32'
% 'egi64'
% 'egi128'
Expand Down Expand Up @@ -81,6 +83,7 @@
% 'yokogawa'
% 'itab'
% 'babysquid'
% 'fieldline'
% If you specify the desired type, this function will return a boolean flag
% indicating true/false depending on the input data.
%
Expand All @@ -96,7 +99,7 @@
%
% See also FT_SENSLABEL, FT_CHANTYPE, FT_READ_SENS, FT_COMPUTE_LEADFIELD, FT_DATATYPE_SENS

% Copyright (C) 2007-2017, Robert Oostenveld
% Copyright (C) 2007-2023, Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
Expand Down Expand Up @@ -305,9 +308,13 @@
type = 'yokogawa440';
end

elseif issubfield(input, 'orig.raw.info')
elseif issubfield(input, 'orig.raw.info') && mean(ismember(input.orig.raw.info.ch_names, ft_senstype('neuromag306')))>0.5
% this is a complete header that was read from a FIF file
type = 'neuromag';
type = 'neuromag306';

elseif issubfield(input, 'orig.raw.info') && mean(ismember(input.orig.raw.info.ch_names, ft_senstype('neuromag122')))>0.5
% this is a complete header that was read from a FIF file
type = 'neuromag122';

elseif issubfield(input, 'orig.FILE.Ext') && strcmp(input.orig.FILE.Ext, 'edf')
% this is a complete header that was read from an EDF or EDF+ dataset
Expand Down Expand Up @@ -429,7 +436,15 @@
type = 'neuromag122_combined';
elseif all(mean(ismember(ft_senslabel('neuromag122'), sens.label)) > 0.4)
type = 'neuromag122';


% FieldLine OPM system
elseif (mean(~cellfun(@isempty, regexp(sens.label, '\d\d:\d\d-B.*'))) > 0.5)
type = 'fieldline_v2'; % like 00:01-BZ_OL
elseif (mean(startsWith(sens.label, {'L', 'R'}) & endsWith(sens.label, {'bx', 'by', 'bz'})) > 0.5)
type = 'fieldline_v3'; % like R407_bz
elseif (mean(startsWith(sens.label, {'L', 'R'}) & contains(sens.label, {'bx-s', 'by-s', 'bz-s'})) > 0.5)
type = 'fieldline_v3'; % like R407_bz-s32, including the electronics chassis number

elseif (mean(ismember(ft_senslabel('biosemi256'), sens.label)) > 0.8)
type = 'biosemi256';
elseif (mean(ismember(ft_senslabel('biosemi128'), sens.label)) > 0.8)
Expand Down Expand Up @@ -521,7 +536,7 @@
case 'egi'
type = any(strcmp(type, {'egi' 'egi32' 'egi64' 'egi128' 'egi256'}));
case 'meg'
type = any(strcmp(type, {'meg' 'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar' 'neuromag' 'neuromag122' 'neuromag306' 'neuromag306_combined' 'bti' 'bti148' 'bti148_planar' 'bti248' 'bti248_planar' 'bti248grad' 'bti248grad_planar' 'yokogawa' 'yokogawa9' 'yokogawa160' 'yokogawa160_planar' 'yokogawa64' 'yokogawa64_planar' 'yokogawa440' 'itab' 'itab28' 'itab153' 'itab153_planar' 'babysquid' 'babysquid74' 'artenis123' 'magview' 'yorkinstruments248'}));
type = any(strcmp(type, {'meg' 'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar' 'neuromag' 'neuromag122' 'neuromag306' 'neuromag306_combined' 'bti' 'bti148' 'bti148_planar' 'bti248' 'bti248_planar' 'bti248grad' 'bti248grad_planar' 'yokogawa' 'yokogawa9' 'yokogawa160' 'yokogawa160_planar' 'yokogawa64' 'yokogawa64_planar' 'yokogawa440' 'itab' 'itab28' 'itab153' 'itab153_planar' 'babysquid' 'babysquid74' 'artenis123' 'magview' 'yorkinstruments248', 'fieldline_v2', 'fieldline_v3'}));
case 'ctf'
type = any(strcmp(type, {'ctf' 'ctf64' 'ctf151' 'ctf275' 'ctf151_planar' 'ctf275_planar'}));
case 'bti'
Expand All @@ -534,9 +549,12 @@
type = any(strcmp(type, {'yokogawa' 'yokogawa9' 'yokogawa64' 'yokogawa64_planar' 'yokogawa160' 'yokogawa160_planar' 'yokogawa208' 'yokogawa208_planar' 'yokogawa440'}));
case 'itab'
type = any(strcmp(type, {'itab' 'itab28' 'itab153' 'itab153_planar'}));
case 'fieldline'
type = any(strcmp(type, {'fieldline_v2' 'fieldline_v3'}));
case 'meg_axial'
% note that neuromag306 is mixed planar and axial
type = any(strcmp(type, {'neuromag306' 'ctf64' 'ctf151' 'ctf275' 'bti148' 'bti248' 'bti248grad' 'yokogawa9' 'yokogawa64' 'yokogawa160' 'yokogawa440'}));
% note that fieldline_v3 might include tangential magnetometers
type = any(strcmp(type, {'neuromag306' 'ctf64' 'ctf151' 'ctf275' 'bti148' 'bti248' 'bti248grad' 'yokogawa9' 'yokogawa64' 'yokogawa160' 'yokogawa440', 'fieldline_v2', 'fieldline_v3'}));
case 'meg_planar'
% note that neuromag306 is mixed planar and axial
type = any(strcmp(type, {'neuromag122' 'neuromag306' 'ctf151_planar' 'ctf275_planar' 'bti148_planar' 'bti248_planar' 'bti248grad_planar' 'yokogawa208_planar' 'yokogawa160_planar' 'yokogawa64_planar'}));
Expand Down
Loading

0 comments on commit 40afa92

Please sign in to comment.