I commit to always be in the process of learning one relevant skill on top of my normal work. Here, I plan to document my journey as I learn cool techniques that will make me a better research.
-
Behavioural Analysis
-
EEG Analysis
<
>
Project 1 - Data Analysis in MATLAB
February, 2020
Learning to code is a valuable skill I never learned. Beyond being able to create self-running experiments, conducting complex data analysis, and creating cool data visualisation tools, coding also teaches you to think analytically and solve problems in a computational away. Each script acknowledges a goal, and has multiple components that reach that goal. Problem solving in this manner is a useful skill, and will apply to more areas of my professional development than just coding.
I start my journey into MATLAB analysis by using data from my honours thesis study. My end goal is to be able to be self sufficient in data analysis; given any set of EEG data, conduct analysis techniques and mathematical operations to create Event-Related Potentials and Time-frequency waveforms, as well as conduct statistical analysis of behavioural data. I started with some simple statistical analysis of behavioural data, namely reaction time, accuracy, and confidence rating. Below is my code for this analysis. As you can see, its awfully long. Many of the variables are unorganized, or just straight up unneccesary. As it stands, the end result of this code is seen in this figure. Unfortunately, I do not have permission to provide sample data to try this code with. My next goal is to turn this into a version that anyone could download from this site and use with relative ease. Until then, feel free to laugh at my expense.
Learning to code is a valuable skill I never learned. Beyond being able to create self-running experiments, conducting complex data analysis, and creating cool data visualisation tools, coding also teaches you to think analytically and solve problems in a computational away. Each script acknowledges a goal, and has multiple components that reach that goal. Problem solving in this manner is a useful skill, and will apply to more areas of my professional development than just coding.
I start my journey into MATLAB analysis by using data from my honours thesis study. My end goal is to be able to be self sufficient in data analysis; given any set of EEG data, conduct analysis techniques and mathematical operations to create Event-Related Potentials and Time-frequency waveforms, as well as conduct statistical analysis of behavioural data. I started with some simple statistical analysis of behavioural data, namely reaction time, accuracy, and confidence rating. Below is my code for this analysis. As you can see, its awfully long. Many of the variables are unorganized, or just straight up unneccesary. As it stands, the end result of this code is seen in this figure. Unfortunately, I do not have permission to provide sample data to try this code with. My next goal is to turn this into a version that anyone could download from this site and use with relative ease. Until then, feel free to laugh at my expense.
%Mat's code to analyze behavioural data from MDM Muse.
clear all;
clc;
%Participant Number, Phase, ((Block)), Block, Trial, Total Trial, Reaction Time, Last Block Accuracy, Disease, Condition, Accuracy, etc
% 1,4,5,11,18,19,20,22,23,24,25,27,34,37,48:Non learners
filenames = dir(strcat('*.txt'));
Grand_Scatter = [];
for counter = 1:length(filenames)
beh_data = [];
beh_data = load(filenames(counter).name); %Load participant data
if counter > 1
beh_data(:,3) = [];
end
%Check if learner
learner_check = find(beh_data(:,2)== 2);
if isempty(learner_check) == 1
learner(counter,1) = 0;
elseif beh_data(learner_check(1,1),7) < 90
learner(counter,1) = 0;
else
learner(counter,1) = 1;
end
%Find conflict and no conflict
findc1 = find(beh_data(:,9)==4); %low conflict
findc2 = find(beh_data(:,9)==3); %high conflict
%Find RT for conflict conditions
c1_Rt = beh_data(findc1,6);
c2_Rt = beh_data(findc2,6);
%Find accuracy for conflict conditions
c1_ac = beh_data(findc1,10);
c2_ac = beh_data(findc2,10);
%Find confidence for conflict conditions
c1_con = beh_data(findc1,11);
c2_con = beh_data(findc2,11);
%Mean Rt
d_stats(counter,1) = mean(c1_Rt);
d_stats(counter,2) = mean(c2_Rt);
%Mean Accuracy
d_stats(counter,3) = mean(c1_ac);
d_stats(counter,4) = mean(c2_ac);
%Mean Confidence
d_stats(counter,5) = mean(c1_con);
d_stats(counter,6) = mean(c2_con);
%STD Rt
d_stats(counter,7) = std(c1_Rt);
d_stats(counter,8) = std(c2_Rt);
%STD Accuracy
d_stats(counter,9) = std(c1_ac);
d_stats(counter,10) = std(c2_ac);
%STD Confidence
d_stats(counter,11) = std(c1_con);
d_stats(counter,12) = std(c2_con);
end
keep = find(learner==1);
kept_stats = d_stats(keep,:);
%CI(:,1) = mean(kept_stats(:,1))+ 1.96 * (mean(kept_stats(:,7) / sqrt(keep)));
%CI(:,2) = mean(kept_stats(:,2))+ 1.96 * (mean(kept_stats(:,8) / sqrt(keep)));
%CI(:,3) = mean(kept_stats(:,3))+ 1.96 * (mean(kept_stats(:,9) / sqrt(keep)));
%CI(:,4) = mean(kept_stats(:,4))+ 1.96 * (mean(kept_stats(:,10) / sqrt(keep)));
%CI(:,5) = mean(kept_stats(:,5))+ 1.96 * (mean(kept_stats(:,11) / sqrt(keep)));
%CI(:,6) = mean(kept_stats(:,6))+ 1.96 * (mean(kept_stats(:,12) / sqrt(keep)));
%CIrt = [CI(10,1)*1000 CI(10,2)];
rTime = mean(kept_stats(:,1:2))*1000;
subplot(1,3,1)
c=bar(rTime); ylim([3000 5500]); xticklabels(['No Conflict','High conflict']); title('Reaction Time');
hold on
c.FaceColor= 'flat';
c.CData(2,:) = [.9 .3 .3];
ax = gca;
set(ax,'box','off');
ax.FontName = 'Arial';
ax.FontSize = 7.5;
ax.TickLength = [0 0];
hold on
errorbar(1:2, rTime, CIrt, 'k', 'LineStyle', 'none');
hold off
hold off
subplot(1,3,2)
bar(mean(kept_stats(:,3:4))*100); ylim([0 100]); xticklabels(['No Conflict','High conflict']); title('Accuracy');
hold on
subplot(1,3,3)
bar(mean(kept_stats(:,5:6))); ylim([7 10]); xticklabels(['No Conflict','High conflict']); title('Confidence');
clear all;
clc;
%Participant Number, Phase, ((Block)), Block, Trial, Total Trial, Reaction Time, Last Block Accuracy, Disease, Condition, Accuracy, etc
% 1,4,5,11,18,19,20,22,23,24,25,27,34,37,48:Non learners
filenames = dir(strcat('*.txt'));
Grand_Scatter = [];
for counter = 1:length(filenames)
beh_data = [];
beh_data = load(filenames(counter).name); %Load participant data
if counter > 1
beh_data(:,3) = [];
end
%Check if learner
learner_check = find(beh_data(:,2)== 2);
if isempty(learner_check) == 1
learner(counter,1) = 0;
elseif beh_data(learner_check(1,1),7) < 90
learner(counter,1) = 0;
else
learner(counter,1) = 1;
end
%Find conflict and no conflict
findc1 = find(beh_data(:,9)==4); %low conflict
findc2 = find(beh_data(:,9)==3); %high conflict
%Find RT for conflict conditions
c1_Rt = beh_data(findc1,6);
c2_Rt = beh_data(findc2,6);
%Find accuracy for conflict conditions
c1_ac = beh_data(findc1,10);
c2_ac = beh_data(findc2,10);
%Find confidence for conflict conditions
c1_con = beh_data(findc1,11);
c2_con = beh_data(findc2,11);
%Mean Rt
d_stats(counter,1) = mean(c1_Rt);
d_stats(counter,2) = mean(c2_Rt);
%Mean Accuracy
d_stats(counter,3) = mean(c1_ac);
d_stats(counter,4) = mean(c2_ac);
%Mean Confidence
d_stats(counter,5) = mean(c1_con);
d_stats(counter,6) = mean(c2_con);
%STD Rt
d_stats(counter,7) = std(c1_Rt);
d_stats(counter,8) = std(c2_Rt);
%STD Accuracy
d_stats(counter,9) = std(c1_ac);
d_stats(counter,10) = std(c2_ac);
%STD Confidence
d_stats(counter,11) = std(c1_con);
d_stats(counter,12) = std(c2_con);
end
keep = find(learner==1);
kept_stats = d_stats(keep,:);
%CI(:,1) = mean(kept_stats(:,1))+ 1.96 * (mean(kept_stats(:,7) / sqrt(keep)));
%CI(:,2) = mean(kept_stats(:,2))+ 1.96 * (mean(kept_stats(:,8) / sqrt(keep)));
%CI(:,3) = mean(kept_stats(:,3))+ 1.96 * (mean(kept_stats(:,9) / sqrt(keep)));
%CI(:,4) = mean(kept_stats(:,4))+ 1.96 * (mean(kept_stats(:,10) / sqrt(keep)));
%CI(:,5) = mean(kept_stats(:,5))+ 1.96 * (mean(kept_stats(:,11) / sqrt(keep)));
%CI(:,6) = mean(kept_stats(:,6))+ 1.96 * (mean(kept_stats(:,12) / sqrt(keep)));
%CIrt = [CI(10,1)*1000 CI(10,2)];
rTime = mean(kept_stats(:,1:2))*1000;
subplot(1,3,1)
c=bar(rTime); ylim([3000 5500]); xticklabels(['No Conflict','High conflict']); title('Reaction Time');
hold on
c.FaceColor= 'flat';
c.CData(2,:) = [.9 .3 .3];
ax = gca;
set(ax,'box','off');
ax.FontName = 'Arial';
ax.FontSize = 7.5;
ax.TickLength = [0 0];
hold on
errorbar(1:2, rTime, CIrt, 'k', 'LineStyle', 'none');
hold off
hold off
subplot(1,3,2)
bar(mean(kept_stats(:,3:4))*100); ylim([0 100]); xticklabels(['No Conflict','High conflict']); title('Accuracy');
hold on
subplot(1,3,3)
bar(mean(kept_stats(:,5:6))); ylim([7 10]); xticklabels(['No Conflict','High conflict']); title('Confidence');
April, 2020
Since my last entry, I have made a lot of Matlab progress. I am now fully comfortable with behavioural data anaylsis in Matlab, including data wrangling, batch analysis, and statistics. My next goals are being fully self-sufficent in EEG pre- and post-processing, including data visualisation. I'm currenlty working on my next study involving feedback in reward learning, and will be conducting the EEG analysis with as much autonomy as possible. This means processing, plotting, and statistics on EEG signals will be all me. Sorry for anyone who has to see my first attempt at that. Below is my final behavioural analysis code for MDM.
Since my last entry, I have made a lot of Matlab progress. I am now fully comfortable with behavioural data anaylsis in Matlab, including data wrangling, batch analysis, and statistics. My next goals are being fully self-sufficent in EEG pre- and post-processing, including data visualisation. I'm currenlty working on my next study involving feedback in reward learning, and will be conducting the EEG analysis with as much autonomy as possible. This means processing, plotting, and statistics on EEG signals will be all me. Sorry for anyone who has to see my first attempt at that. Below is my final behavioural analysis code for MDM.
Project 2- Complex EEG Analysis In Matlab
May, 2020
The next obvious step in my MATLAB journal is full, in-depth EEG analysis in MATLAB. Its best to learn by doing, so I am analyzing data from my next solo paper myself in MATLAB. This experiment was a standard two-armed bandits task but with an additional condition where we added a key manipulation (paper isn't done yet, no spoilers). For this project, not only will I have to pre-process over 30 participants with 64 channels of data each, but I'll also have some complex post-processing steps based on the story we're telling with this paper. Using the TAN Lab's EEG analysis repositories, found here, I will have to create a pre-procesing script, create a 4-D matrix with all of the participant's processed data, and create more code to run statistical analysis on this matrix. I also plan to implement spatiotemporal Principal Components Analysis on my data, which will add a great deal of complexity to my analysis code.
The next obvious step in my MATLAB journal is full, in-depth EEG analysis in MATLAB. Its best to learn by doing, so I am analyzing data from my next solo paper myself in MATLAB. This experiment was a standard two-armed bandits task but with an additional condition where we added a key manipulation (paper isn't done yet, no spoilers). For this project, not only will I have to pre-process over 30 participants with 64 channels of data each, but I'll also have some complex post-processing steps based on the story we're telling with this paper. Using the TAN Lab's EEG analysis repositories, found here, I will have to create a pre-procesing script, create a 4-D matrix with all of the participant's processed data, and create more code to run statistical analysis on this matrix. I also plan to implement spatiotemporal Principal Components Analysis on my data, which will add a great deal of complexity to my analysis code.