def plot_seq_effects(self): for t,tag in enumerate(self.tags): # Analyze each individual trial code (i.e. what was the previous trial?) data_mean, data_sem = emergent.group_batch(self.data_settled[tag], ['prev_trial_code', 'inhibited', 'SS_presented']) # Select those where a response was made and no stop signal was presented idx = (data_mean['inhibited'] == 0.0) & (data_mean['SS_presented'] == 0.0) & ((data_mean['prev_trial_code'] != 1) ) #data_mean[idx]['prev_trial_code'] plt.errorbar([0,1,2], data_mean[idx]['minus_cycles']*self.ms, color=self.colors[t], yerr=data_sem[idx]['minus_cycles']*self.ms, label=tag, lw=3) #plt.title('RTs depending on previous trial') plt.xticks(np.arange(len(self.pt_code.values())), self.pt_code.values()) plt.ylabel('RTs (ms)') plt.xlabel('Previous Trial Type') plt.legend(loc=0) plt.xlim((-.5, 2.5))
def analyze_act_stim_onset(self, name='SC', field='Thalam_unit_corr', tag='intact'): start_cycle = 0 wind = (0,125) #wind = (100,100) # From emergent, SC threshold: data_grp_mean, data_grp_sem = emergent.group_batch(self.data['trl'][tag], ['SS_presented']) idx = data_grp_mean['SS_presented'] == 1 SSD = np.median(self.data_settled[tag]['SSD']) ss_resp = self.extract_cycles( tag, ((self.data['trl'][tag]['SS_presented'] == 1) & (self.data['trl'][tag]['inhibited'] == 0) & (self.data['trl'][tag]['epoch'] > 30) & (self.data['trl'][tag]['SSD'] == SSD)), field, cycle=start_cycle, #center='SSD', wind=wind) ss_inhib = self.extract_cycles( tag, ((self.data['trl'][tag]['SS_presented'] == 1) & (self.data['trl'][tag]['inhibited'] == 1) & (self.data['trl'][tag]['epoch'] > 30) & (self.data['trl'][tag]['SSD'] == SSD)), field, cycle=start_cycle, #center='SSD', wind=wind) x=np.linspace(wind[0]+start_cycle,wind[1]+start_cycle,np.sum(wind)+1)*self.ms #thr_cross = np.where(np.mean(thalam_ss_resp, axis=0) > thr)[0][0] plt.plot(x, np.mean(ss_inhib, axis=0), label='canceled stop trials', color='.7', lw=3.) plt.plot(x, np.mean(ss_resp, axis=0), label='non-canceled stop trials', color='k', lw=3.) plt.axhline(y=self.SC_thr, color='k', lw=3., linestyle='-.') #plt.axvline(x=thr_cross, color='k') #plt.axvline(x=np.mean(self.SSD['intact'])+np.mean(self.SSRT['intact']), color='k') #plt.axvline(x=np.mean(self.SSD['intact']), color='k') plt.axvline(x=SSD*self.ms, color='k', lw=3.) plt.axvline(x=(SSD + np.mean(self.SSRT[tag]))*self.ms, color='k', linestyle='--', lw=2.) plt.ylim(0,1) plt.xlabel('Time from Target Onset (ms)') plt.ylabel('%s activity' % name) #plt.title('SC activity during inhibited and not-inhibited stop trials: %s'%tag) plt.legend(loc=0)
def analyze_SC_act_ind(self, SSDs=None, tag=None, plot_ind=False): if tag is None: tag = 'intact' wind = (0,100) start_cycle = 25 skip_epochs = 20 if SSDs is None: SSDs = np.unique(self.data['trl']['intact']['SSD']) for SSD in SSDs: data_grp_mean, data_grp_sem = emergent.group_batch(self.data['trl'][tag], ['SS_presented']) idx = data_grp_mean['SS_presented'] == 1 SSD_mean = data_grp_mean[idx]['SSD'] # Select responded and inhibited trials resp = ((self.data['trl'][tag]['inhibited'] == 0) & (self.data['trl'][tag]['SSD'] == SSD) & (self.data['trl'][tag]['epoch'] > skip_epochs)) ss_resp = ((self.data['trl'][tag]['SS_presented'] == 1) & (self.data['trl'][tag]['inhibited'] == 0) & (self.data['trl'][tag]['SSD'] == SSD) & (self.data['trl'][tag]['epoch'] > skip_epochs)) ss_inhib = ((self.data['trl'][tag]['SS_presented'] == 1) & (self.data['trl'][tag]['inhibited'] == 1) & (self.data['trl'][tag]['SSD'] == SSD) & (self.data['trl'][tag]['epoch'] > skip_epochs)) # Calculate proportion of inhibited vs error trials mean_ss_resp = (np.sum(ss_inhib)/np.sum(((self.data['trl'][tag]['SS_presented'] == 1) & (self.data['trl'][tag]['SSD'] == SSD) & (self.data['trl'][tag]['epoch'] > skip_epochs)))) print "Mean responded trials: %f" % mean_ss_resp if mean_ss_resp == 0. or mean_ss_resp == 1.: continue # No need to plot SSDs to which no or all responses where inhibited. self.new_fig() thalam_ss_resp = self.extract_cycles(tag, resp, 'Thalam_unit_corr', cycle=start_cycle, wind=wind) thalam_ss_inhib = self.extract_cycles(tag, ss_inhib, 'Thalam_unit_corr', cycle=start_cycle, wind=wind) x=np.linspace(wind[0]+start_cycle,wind[1]+start_cycle,np.sum(wind)+1) #thr_cross = np.where(np.mean(thalam_ss_resp, axis=0) > thr)[0][0] self.plot_filled(x, thalam_ss_inhib, label='SS_inhib', color='g') self.plot_filled(x, thalam_ss_resp, label='SS_resp', color='r') plt.axhline(y=self.SC_thr, color='k') plt.axvline(x=SSD, color='k') plt.axvline(x=SSD + np.mean(self.SSRT['intact']), color='k') plt.xlabel('Stop-Signal') plt.ylabel('Average SC activity') plt.title('SC activity during inhibited and not-inhibited stop trials\n: %s, SSD: %i, mean response rate: %f'%(tag, SSD, mean_ss_resp)) plt.legend(loc=0) if plot_ind: self.new_fig() self.plot_filled(x, thalam_ss_inhib, avg=False, label='SS_inhib', color='g') self.plot_filled(x, thalam_ss_resp, avg=False, label='SS_resp', color='r') plt.axhline(y=self.SC_thr, color='k') plt.axvline(x=SSD, color='k') plt.axvline(x=SSD + np.mean(self.SSRT['intact']), color='k') plt.xlabel('Stop-Signal') plt.ylabel('Average SC activity') plt.title('SC activity during inhibited and not-inhibited stop trials\n: %s, SSD: %i, mean response rate: %f'%(tag, SSD, mean_ss_resp))