Commit c41ee8b5 authored by Amit Goldenberg's avatar Amit Goldenberg

a few minor changes to andero's analysis

parent 1574e180
function trialdata = AngerTrial1_firstround_eeg
% Amit Goldenberg
% original copy - Erik Nook\Jamil Zaki
% James Gross
%Script for the Food Conformity fMRI study - Run 1
%Instructions; 150 trials of food conformity study (all conditions
%decided "on the fly"); Instructions to contact experimenter
%Runs a trial of the Food Study where participants are shown an image of
%food, rate how much they want to eat it and are given feedback that the
%group did want to eat it.
global RT pics subject_id studydir data exp_screen bgcolor textcolor markercolor text_size cross_size windowptr framewidth wWidth wHeight xcenter ycenter bottom_all top_all left_all right_all image_lb image_rb image_tb image_bb runstart left_1 right_1 left_2 right_2 left_3 right_3 left_4 right_4 left_5 right_5 left_6 right_6 left_7 right_7 left_8 right_8 box_1 box_2 box_3 box_4 box_5 box_6 box_7 box_8 gbox_1 gbox_2 gbox_3 gbox_4 gbox_5 gbox_6 gbox_7 gbox_8 agreeplace normBoundsRectplus normBoundsRectminus difftext_size top_difftext cond orate counter food rate rateboxcolor groupboxcolor pictime ratetime grouptime waittime t c
% %Group rating
% this is just a screen that shows the image and the ratings
Screen ('PutImage', windowptr, pics{t}, [image_lb image_tb image_rb image_bb]); %displays image
Screen('TextSize', windowptr, text_size); %Set textsize XXX
Screen('TextColor', windowptr, [100 100 100]);%Set text color
Screen('Drawtext',windowptr,'1',left_1,top_all);
Screen('Drawtext',windowptr,'2',left_2,top_all);
Screen('Drawtext',windowptr,'3',left_3,top_all);
Screen('Drawtext',windowptr,'4',left_4,top_all);
Screen('Drawtext',windowptr,'5',left_5,top_all);
Screen('Drawtext',windowptr,'6',left_6,top_all);
Screen('Drawtext',windowptr,'7',left_7,top_all);
Screen('Drawtext',windowptr,'8',left_8,top_all);
while (GetSecs - runstart) < c % while the curent time minus the starting time is lower than c (which is equal to 10 leadin)
WaitSecs(.01);
end
% this flips the screen but I am not sure what is the meaning of the groupt
% to my understanding the meaning of it is to define the time. We therefore
% need to use this to define the time. Look at line 104 they are doing it
% there
[groupt] = Screen('Flip', windowptr);
NetStation('Synchronize', 10);
NetStation('Event', 'PIC1'); % at this point in time c is equal to 10.
%%%% i need to figure this one out cause the order changed and I am not
%%%% sure how to record the rating as before. This is something that I
%%%% should go over with golijeh
%if isnan(ratet)
% ratet = groupt; %if jitter is 0
%end
c = c+grouptime; % at this time c is equal to c + the time it too the
% this is where the participants rate.
%pic + rating load the picture (first line ) and put the rating on
Screen ('PutImage', windowptr, pics{t}, [image_lb image_tb image_rb image_bb]); %displays image
Screen('TextSize', windowptr, text_size); %Set textsize XXX
Screen('TextColor', windowptr, textcolor);%Set text color
Screen('Drawtext',windowptr,'1',left_1,top_all);
Screen('Drawtext',windowptr,'2',left_2,top_all);
Screen('Drawtext',windowptr,'3',left_3,top_all);
Screen('Drawtext',windowptr,'4',left_4,top_all);
Screen('Drawtext',windowptr,'5',left_5,top_all);
Screen('Drawtext',windowptr,'6',left_6,top_all);
Screen('Drawtext',windowptr,'7',left_7,top_all);
Screen('Drawtext',windowptr,'8',left_8,top_all);
while (GetSecs - runstart) < c
WaitSecs(.01);
end
c=c+pictime; % this is the picture time
% we are flipping the screen and getting the rating.
[pict] = Screen('Flip', windowptr);
NetStation('Synchronize', 10);
NetStation('Event', 'PIC2' ); % at this time c is equal to group time plus the value
disp(pict);
%creating a variable called noresp which is equal to 1
noresp=1;
while noresp == 1,
[keyIsDown,secs,keyCode] = KbCheck(-1); %wait for response
if keyIsDown
disp(num2str(keyIsDown)); % you need to make this into a string in order to record it.
noresp = 0;%break out of loop
RT = secs - pict;%get response time
NetStation('Synchronize', 10);
NetStation('Event', 'RAT1');
%if participant had pressed the botton, we are going to define it
%as rate.
key = KbName(keyCode);
if strcmp(key,'1!')==1
rate = 1;
Screen('FrameRect', windowptr, rateboxcolor, box_1, framewidth);
elseif strcmp(key,'2@')==1
rate = 2;
Screen('FrameRect', windowptr, rateboxcolor, box_2, framewidth);
elseif strcmp(key,'3#')==1
rate = 3;
Screen('FrameRect', windowptr, rateboxcolor, box_3, framewidth);
elseif strcmp(key,'4$')==1
rate = 4;
Screen('FrameRect', windowptr, rateboxcolor, box_4, framewidth);
elseif strcmp(key,'5%')==1
rate = 5;
Screen('FrameRect', windowptr, rateboxcolor, box_5, framewidth);
elseif strcmp(key,'6^')==1
rate = 6;
Screen('FrameRect', windowptr, rateboxcolor, box_6, framewidth);
elseif strcmp(key,'7&')==1
rate = 7;
Screen('FrameRect', windowptr, rateboxcolor, box_7, framewidth);
elseif strcmp(key,'8*')==1
rate = 8;
Screen('FrameRect', windowptr, rateboxcolor, box_8, framewidth);
else noresp = 1;
RT = NaN;
rate = NaN;
% we should think about it more on whether we want to
% diffrentiate between these two things.
end
end
if GetSecs - pict > (pictime-0.001)
noresp = 0;
RT = NaN;
rate = NaN;
end
end
% this is the condition if response is not given.
%Participant's Rating + Pic within pictime (if response given)
if ~isnan(rate)
Screen ('PutImage', windowptr, pics{t}, [image_lb image_tb image_rb image_bb]); %displays image
Screen('Drawtext',windowptr,'1',left_1,top_all);
Screen('Drawtext',windowptr,'2',left_2,top_all);
Screen('Drawtext',windowptr,'3',left_3,top_all);
Screen('Drawtext',windowptr,'4',left_4,top_all);
Screen('Drawtext',windowptr,'5',left_5,top_all);
Screen('Drawtext',windowptr,'6',left_6,top_all);
Screen('Drawtext',windowptr,'7',left_7,top_all);
Screen('Drawtext',windowptr,'8',left_8,top_all);
%Frames are drawn above...
Screen('Flip', windowptr);
end
%Participant's Rating + pic (if jitter ~= 0) $ this deoens't matter for us
if data(t,17) ~=0
Screen ('PutImage', windowptr, pics{t}, [image_lb image_tb image_rb image_bb]); %displays image
Screen('Drawtext',windowptr,'1',left_1,top_all);
Screen('Drawtext',windowptr,'2',left_2,top_all);
Screen('Drawtext',windowptr,'3',left_3,top_all);
Screen('Drawtext',windowptr,'4',left_4,top_all);
Screen('Drawtext',windowptr,'5',left_5,top_all);
Screen('Drawtext',windowptr,'6',left_6,top_all);
Screen('Drawtext',windowptr,'7',left_7,top_all);
Screen('Drawtext',windowptr,'8',left_8,top_all);
% this is just a code that shows the rectangle around the rating
if rate == 1
Screen('FrameRect', windowptr, rateboxcolor, box_1, framewidth);
elseif rate == 2
Screen('FrameRect', windowptr, rateboxcolor, box_2, framewidth);
elseif rate == 3
Screen('FrameRect', windowptr, rateboxcolor, box_3, framewidth);
elseif rate == 4
Screen('FrameRect', windowptr, rateboxcolor, box_4, framewidth);
elseif rate == 5
Screen('FrameRect', windowptr, rateboxcolor, box_5, framewidth);
elseif rate == 6
Screen('FrameRect', windowptr, rateboxcolor, box_6, framewidth);
elseif rate == 7
Screen('FrameRect', windowptr, rateboxcolor, box_7, framewidth);
elseif rate == 8
Screen('FrameRect', windowptr, rateboxcolor, box_8, framewidth);
end
while (GetSecs - runstart) < c
WaitSecs(.01);
end
[ratet] = Screen('Flip', windowptr);
else
ratet = NaN; %if jitter = 0
end
c = c+data(t,17);
% I should att the time of the rating as NAN as they
food = data(t,4); % specifying the condition this particular image belongs to and define food
generateotherresponse_test; % activate function that gets the response (which I should be working on)
data(t,2) = cond; % after the actication we define the condition
data(t,16) = orate; % generate the group ratings.
if data(t,18) ~=0 % this shows the cross jitter
Screen('TextSize', windowptr, cross_size); %Set textsize XXX
DrawFormattedText(windowptr, '+', 'center', 'center', 255, 70, 0, 0, 1.5);%Draw text
while (GetSecs - runstart) < c
WaitSecs(.01);
end
Screen('Flip', windowptr);
NetStation('Synchronize', 10);
NetStation('Event', 'CROS' ); % at this time c is equal to group time plus the value
c = c+data(t,18);
end
% if isnan(RT) %Jitter
% c = c+waittime;
% else
% c = c+waittime+waittime-RT;
% end
picot = pict - runstart;
rateot = picot + RT;
%groupot = groupt - runstart;
disp('here5');
disp(picot);
disp(rateot);
%this is the output of this script that is mapped back to data
trialdata = [rate,RT,picot,rateot]; %trialdata = [rate,RT,picot,rateot,groupot];
% I have created a trialdata that does not include the last variable. 6
%trialdata = [rate,RT,picot,rateot];
size(trialdata)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -47,18 +47,26 @@ We assume that these features of individual-social mismatch trigger two differen
```
```{r IMPORT DATA, include=FALSE}
#Amit's folder
setwd("C:/Users/Amit/Dropbox/Research/emotional conformity-non conformity/motivated_contation_EEG_2017/Results")
# setwd("C:/Users/Amit/Dropbox/Research/emotional conformity-non conformity/motivated_contation_EEG_2017/Results")
setwd("C:/Users/ro/Desktop")
#andero's folder
#setwd("C:/Users/ro/Desktop")
d <- read.csv2("export.csv")
d <- read.csv2("eeg_data_motivated_contagion_revised version2.9.17.csv")
# remove group ratings from "none" conditions
head(d)
d$grate = ifelse(d$grate == 0, NA, d$grate)
# remove strange trials
d <- d[d$rate %in% c(1:7),]
d$rt <- as.numeric(as.character(d$rt))
head(d)
# reshape
colnames(d) <- as.character(lapply(colnames(d), function(x) strsplit(x,"_")[[1]][1]))
head(d)
base <- d[,c(1:which(colnames(d)=="Subject"))]
alpha <- merge(base,gather(d,window, alpha, alpha1:alpha4)[,c("Subject", "urevent", "window", "alpha")],c("Subject", "urevent"))
......@@ -139,6 +147,10 @@ We assume that these features of individual-social mismatch trigger two differen
ersp$delta.dif <- lm(delta.social ~ delta.indiv,ersp)$residuals
head(erp)
colnames(d)
```
# ANALYTIC VARIABLES
......@@ -152,6 +164,9 @@ ggplot(base,aes(x=rate.indiv, y = grate, color = condition)) + geom_jitter() + g
We kind of have a dilemma. On the one hand, we could stick to analyzing the conditions. On the other hand, each conditions contains quite a bit of variance so we could also treat the group rating as a continuous variable. The added benefit of the continuous approach is that we don't have to worry about if the conditions are perfectly balanced after we've lost trials due to EEG preprocessing.
#amit's comment: I vote for grate as a countious.
Now, if we wanted to use continuous independent variables, which ones make the most sense?
* Generally, we want to have a variables that gives us the individual response and other(s) that map to the different motivational concerns.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment