0

what do I want to do?

  • compute within participants condition files a new variable, containing only the difference between channels 4 and 5 across all data points (i.e. frames) and trials.

  • I double-checked that and this step works

  • Subsequently, I want to save the data files for each participant's condition. The code produces saved files (i.e. '.set' files). However the last element within condslist (variable containing all conditions, see below) seems to overwrite the first element in condslist. Thus for both conditions-files per participant, I obtain identical values.

How do I solve this issue?

%% Channels C3 and C4 for subtraction %%

lrp_chan = [4 5];
chan_labs = {'C3', 'C4'};

%% variables: containing conditions OR participants %%

condlist = {'high-reward-congruent', 'high-reward-incongruent'};

vpn_even = {'Reward_Simon_LRP0003','Reward_Simon_LRP0002'};  

%%compute for each participant in each conditions single-subtraction%%

for ivpn_even = 1:length(vpn_even)
 
 for jCond = 1:length(condlist)
    EEG = pop_loadset([Mainpath, 'output\Condsout\', vpn_even{ivpn_even}, '-', 
    condlist{jCond} '.set']);
    EEG.single_subtraction = (EEG.data(4,:,:) - EEG.data(5,:,:));
 end   




 %% save participant files %% 

     for ivpn = 1:length(vpn_even)
        for jCond = 1:length(condlist)
         EEG.setname = [vpn_even{ivpn_even}, '-LRP-', condlist{jCond}]
         EEG.filename = [EEG.setname '.set'];
         EEG.filepath = [Mainpath, Dataout];
         %EEG.savemode = [EEG,'twofiles'];
         pop_saveset(EEG, 'filename', EEG.filename, 'filepath', EEG.filepath);
        end
     end
 
 
 end

Please let me know if any information is missing.

thanks in advance, Leif.

1 Answers1

0

This modification solved the overwriting issue ^^

%% save participant files

for ivpn = 1:length(vpn_even)
     EEG.setname = [vpn_even{ivpn_even}, '-LRP-', condlist{jCond}]
     EEG.filename = [EEG.setname '.set'];
     EEG.filepath = [Mainpath, Dataout];
     %EEG.savemode = [EEG,'twofiles'];
     pop_saveset(EEG, 'filename', EEG.filename, 'filepath', EEG.filepath);
  end