-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46909bf
commit 1de68e0
Showing
1,518 changed files
with
66,390 additions
and
36,491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function res = badtrials(this, varargin) | ||
% Method for getting/setting bad trials | ||
% FORMAT res = badtrials(this) | ||
% _______________________________________________________________________ | ||
% Copyright (C) 2011-2012 Wellcome Trust Centre for Neuroimaging | ||
|
||
% Christophe Phillips | ||
% $Id: badtrials.m 5059 2012-11-15 13:48:35Z vladimir $ | ||
|
||
|
||
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 && ~isempty(varargin{1}) | ||
if ~(all(varargin{1} >= 1) && all(varargin{1} <= ntrials(this))) | ||
error('Trial number out of range.'); | ||
end | ||
end | ||
|
||
if numel(varargin) >= 2 | ||
ubad = unique(varargin{2}); | ||
if isempty(ubad) || ~all(ismember(ubad, [0 1])) | ||
error('Illegal bad flags (should be 0 or 1)'); | ||
end | ||
end | ||
|
||
res = getset(this, 'trials', 'bad', varargin{:}); | ||
|
||
|
||
% Return trial indices if called without arguments and [0, 1] if called | ||
if numel(varargin) <= 1 % get | ||
if iscell(res) | ||
res = [res{:}]; | ||
end | ||
if isempty(varargin) | ||
res = find(res); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,69 @@ | ||
function raw = ftraw(this, memmap) | ||
function raw = ftraw(this, chanind, timeind, trialind) | ||
% Method for converting meeg object to Fieldtrip raw struct | ||
% FORMAT raw = ftraw(this, memmap) | ||
% memmap - 1 (default) memory map the data with file_array | ||
% 0 load the data into memory | ||
% FORMAT raw = ftraw(this, chanind, timeind, trialind) | ||
% _______________________________________________________________________ | ||
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging | ||
% Copyright (C) 2008-2012 Wellcome Trust Centre for Neuroimaging | ||
|
||
% Vladimir Litvak | ||
% $Id: ftraw.m 1742 2008-05-28 11:58:04Z vladimir $ | ||
% $Id: ftraw.m 5063 2012-11-16 12:10:41Z vladimir $ | ||
|
||
if nargin < 2 | ||
memmap = 1; | ||
if ~isequal(transformtype(this), 'time') | ||
raw = fttimelock(this, chanind, timeind, trialind); | ||
return; | ||
end | ||
|
||
nchans = nchannels(this); | ||
ntime = nsamples(this); | ||
ntrl = ntrials(this); | ||
% chanind == 0 is accepted for backward compatibility | ||
if nargin < 2 || isempty(chanind) || chanind == 0 | ||
chanind = 1:nchannels(this); | ||
end | ||
|
||
if nargin < 3 || isempty(timeind) | ||
timeind = 1:nsamples(this); | ||
end | ||
|
||
if nargin < 4 || isempty(trialind) | ||
trialind = 1:ntrials(this); | ||
end | ||
|
||
raw = []; | ||
raw.fsample = fsample(this); | ||
raw.label = chanlabels(this)'; | ||
|
||
wsize=wordsize(this.data.datatype); | ||
|
||
for i=1:ntrl | ||
if memmap | ||
offset = (i-1)*nchans*ntime*wsize; | ||
trialdim = [nchans ntime]; | ||
raw.trial{i} = file_array(fullfile(this.path, this.data.fnamedat),trialdim,this.data.datatype,offset,1,0,'ro'); | ||
else | ||
raw.trial{i} = this.data.y(:, :, i); | ||
end | ||
|
||
raw.label = chanlabels(this, chanind)'; | ||
|
||
raw.trial = cell(1, length(trialind)); | ||
|
||
for i = 1:length(trialind) | ||
raw.trial{i} = this.data.y(chanind, timeind, trialind(i)); | ||
end | ||
|
||
raw.time = repmat({time(this, timeind)}, 1, length(trialind)); | ||
|
||
clist = condlist(this); | ||
|
||
condlabels = conditions(this, trialind); | ||
|
||
raw.trialinfo = 0*trialind; | ||
for k = 1:numel(clist) | ||
fprintf('mapping condition label "%s" to condition code %d\n', clist{k}, k); | ||
sel = strcmp(clist{k}, condlabels); | ||
raw.trialinfo(sel) = k; | ||
end | ||
|
||
if ~isempty(sensors(this, 'MEG')) | ||
raw.grad = sensors(this, 'MEG'); | ||
end | ||
|
||
if ~isempty(sensors(this, 'EEG')) | ||
raw.elec = sensors(this, 'EEG'); | ||
end | ||
|
||
if isfield(this.other, 'origheader') | ||
raw.hdr = this.other.origheader; | ||
end | ||
|
||
onsets = trialonset(this, trialind); | ||
|
||
if all(onsets>0) | ||
onsets = round(onsets(:)*fsample(this)); | ||
raw.sampleinfo = [onsets+timeind(1) onsets+timeind(end)]-1; | ||
end | ||
|
||
raw.time = repmat({time(this)}, 1, ntrl); | ||
|
||
function s = wordsize(datatype) | ||
|
||
datatype = strtok(datatype, '-'); | ||
|
||
switch datatype | ||
case 'int8' | ||
s = 1; | ||
case 'int16' | ||
s = 2; | ||
case 'int32' | ||
s = 4; | ||
case 'uint8' | ||
s = 1; | ||
case 'uint16' | ||
s = 2; | ||
case 'uint32' | ||
s = 4; | ||
case 'float' | ||
s = 4; | ||
case 'double' | ||
s = 8; | ||
case 'float32' | ||
s = 4; | ||
case 'float64' | ||
s = 8; | ||
otherwise | ||
error('unrecognized datatype'); | ||
% FIXME, add support for le and be versions | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,95 @@ | ||
function timelock = fttimelock(this) | ||
function timelock = fttimelock(this, chanind, timeind, trialind, freqind) | ||
% Method for converting meeg object to Fieldtrip timelock/freq struct | ||
% FORMAT timelock = fttimelock(this) | ||
% FORMAT timelock = fttimelock(this, chanind, timeind, trialind, freqind) | ||
% | ||
% The method support both time and TF data and outputs different variants | ||
% of timelock or freq FT struct depending on the dataset type and requested | ||
% data dimensions. | ||
% _______________________________________________________________________ | ||
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging | ||
% Copyright (C) 2008-2012 Wellcome Trust Centre for Neuroimaging | ||
|
||
% Vladimir Litvak | ||
% $Id: fttimelock.m 3210 2009-06-17 13:46:25Z vladimir $ | ||
% $Id: fttimelock.m 5063 2012-11-16 12:10:41Z vladimir $ | ||
|
||
if nargin < 2 || isempty(chanind) | ||
chanind = 1:nchannels(this); | ||
end | ||
|
||
if nargin < 3 || isempty(timeind) | ||
timeind = 1:nsamples(this); | ||
end | ||
|
||
if nargin < 4 || isempty(trialind) | ||
trialind = 1:ntrials(this); | ||
end | ||
|
||
if strncmpi(transformtype(this),'TF',2) && ... | ||
(nargin < 5 || isempty(freqind)) | ||
freqind = 1:nfrequencies(this); | ||
end | ||
|
||
timelock = []; | ||
timelock.label = chanlabels(this); | ||
timelock.label = timelock.label(:); | ||
timelock.label = chanlabels(this, chanind)'; | ||
|
||
if isequal(transformtype(this), 'time') | ||
timelock.dimord = 'rpt_chan_time'; | ||
timelock.fsample = fsample(this); | ||
timelock.trial = permute(this.data.y(:, :, :), [3 1 2]); | ||
timelock.dimord = 'rpt_chan_time'; | ||
if isequal(type(this), 'continuous') | ||
error('For continuous data use ftraw method'); | ||
end | ||
|
||
if isequal(type(this), 'single') || length(trialind)>1 | ||
timelock.dimord = 'rpt_chan_time'; | ||
timelock.trial = permute(this.data.y(chanind, timeind, trialind), [3 1 2]); | ||
else | ||
timelock.dimord = 'chan_time'; | ||
timelock.avg = spm_squeeze(this.data.y(chanind, timeind, trialind), 3); | ||
end | ||
|
||
timelock.time = time(this, timeind); | ||
|
||
elseif strncmpi(transformtype(this),'TF',2) | ||
timelock.dimord = 'rpt_chan_freq_time'; | ||
timelock.powspctrm = permute(this.data.y(:, :, :, :), [4 1 2 3]); | ||
timelock.freq = frequencies(this); | ||
if length(timeind)>1 | ||
if isequal(type(this), 'single') || length(trialind)>1 | ||
timelock.dimord = 'rpt_chan_freq_time'; | ||
timelock.powspctrm = permute(this.data.y(chanind, freqind, timeind, trialind), [4 1 2 3]); | ||
else | ||
timelock.dimord = 'chan_freq_time'; | ||
timelock.powspctrm = spm_squeeze(this.data.y(chanind, freqind, timeind, trialind), 3); | ||
end | ||
|
||
timelock.time = time(this, timeind); | ||
else | ||
if isequal(type(this), 'single') || length(trialind)>1 | ||
timelock.dimord = 'rpt_chan_freq'; | ||
timelock.powspctrm = spm_squeeze(permute(this.data.y(chanind, freqind, timeind, trialind), [4 1 2 3]), 4); | ||
else | ||
timelock.dimord = 'chan_freq'; | ||
timelock.powspctrm = spm_squeeze(this.data.y(chanind, freqind, timeind, trialind), [3 4]); | ||
end | ||
end | ||
|
||
timelock.freq = frequencies(this, freqind); | ||
else | ||
error('Unknown transform type.'); | ||
error('Unknown transform type.'); | ||
end | ||
|
||
if length(trialind)>1 | ||
|
||
clist = condlist(this); | ||
condlabels = conditions(this, trialind); | ||
timelock.trialinfo = 0*trialind; | ||
|
||
for k = 1:numel(clist) | ||
fprintf('mapping condition label "%s" to condition code %d\n', clist{k}, k); | ||
sel = strcmp(clist{k}, condlabels); | ||
timelock.trialinfo(sel) = k; | ||
end | ||
|
||
end | ||
|
||
timelock.time = time(this); | ||
if ~isempty(sensors(this, 'MEG')) | ||
timelock.grad = sensors(this, 'MEG'); | ||
end | ||
|
||
if ~isempty(sensors(this, 'EEG')) | ||
timelock.elec = sensors(this, 'EEG'); | ||
end |
Oops, something went wrong.