Browse Source

Upload files to 'raw_code'

Manuel Schottdorf 4 years ago
parent
commit
0ba6161f23
1 changed files with 66 additions and 0 deletions
  1. 66 0
      raw_code/plot_single_experiment.py

+ 66 - 0
raw_code/plot_single_experiment.py

@@ -0,0 +1,66 @@
+from pylab import *
+import numpy as np
+import scipy as sp
+from NeuroTools.analysis import crosscorrelate
+from Helpers.file_helpers import data_dictionary_di
+
+
+savepath = '/home/manuel/bla/OptoGeneticsData/Lightdisco_raw/'
+path_for_figures = '/home/manuel/Holo_project/single_elements/extraction_viola/'
+
+ex = 24 #23 DIV Control
+#~ ex = 4  #23 DIV Disco
+
+
+di = data_dictionary_di(ex)
+
+saveresults = savepath + 'rawdata_' + str(ex)
+a = np.load(saveresults + '.npy')
+final_results = a.item()
+elenumber = final_results['data_dict']['elenumber']
+data = final_results['electrode_data']
+good_channels_file = di[ex]['channels']
+
+
+figure(1,figsize = (15,15))
+counter = 1
+for k1 in good_channels_file[:12]:
+    for k2 in good_channels_file[:12]:
+        spikes1 = data['Electrode_' + str(k1)]
+        spikes2 = data['Electrode_' + str(k2)]
+        subplot(12,12,counter)
+        corr_data = crosscorrelate(spikes1,spikes2,lag=5)[0]
+        ls = np.histogram(corr_data,bins = np.arange(-.5,.5,0.01))   #plots the spiek train crosscorrelation between -10 and 10sec
+        if np.sum(ls[0]) > 500:
+            plot(np.arange(-.495,.495,0.01),(1.*ls[0])/np.max(ls[0]))
+        axis('off')
+        ylim([0,1])
+        counter = counter + 1
+savefig(path_for_figures + 'crosscorrelogram_' + str(ex) + '.pdf', bbox_inches='tight')
+close()
+
+figure(2, figsize = (15,5))
+counter = 1
+for k1 in good_channels_file:
+    spikes1 = data['Electrode_' + str(k1)]
+    plot(spikes1-500,counter*np.ones(len(spikes1)),'k|')
+    counter = counter + 1
+    xlim([0,60])
+    
+ylim([-1,counter])
+xlabel('Time [s]')
+ylabel('Channel')
+savefig(path_for_figures + 'spiketrain_' + str(ex) + '.pdf', bbox_inches='tight')
+close()
+
+figure(3, figsize = (7.5,5))
+for k1 in good_channels_file:
+    spikes = data['Electrode_' + str(k1)]
+    n, bins, patches = hist(np.diff(spikes),np.linspace(0,1,100), alpha=0.5,normed = False, label = str(k1))
+    setp(patches, 'facecolor', 'g', 'alpha', 0.5)
+xlim([0,.5])
+xlabel('ISI [s]')
+ylabel('Number [not normalized]')
+savefig(path_for_figures + 'isi_hist_' + str(ex) + '.pdf', bbox_inches='tight')
+close()
+