123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- %% Subscript: Organises data from datasets in multiple variables
- % subdivide dataset into its components
- if remI==1
- data(remRec,:) = []; % remove certain recordings from analysis
- end
- filenames = cat(1,data{:,1});
- bsPos = cell2mat(strfind(filenames,'\')); % find positions of back slashes in filename
- startPos = bsPos(:,end); % use last back slash position as starting point
- ptPos = cell2mat(strfind(filenames,'.')); % find positions of points in filename (here only one)
- endPos = ptPos; % use point position as ending point
- recID = extractBetween(filenames,startPos,endPos,'Boundaries','Exclusive'); % extract between Positions
- switch runType
- case 1
- recID_oddb{c} = recID; % save recIDs for each oddball stimulus-combination
- fileI_Oddb = 0; % file index is empty for runType 1 (oddball)
- fileI_Ctrl = 0; % file index is empty for runType 1 (oddball)
- case {2,3}
- insect = intersect(recID_oddb{c},recID); % create array containing only those recordings that are available for both the oddball and the respective control paradigm
- fileI_Oddb = ismember(recID_oddb{c},insect); % create logical array containing those oddball recordings that have a matching control recording
- fileI_Ctrl = ismember(recID,insect);% create logical array containing those control recordings that have a matching oddball recording
- data = data(fileI_Ctrl,:); % use only those control responses that have a matching oddball response
- filenames = filenames(fileI_Ctrl); % use only those control filenames that have a matching oddball response
- end
- param = cat(1,data{:,2});
- seq = cat(1,data{:,4});
- rec_raw = cat(1,data(:,5));
- nFiles = size(data,1); % number of files within the variable
- %% define some additional parameters that are needed for calculations
- % stimulation-parameters; ATTENTION: always uses the parameters of first
- % file --> parameters must be consistent across all files!
- fs = param(1,4);
- fdown = param(1,17);
- fsDwn = fs/fdown;
- fIndx = param(1,2);
- switch runType
- case {1,2} % Oddball, 50Per
- Alvl = param(1,9);
- Afrq = param(1,10);
- Blvl = param(1,26);
- Bfrq = param(1,25);
- AfrqI = 999; % frequency index in MR control --> redundant but required in other runTypes
- BfrqI = 999;
- end
- nDev = param(1,23);
- devProb = param(1,24);
- nTrials = param(1,12);
- nStd = nTrials-nDev;
- switch runType
- case {1,2} % Oddball, 50Per
- nBlcks = 2; % number of blocks (AB and BA)
- case 3 % MR
- nBlcks = 1; % only one block
- end
- stimDur = round(param(1,7),4);
- trDel = spDis/343.2; % travelling delay time of stimulus in s (343.2 is the speed of sound in air)
- stimDelay = round(param(1,13)+trDel,4); % stimulus delay in s (corrected for sound travelling delay)
- stimDelay = stimDelay+0.001; % add additional tone delay to stim delay
- pts2begin = round(stimDelay.*fsDwn); % samples before stimulus onset
- repper = round(param(1,8),4);
- recdur = repper;
- % additional parameters
- rawLen = zeros(1,nFiles); % preallocate
- for f = 1:nFiles
- rawLen(f) = size(rec_raw{f},2); % number of samples in each channel of raw file
- end
- blockLenBuff = rawLen./nBlcks; % % length of one block (AB or BA) in samples, INCLUDING buffers
- blockLen = round(recdur.*nTrials.*fsDwn); % length of one block (AB or BA) in samples, WITHOUT buffers
- pSmpl = blockLen(1)/nTrials(1); % number of samples of each single response
- timetr = (0:pSmpl-1)/fsDwn(1); % time trace of one trial
|