Baseline Problem

Michael Wibral wibral at BIC.UNI-FRANKFURT.DE
Tue May 20 15:22:55 CEST 2008


Dear Robert, dear Fieldtrippers,

I recently reported on some strange sensor signals that were complete on one side of the baseline. I have meanwhile run the checks Robert proposed to get the average fields throughout the baseline and I find values as high as 20fT, which I think is too much!? Maybe it's just something stupid in my code (attached below). Maybe it's related to the fact that we set the threshold for sensor jumps quite high (50)? We chose such a high value because the standard value would report sensor jumps in files where careful visual inspection didn' seem to find any...

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preprocessing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File selection
pathname = '/data/MEGArchive/data/meg/CTF_Data/MooneyFacesMEEG.proc/DATASETS/';
outpath = '/net/M036-LFS1/srv/data1/home1/ctillman/data/MooneyMEEGFieldtripAnalysis/MEG_Preprocessing/controls_chanjump50/';

% "Design matrix
% first Column: subject basefilename
% second column: vector of valid run numbers
% third column: name of trialfun for that particular subject
% fourth column: trial types as defined in the trialfunction (!)
% that should be analysed

Design = {
      'ABA04_MooneyFacesMEEG_20070625_0', [1 2 3 4 5 6], 'mytrialfun_MooneyMEEG_FaceRightButton',[1 4];
             };
for subject = 1:size(Design,1)
    conditions = Design{subject,4}; % These are the correct trials

    for conditioncount = 1:length(conditions)
        DataOut = [];
        OutFileName = strcat(outpath, 'PreprocNew1secbase_',Design{subject,1},'_cond_',...
            num2str(Design{subject,4}(1,conditioncount)),...
            '.mat');

        for run = 1:size(Design{subject,2},2)
            filename = strcat(Design{subject,1},num2str(Design{subject,2}(1,run)),'.ds');
            fullname = strcat(pathname,filename);
            disp('working on: ');
            disp(filename);
            disp(strcat('# of run in Design is: ',num2str(Design{subject,2}(1,run))));

            % Channel selection
            cfg = [];
            cfg.channel = {'MEG', '-MLP12', '-MRC14', '-MLT41', '-MRC25', '-MRP56', '-MRT21', '-MLO21', '-MRO44', '-MRT47'}; % added -MLO21
                                                                                                       % for compatibility because it is bad in some subjects
            cfg.channelmeg = {'MEG' ...
                '-MLP12' '-MRC14' '-MLT41'...
                '-MRC25' '-MRP56' '-MRT21', '-MLO21','-MRO44','-MRT47'};

            cfg.dataset = fullname;

            % Trial definition
            cfg.cond = conditions(conditioncount);  % selection of one of the 4 possible conditions (see readme.txt)
            cfg.trialfun = Design{subject,3};
            cfg = definetrial(cfg);

            % Artifact rejection
            cfg.artfctdef.feedback = 'no';

            cfg.artfctdef.eog.sgn = 'MRT41';             % selection of channel MRT41 as the pseudo EOG channel
            cfg = artifact_eog(cfg);                    % automatic eye blinks rejection

            cfg.artfctdef.jump.sgn = cfg.channelmeg;     % selection of valid channels
            cfg.artfctdef.jump.cutoff = 50;
            cfg = artifact_jump(cfg);                    % automatic sensor jump rejection

            cfg.artfctdef.muscle.cutoff = 6;             % default = 4
            cfg.artfctdef.muscle.sgn = cfg.channelmeg;   % selection of valid channels
            cfg = artifact_muscle(cfg);                  % automatic muscle activity rejection

            cfg = rejectartifact(cfg);

            % Baseline correction
            cfg.blc = 'yes';                             % baseline correction
            cfg.blcwindow = [-0.5 -0.1];
            cfg.detrend = 'yes';

            preproc = preprocessing(cfg);                % preprocessing

            % Concatenate the data as necessary
            if run <=1
                DataOut1 = preproc; % buffer DataOut for the first concatenation
            end
            if run == 2
                cfg = [];
                DataOut = appenddata(cfg, DataOut1, preproc);
            end
            if run > 2
                cfg = [];
                DataOut = appenddata(cfg, DataOut, preproc);
            end

        end % end of run-loop


        % write data for one subject and one condition to disk
        save(OutFileName, 'DataOut');

    end % end of condition loop
end % end of subject loop

exit; %exit MATLAB to free licence


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% trialfunction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function trl = mytrialfun_MooneyMEEG_FaceRightButton(cfg);

hdr = read_fcdc_header(cfg.dataset);
event = read_fcdc_event(cfg.dataset);
pre = 1;   % pretrigger interval in seconds
post = 1; % posttrigger interval in seconds
off = pre;  % trigger offset into datapiece


trl1 = [];
trl2 = [];
trl3 = [];
trl4 = [];
trl5 = [];
trl6 = [];
trl7 = [];
trl8 = [];

for i = 1 : length(event)-2

    switch event(i).type


        case {'Upright'}
            % it is a stimulus trigger, define a trial
            begsample = event(i).sample - pre*hdr.Fs; % 1 second prestimulus data
            endsample = event(i).sample + post*hdr.Fs - 1; % 1 second post stimulus data
            offset = - off*hdr.Fs; % Position where the trigger initially was found

            for j = 1 : 1   % change this number if intervening triggers are present

                k = j
                % added for faulty datasets from PEGE_...
                if (strcmp(event(i+k).type,'UPPT001') | strcmp(event(i+k).type,'frontpanel trigger') )
                    k = k+1
              end
              if (strcmp(event(i+k).type,'frontpanel trigger') | strcmp(event(i+k).type,'UPPT001'))
                    k = k+1
              end

                % see to what condition it belongs by looking at the  button press response
                if strcmp(event(i+k).type,'ButtonNoFace')
                    trl1(end+1,:) = round([begsample endsample offset]);
               end



            end  % end for


        case {'Inverted'}

            % it is a stimulus trigger, define a trial
            begsample = event(i).sample - pre*hdr.Fs; % 0.5 second prestimulus data
            endsample = event(i).sample + post*hdr.Fs - 1; % 1 second post stimulus data
            offset = - off*hdr.Fs; % Position where the trigger initially was found


            for j = 1 : 1 % change this number if intervening triggers are present
                k = j
                % added for faulty datasets from PEGE_...
                if (strcmp(event(i+k).type,'UPPT001') | strcmp(event(i+k).type,'frontpanel trigger'))
                    k = k+1
                end
                if (strcmp(event(i+k).type,'frontpanel trigger') | strcmp(event(i+k).type,'UPPT001'))
                    k = k+1
                end



                if strcmp(event(i+k).type,'ButtonFace')
                    trl4(end+1,:) = round([begsample endsample offset]);
                end

            end % end for


    end % end switch

end % end for

trl = eval(strcat('trl',num2str(cfg.cond))); % picking out the condition that was asked in cfg
                                                                       % (not so elegant; TODO: change so that not all arrays trl1 ... trl8 are build at each call of the function)
trl = trl(2:end-1,:);                            % skip the first and last trial for potential boundary problems
cfg.trl = trl;                                       % needed for compatibility with some later functions



----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Michael Wibral.vcf
Type: text/x-vcard
Size: 443 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20080520/a83d40a3/attachment-0001.vcf>


More information about the fieldtrip mailing list