Commit 625ca4c0 authored by laurencehunt's avatar laurencehunt
Browse files

add session 4

parent d3e22813
No preview for this file type
......@@ -15,7 +15,7 @@ clear all;close all; % close any open figures and delete variables
% load it in the same way as we did for the simulated data in week 2.
% Adjust the basepath to your directory
basepath='/Users/laurence/Dropbox/Private/teaching/WIN_Grad_Programme/2019/win-computational-models-2019/Session3/';
basepath='/Users/lhunt/Dropbox/Private/teaching/WIN_Grad_Programme/2019/win-computational-models-2019/Session3/';
load(fullfile(basepath,'data.mat'));
warning off;
......@@ -119,7 +119,7 @@ data.discardSubj = sum([abs(AccZscored) abs(meanRTZscored)' abs(stdRTZscored)']>
% Add one line of code here to check how many subjects were excluded with the threshold we used
% the command 'find' might be useful which finds any element of a vector that
% is not zero
keyboard %LINE TO BE ADDED BY STUDENT
find(data.discardSubj) %LINE TO BE ADDED BY STUDENT
% This plots a red circle on top of the mean accuracy IF there is a
% subject that is an outlier
......@@ -280,7 +280,7 @@ end
% Please insert here one line that saves the mean of the best parameter
% estimates across subjects in a variable called meanBestParam; we can
% then use that mean to initialize fminsearch in the next cell
meanBestParam = []; %LINE TO BE COMPLETED BY STUDENT
meanBestParam = mean(bestParams); %LINE TO BE COMPLETED BY STUDENT
%% 3.3 MODEL FITTING USING FMINSEARCH
%% 3.3.1 Fitting two learning rates and one beta
......
%% Section 1: Understanding haemodynamic convolution (hrf)
% Make the hrf
window = 14; % how much time (in s) to display
TR = 1; % what the time between FMRI volumes was
sigma1 = 3; % parameter for the shape of the hrf
my1 = 7; % parameter for hrf shape
alpha1=my1^2/sigma1^2;
beta1=my1/sigma1^2;
% Code the HRF
t=0:(TR):(window); % create the time window (from 0 s to 14s) for which to show the hrf
hrf = gammapdf(alpha1,beta1,t); % create the hrf
% Plot the hrf shape
figure('name','Convolution','color',[1 1 1]);
subplot(2,1,1);hold on;
plot(hrf,'Linewidth',3);set(gca,'Fontsize',16);title('HRF function')
% Create an example set of events
event_times = [50 100 150 160 170 180 190 200 303 306 309 312 315 330]; % onsets of the events
event_duration= [0 30 0 0 0 0 0 0 0 0 0 0 0 0]; % duration of events
event_values = [1 1 2 1 1 1 1.5 2 1 1 1 1 1 -1]; % event values
% Create a vector that has for every time point whether there is an event
% or not (and the size and direction of the event)
nT = 400; %total number of timepoints in our fake FMRI data
regressor = zeros(nT,1); % the vector to be filled
for i = 1:length(event_times)
regressor(event_times(i):event_times(i)+event_duration(i)) = event_values(i);
end
% Convolve the vector with the hrf
convolved_regressor = conv(regressor,hrf);
% Plot the resulting vector
subplot(2,1,2)
plot(regressor,'k','Linewidth',3);hold on;plot(convolved_regressor,'Linewidth',3)
legend('unconvolved regressor','convolved regressor');set(gca,'Fontsize',16);title('Convolved and unconvolved regressors')
\ No newline at end of file
7.5332 2.0158 1
20.994 1.0162 1
41.685 1.0163 1
58.478 1.0162 1
73.504 1.516 1
103.96 1.0162 1
117.27 1.0162 1
131.43 2.0157 1
160.2 2.0158 1
174.18 1.516 1
191.2 1.516 1
203.95 2.0157 1
227.79 1.516 1
244.1 1.516 1
264.44 2.0158 1
282.95 2.0158 1
296.17 2.0158 1
312.02 1.0162 1
329.39 1.516 1
342.15 1.0163 1
362.98 1.0162 1
376.4 1.5161 1
401.26 1.516 1
442.01 1.0163 1
490.82 2.0157 1
504.25 1.516 1
518.21 1.0162 1
547.16 1.0162 1
572.63 2.0158 1
604.45 2.0158 1
623.86 2.0158 1
638.07 2.0157 1
665.53 1.0162 1
705.24 2.0158 1
723.68 1.0162 1
743.07 2.0158 1
787.74 1.516 1
801.98 1.5159 1
821.27 2.0158 1
840.32 1.0163 1
880.66 2.0158 1
908.27 1.0163 1
935.69 1.516 1
948.85 1.0162 1
962.48 1.0162 1
984.9 2.0158 1
1001.7 2.0157 1
1015.1 2.0158 1
1053.1 1.516 1
1072 1.516 1
1087.9 1.0162 1
1112.8 2.0158 1
1166.5 2.0158 1
1183.1 1.0162 1
1212.6 2.0158 1
1239.4 1.0162 1
1282.3 1.0163 1
1296.8 2.0157 1
1312.6 2.0157 1
1333.3 1.516 1
1352.3 1.0162 1
1367.8 1.516 1
1381.3 1.0162 1
1403.3 2.0158 1
1420.5 1.0162 1
1452.3 1.0162 1
1489.6 1.0162 1
1508.4 1.0163 1
1520.2 2.0158 1
1534 1.516 1
1563.9 1.0162 1
1578.5 1.516 1
1599.6 1.0162 1
1612.7 1.516 1
1629.4 1.516 1
1641.7 1.516 1
1655.6 2.0158 1
1676.3 2.0158 1
1695.1 1.0163 1
1712.1 1.516 1
1740.1 2.0158 1
1755.3 1.516 1
1770.8 1.516 1
1791 1.516 1
1809.5 1.0162 1
1829.9 1.516 1
1856.1 1.0162 1
1868.3 1.516 1
1907.8 1.0162 1
1938.7 1.0162 1
1956.4 2.0158 1
1976.2 1.516 1
1993.4 1.0162 1
2011 1.0162 1
2049.8 1.516 1
2068.1 1.0162 1
2088.3 2.0158 1
2107.1 1.516 1
2122 2.0158 1
2144 1.0162 1
7.5332 0 1
20.994 0 1
41.685 0 1
58.478 0 1
73.504 0 1
103.96 0 1
117.27 0 1
131.43 0 1
160.2 0 1
174.18 0 1
191.2 0 1
203.95 0 1
227.79 0 1
244.1 0 1
264.44 0 1
282.95 0 1
296.17 0 1
312.02 0 1
329.39 0 1
342.15 0 1
362.98 0 1
376.4 0 1
401.26 0 1
442.01 0 1
490.82 0 1
504.25 0 1
518.21 0 1
547.16 0 1
572.63 0 1
604.45 0 1
623.86 0 1
638.07 0 1
665.53 0 1
705.24 0 1
723.68 0 1
743.07 0 1
787.74 0 1
801.98 0 1
821.27 0 1
840.32 0 1
880.66 0 1
908.27 0 1
935.69 0 1
948.85 0 1
962.48 0 1
984.9 0 1
1001.7 0 1
1015.1 0 1
1053.1 0 1
1072 0 1
1087.9 0 1
1112.8 0 1
1166.5 0 1
1183.1 0 1
1212.6 0 1
1239.4 0 1
1282.3 0 1
1296.8 0 1
1312.6 0 1
1333.3 0 1
1352.3 0 1
1367.8 0 1
1381.3 0 1
1403.3 0 1
1420.5 0 1
1452.3 0 1
1489.6 0 1
1508.4 0 1
1520.2 0 1
1534 0 1
1563.9 0 1
1578.5 0 1
1599.6 0 1
1612.7 0 1
1629.4 0 1
1641.7 0 1
1655.6 0 1
1676.3 0 1
1695.1 0 1
1712.1 0 1
1740.1 0 1
1755.3 0 1
1770.8 0 1
1791 0 1
1809.5 0 1
1829.9 0 1
1856.1 0 1
1868.3 0 1
1907.8 0 1
1938.7 0 1
1956.4 0 1
1976.2 0 1
1993.4 0 1
2011 0 1
2049.8 0 1
2068.1 0 1
2088.3 0 1
2107.1 0 1
2122 0 1
2144 0 1
7.5332 0 0
20.994 0 -0.28417
41.685 0 -0.63042
58.478 0 0.79787
73.504 0 0.10536
103.96 0 0.79787
117.27 0 1.3172
131.43 0 0.40833
160.2 0 0.45161
174.18 0 1.5769
191.2 0 -0.28417
203.95 0 1.5337
227.79 0 1.6202
244.1 0 -0.93339
264.44 0 1.0143
282.95 0 -0.24089
296.17 0 -0.63042
312.02 0 1.0576
329.39 0 0.58146
342.15 0 -0.37073
362.98 0 -0.24089
376.4 0 -1.1065
401.26 0 0.84115
442.01 0 -0.50058
490.82 0 1.4471
504.25 0 0.84115
518.21 0 1.3172
547.16 0 0.53818
572.63 0 -0.93339
604.45 0 -1.5826
623.86 0 0.27849
638.07 0 0.14864
665.53 0 -0.67371
705.24 0 -1.2796
723.68 0 -1.4528
743.07 0 -0.84683
787.74 0 1.5337
801.98 0 -0.37073
821.27 0 1.4471
840.32 0 -1.02
880.66 0 -0.41402
908.27 0 0.19193
935.69 0 0.66802
948.85 0 -1.0632
962.48 0 -0.4573
984.9 0 0.53818
1001.7 0 0.92771
1015.1 0 0.58146
1053.1 0 1.274
1072 0 -1.7557
1087.9 0 1.0143
1112.8 0 0.14864
1166.5 0 1.4904
1183.1 0 0.79787
1212.6 0 -1.5826
1239.4 0 -1.8423
1282.3 0 -0.93339
1296.8 0 1.6202
1312.6 0 0.97099
1333.3 0 -0.76027
1352.3 0 0.62474
1367.8 0 -0.24089
1381.3 0 -0.32745
1403.3 0 1.4038
1420.5 0 -1.799
1452.3 0 0.66802
1489.6 0 -0.67371
1508.4 0 -0.80355
1520.2 0 -0.37073
1534 0 1.2307
1563.9 0 -1.2796
1578.5 0 1.5769
1599.6 0 -1.1498
1612.7 0 -1.2796
1629.4 0 -1.5826
1641.7 0 0.14864
1655.6 0 -0.24089
1676.3 0 -0.84683
1695.1 0 0.19193
1712.1 0 -0.89011
1740.1 0 -0.71699
1755.3 0 0.84115
1770.8 0 1.3605
1791 0 -0.19761
1809.5 0 1.5337
1829.9 0 0.62474
1856.1 0 -1.6692
1868.3 0 0.40833
1907.8 0 0.10536
1938.7 0 -0.93339
1956.4 0 -1.4095
1976.2 0 1.274
1993.4 0 -1.1931
2011 0 -0.63042
2049.8 0 -1.4528
2068.1 0 -0.76027
2088.3 0 0.40833
2107.1 0 0.19193
2122 0 -0.32745
2144 0 0.4949
13.63 2.0158 1
31.323 2.0158 1
51.614 2.0157 1
68.14 1.0163 1
96.094 1.516 1
111.4 1.0162 1
127.06 1.0163 1
152.84 1.0162 1
168.81 2.0158 1
182.34 1.0162 1
197.58 1.516 1
217.92 1.0162 1
235.73 1.0162 1
256.07 1.516 1
276.08 2.0158 1
289.81 1.0162 1
302.65 1.516 1
321.53 2.0157 1
336.29 1.0162 1
348.23 1.516 1
368.04 1.0162 1
392.9 1.516 1
433.15 1.516 1
480.96 2.0158 1
496.88 1.516 1
509.84 2.0158 1
538.8 2.0158 1
566.77 1.516 1
595.09 2.0157 1
614.5 2.0158 1
632.21 1.0163 1
656.66 1.516 1
699.38 1.516 1
718.82 1.516 1
732.71 1.516 1
780.38 1.0162 1
793.62 2.0158 1
810.41 1.516 1
832.95 1.0162 1
870.63 2.0157 1
902.9 1.0162 1
927.33 1.516 1
941.99 1.516 1
954.11 2.0158 1
978.54 1.516 1
995.85 1.516 1
1008.7 1.0162 1
1047.7 1.0162 1
1062.7 2.0158 1
1082.5 1.516 1
1107 1.0163 1
1155.6 2.0158 1
1175.2 1.0162 1
1206.7 1.0162 1
1231 1.0162 1
1275.9 2.0158 1
1286.9 2.0158 1
1302.7 2.0158 1
1325.5 1.0162 1
1341.8 1.0162 1
1360 2.0157 1
1374.9 1.0163 1
1392.9 2.0158 1
1412.1 1.516 1
1446 1.0162 1
1482.2 1.0162 1
1500 1.516 1
1515.3 1.0162 1
1527.7 1.0163 1
1557.5 1.516 1
1571.6 1.0162 1
1589.8 2.0158 1
1607.4 1.0163 1
1622.5 2.0157 1
1636.8 1.0162 1
1650.2 1.0162 1
1670.5 1.516 1
1688.3 2.0158 1
1705.2 1.516 1
1724.5 2.0158 1
1747.4 2.0157 1
1762.4 1.516 1
1784.6 2.0157 1
1801.1 2.0157 1
1822 1.516 1
1849.3 1.0162 1
1862.5 1.0163 1
1899.9 2.0158 1
1931.3 2.0158 1
1947.1 1.516 1
1966.4 2.0157 1
1985 1.516 1
2004.1 1.0162 1
2040.4 2.0158 1
2061.3 1.516 1
2081.4 2.0158 1
2097.3 1.516 1
2114.6 2.0158 1
2138.7 1.0163 1
2162.8 2.0157 1
10.598 0.3166 1
25.792 0.3165 1
49.581 0.3166 1
65.608 0.3165 1
93.062 0.3165 1
107.87 0.3166 1
123.53 0.3165 1
148.8 0.3165 1
163.28 0.3165 1
177.81 0.3166 1
195.55 0.3165 1
212.89 0.3166 1
230.7 0.3166 1
254.04 0.3166 1
269.55 0.3165 1
286.78 0.3166 1
299.62 0.3166 1
317.5 0.3166 1
332.26 0.3165 1
344.2 0.3165 1
366.01 0.3165 1
387.37 0.3165 1
430.61 0.3165 1
474.43 0.3165 1
493.85 0.3166 1
507.81 0.3165 1
535.77 0.3165 1
562.74 0.3166 1
590.06 0.3166 1
608.47 0.3165 1
626.68 0.3165 1
650.13 0.3166 1
695.35 0.3166 1
715.79 0.3165 1
728.18 0.3165 1
774.84 0.3165 1
790.09 0.3165 1
808.38 0.3166 1
830.92 0.3165 1
863.6 0.3166 1
895.87 0.3165 1
922.3 0.3165 1
939.45 0.3166 1
952.08 0.3165 1
975.01 0.3165 1
992.31 0.3165 1
1005.2 0.3165 1
1045.2 0.3166 1
1056.6 0.3165 1
1077.5 0.3165 1
1099.9 0.3165 1
1151.1 0.3165 1
1172.7 0.3166 1
1202.7 0.3165 1
1226.5 0.3165 1
1273.4 0.3165 1
1284.4 0.3165 1
1300.2 0.3165 1
1322 0.3165 1
1337.3 0.3165 1
1354.4 0.3166 1
1371.4 0.3165 1
1386.9 0.3165 1
1408.1 0.3165 1
1442.4 0.3165 1
1478.7 0.3165 1
1495 0.3165 1
1512.3 0.3165 1
1523.6 0.3165 1
1552.5 0.3166 1
1566.1 0.3165 1
1587.2 0.3165 1
1602.8 0.3165 1
1619.5 0.3166 1
1633.8 0.3166 1
1645.7 0.3165 1
1666.4 0.3165 1
1684.7 0.3165 1
1699.2 0.3165 1
1722 0.3165 1
1744.4 0.3166 1
1758.9 0.3165 1
1779.6 0.3166 1
1795.6 0.3166 1
1817.5 0.3165 1
1842.7 0.3165 1
1859.9 0.3165 1
1895.4 0.3165 1
1925.3 0.3165 1
1942 0.3165 1
1961.3 0.3166 1
1979 0.3166 1
2000.1 0.3166 1
2037.4 0.3165 1
2056.7 0.3165 1
2076.9 0.3165 1
2090.7 0.3166 1
2112.6 0.3166 1
2131.6 0.3165 1
2158.7 0.3166 1
15.963 3.5151 1
33.655 6.0141 1
53.946 3.5152 1
69.473 2.0157 1
97.927 4.0149 1
112.74 2.5156 1
128.4 2.0157 1
154.17 4.5147 1
171.14 2.0158 1
183.67 5.5142 1
199.42 3.0154 1
219.26 6.5138 1
237.07 5.0144 1
257.91 5.5142 1
278.41 2.5155 1
291.14 3.5151 1
304.49 6.5137 1
323.86 4.5147 1
337.62 2.5156 1
350.07 5.5142 1
369.37 6.014 1
394.73 5.0144 1
434.98 5.0145 1
483.29 6.014 1
498.72 4.0149 1
512.18 5.0144 1
541.13 4.5147 1
568.6 3.0153 1
597.42 5.0145 1
616.83 6.014 1
633.54 3.5151 1
658.5 5.0144 1
701.21 3.0153 1
720.65 2.0158 1
734.55 7.0135 1
781.71 4.0149 1
795.95 4.0149 1
812.24 7.0135 1
834.28 4.5147 1
872.97 4.0149 1
904.24 3.0153 1
929.16 5.5142 1
943.82 4.0148 1
956.45 4.0149 1
980.37 2.5156 1
997.68 2.0158 1
1010 3.5151 1