|
@@ -4,16 +4,17 @@ Created on Wed Oct 14 11:18:44 2020
|
|
|
|
|
|
@author: kleisp
|
|
|
This is a script for getting matrices of snippets around the stimulation pulses in PACK-expressing mice,
|
|
|
-this can later be used for plotting the snippets on top of each other (in this file below) and for line length calculations (in another file)
|
|
|
-0.1 Hz and 0.05 Hz need to be treated separately
|
|
|
-need to load dictionaries containing recIDs with corresponding smrs for using raw data
|
|
|
+which can later be used for plotting the snippets on top of each other and for line length
|
|
|
+calculations.
|
|
|
+Note that recordings with 0.1 Hz and 0.05 Hz illumination need to be treated separately
|
|
|
+One needs to load dictionaries containing recIDs with corresponding smr filenames for using raw data
|
|
|
+Abbreviations:
|
|
|
dict- dictionary
|
|
|
stim- light pulse
|
|
|
pre- before light pulse
|
|
|
post-after light pulse
|
|
|
snipmat- matrix containing snippets
|
|
|
|
|
|
-
|
|
|
"""
|
|
|
|
|
|
import os
|
|
@@ -29,7 +30,7 @@ os.chdir('C:\EAfiles\EAdetection')
|
|
|
import core.ea_management as eam
|
|
|
reload(eam)
|
|
|
|
|
|
-#%% define functions to extract snippets before and after the stim
|
|
|
+#%% (1) define functions to extract snippets before and after the stim
|
|
|
''' 'pre' or 'post' are the snippet length in seconds, here 2 is used, sr=sampling rate (here 500)'''
|
|
|
|
|
|
# get the spike trace before stimulation (pre):
|
|
@@ -71,7 +72,7 @@ def get_snipmat_post(datatrace, recID, post, stimtimes, sr):
|
|
|
snipmat[tt] = spiketrace
|
|
|
return snipmat
|
|
|
|
|
|
-#%% defining the function to get line length of each snippet(snipmat line length)
|
|
|
+#%% (2) defining the function to get line length of each snippet(snipmat line length)
|
|
|
|
|
|
def get_snipmat_linelength(snipmat_pre, snipmat_post, linelength_dict_pre, linelength_dict_post, recID):
|
|
|
|
|
@@ -118,6 +119,7 @@ def get_snipmat_linelength(snipmat_pre, snipmat_post, linelength_dict_pre, linel
|
|
|
linelength_dict_post[recID]['mean post-pulse linelength/second']=np.mean(linelength_s_list)
|
|
|
linelength_dict_post[recID]['mean post-pulse linelength']=np.mean(linelength_list)
|
|
|
linelength_dict_post[recID]['pulse number']=count
|
|
|
+
|
|
|
#%% in order to exclude unwanted recordings
|
|
|
|
|
|
pathtobadrecIDs = 'C:\EAfiles\ID_Dateien\\badrecIDs.txt'
|
|
@@ -127,7 +129,7 @@ with open (pathtobadrecIDs,'r') as f:
|
|
|
badrecIDs = badrecIDs + badIDs
|
|
|
|
|
|
|
|
|
-#%% Example of using the script to extract the snipmats
|
|
|
+#%% (3) Example of using the script to extract the snipmats
|
|
|
#Saline PACK mice 0.05Hz: get snipmat dicts (for before and after 0.05 Hz pulses) (downsampled data)
|
|
|
|
|
|
os.chdir('C:\EAfiles\EAdetection')
|
|
@@ -182,7 +184,7 @@ outfile = open(filename, 'wb') #write binary: mit Erlaubnis zu (über)schreiben
|
|
|
pickle.dump(snipmat_005Hz_post_controls, outfile)
|
|
|
outfile.close()
|
|
|
|
|
|
-#%% Example of using the script to create dictionaries with line length before and after 0.05Hz pulses from snipmats above
|
|
|
+#%% (4) Example of using the script to create dictionaries with line length before and after 0.05Hz pulses from snipmats above
|
|
|
|
|
|
os.chdir('C:\EAfiles\EAdetection')
|
|
|
ymlfiles = glob('C:\EAfiles\yml_setup_PK43\*.yml') #takes all yml files from this folder
|