%get directory root_dir = uigetdir(pwd, 'Please select Folder'); %Load DATA load(strcat(root_dir,'\SimulatedDriving.mat')) %Job Pipeline j = nirs.modules.ImportData(); %Remove Datasets without Stimuli (e.g. Recordings of preparation) j = nirs.modules.RemoveStimless(j); %Remove Short Stimuli (mainly 2 und 3 Dummies) j = nirs.modules.RemoveShortStims (j); %Rename Stimuli according to experimental condition, type of reaction etc. j = nirs.modules.RenameStims( j ); j.listOfChanges = { 'stim_channel1', 'A_Mistakes'; 'stim_channel2', 'B_CountryCourse'; 'stim_channel3', 'C_Transition'; 'stim_channel4', 'D_CityCourse'; 'stim_channel5', 'E_Event'}; %Fill in missing values j = nirs.modules.FixNaNs(j); %Only Data within a certain time range around the stimulus is kept j = nirs.modules.TrimBaseline( j ); %Keep data 30 seconds prior to and 30 seconds after stimuli j.preBaseline = 30; j.postBaseline = 30; %Convert raw electrical data into optical density j = nirs.modules.OpticalDensity(j); %Calculate relative concentration change of blood types via modified %Beer-Lambert law j = nirs.modules.BeerLambertLaw(j); %Create object with blood types hb = j.run(raw); %Wavelet Filter j = nirs.modules.WaveletFilter(); wavehb = j.run(hb); %Keep only Fahrten und Fehler j = nirs.modules.KeepStims(); j.listOfStims = {'A_Mistakes';'B_CountryCourse';'C_Transition';'D_CityCourse'}; %Run first level GLM to get and correct for auto correlational structure j = nirs.modules.GLM(j); %Create new object with subject statistics SubjStats = j.run(wavehb); %Keep only stimuli relevant for research question j = nirs.modules.KeepStims(); j.listOfStims = {'B_CountryCourse:01'; 'D_CityCourse:01'}; %Run group level analysis j = nirs.modules.MixedEffects(j); j.formula = 'beta ~ -1 + cond + (1|subject)'; j.robust=true; j.dummyCoding = 'full'; %Create new object group statistics GroupStats = j.run(SubjStats); %Create matrix for all relevant contrasts c = [-1 1]; %Calculate t-tests for relevant contrasts ContrastStats = GroupStats.ttest(c); %Display contrast table ContrastStats.table %Draw contrast stats %ContrastStats.draw('tstat', [-5 5], 'q < 0.05'); MeasList=[1 1;... 1 2;... 2 1;... 2 2]; Region{1} = table(MeasList(:,1),MeasList(:,2),'VariableNames',{'source','detector'}); MeasList=[3 2;... 3 3;... 3 4;... 4 3;... 4 4]; Region{2} = table(MeasList(:,1),MeasList(:,2),'VariableNames',{'source','detector'}); MeasList=[5 5;... 5 6;... 6 5;... 6 6]; Region{3} = table(MeasList(:,1),MeasList(:,2),'VariableNames',{'source','detector'}); MeasList=[7 6;... 7 7;... 7 8;... 8 7;... 8 8]; Region{4} = table(MeasList(:,1),MeasList(:,2),'VariableNames',{'source','detector'}); ROItable=nirs.util.roiAverage(ContrastStats,Region,{'region1','region2';'region3','region4'}); disp(ROItable);