linux goes windows
This commit is contained in:
parent
fd558b213c
commit
a483f40056
1014
NixFrame.py
1014
NixFrame.py
File diff suppressed because it is too large
Load Diff
@ -7,17 +7,12 @@ from IPython import embed
|
|||||||
|
|
||||||
|
|
||||||
def stimulus_collector(filename):
|
def stimulus_collector(filename):
|
||||||
try:
|
stims = []
|
||||||
stims = []
|
f = nix.File.open(filename, nix.FileMode.ReadOnly)
|
||||||
f = nix.File.open(filename, nix.FileMode.ReadOnly)
|
b = f.blocks[0]
|
||||||
b = f.blocks[0]
|
embed()
|
||||||
for g in b.groups:
|
exit()
|
||||||
# embed()
|
|
||||||
# exit()
|
|
||||||
stims.append(g.multi_tags[0].name)
|
|
||||||
except KeyError:
|
|
||||||
embed()
|
|
||||||
exit()
|
|
||||||
return stims
|
return stims
|
||||||
|
|
||||||
|
|
||||||
@ -26,22 +21,18 @@ def analyze_sams(filename):
|
|||||||
b = f.blocks[0]
|
b = f.blocks[0]
|
||||||
b.metadata.pprint(max_depth=-1) # max_depth=-1: alles rausschreiben
|
b.metadata.pprint(max_depth=-1) # max_depth=-1: alles rausschreiben
|
||||||
for g in b.groups:
|
for g in b.groups:
|
||||||
|
|
||||||
if 'sam' in g.name.lower(): # go through loop, until 'sam' is found
|
if 'sam' in g.name.lower(): # go through loop, until 'sam' is found
|
||||||
break
|
break
|
||||||
# embed()
|
|
||||||
# exit()
|
rtag_data = g.tags[0] # rtag_data = tags within this group
|
||||||
rtag_data = g.tags[0]
|
|
||||||
rtag_data.metadata.pprint(max_depth=-1)
|
rtag_data.metadata.pprint(max_depth=-1)
|
||||||
|
|
||||||
print(40*'*')
|
print(40*'*')
|
||||||
|
|
||||||
stim_tag = g.multi_tags[0]
|
stim_tag = g.multi_tags[0]
|
||||||
stim_type = g.multi_tags[0].name
|
stim_type = g.multi_tags[0].name
|
||||||
stim_pos = stim_tag.positions[:] # beginnings of stimulations
|
stim_pos = stim_tag.positions[:] # beginnings of stimuli
|
||||||
stim_extent = stim_tag.extents[:] # duration of stimulations
|
stim_extent = stim_tag.extents[:] # duration of stimuli
|
||||||
# for r in rtag_data.references:
|
|
||||||
# print(r.name, r.type)
|
|
||||||
|
|
||||||
voltage_trace = rtag_data.references['V-1']
|
voltage_trace = rtag_data.references['V-1']
|
||||||
|
|
||||||
@ -56,15 +47,16 @@ def analyze_sams(filename):
|
|||||||
stim_y = [np.max(voltage_trace)+10, np.max(voltage_trace)+10]
|
stim_y = [np.max(voltage_trace)+10, np.max(voltage_trace)+10]
|
||||||
plt.plot([stim_pos[i], stim_pos[i] + stim_extent[i]], stim_y, 'k')
|
plt.plot([stim_pos[i], stim_pos[i] + stim_extent[i]], stim_y, 'k')
|
||||||
|
|
||||||
|
os.chdir('/home/lisa/Dropbox/Masterarbeit/')
|
||||||
for j in range(len(spike_data)):
|
for j in range(len(spike_data)):
|
||||||
for k in range(len(spike_data[j])):
|
for k in range(len(spike_data[j])):
|
||||||
plt.plot(spike_data[j][k], np.max(voltage_trace)+5, 'o', color='k')
|
plt.plot(spike_data[j][k], np.max(voltage_trace)+2.5, 'o', color='k')
|
||||||
plt.xlim([stim_pos[0]-1, stim_extent[-1]+1])
|
plt.xlim([stim_pos[0]-.5, stim_pos[0] + stim_extent[-1] + .5])
|
||||||
plt.title(filename[-26:-13] + ': ' + stim_type)
|
plt.xlabel('time [s]')
|
||||||
# plt.show()
|
plt.ylabel('voltage [mV]')
|
||||||
|
plt.show()
|
||||||
print('saving...')
|
print('saving...')
|
||||||
os.chdir('/home/lisa/Dropbox/Masterarbeit/')
|
plt.savefig(filename + stim_type + '.png')
|
||||||
plt.savefig(filename[-26:-13] + ': ' + stim_type + '.png')
|
|
||||||
plt.close()
|
plt.close()
|
||||||
# f.close()
|
# f.close()
|
||||||
# embed()
|
# embed()
|
||||||
@ -73,13 +65,61 @@ def analyze_sams(filename):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def analyze_fis(filename):
|
||||||
|
f = nix.File.open(filename, nix.FileMode.ReadOnly)
|
||||||
|
b = f.blocks[0]
|
||||||
|
b.metadata.pprint(max_depth=-1) # max_depth=-1: alles rausschreiben
|
||||||
|
for g in b.groups:
|
||||||
|
# if 'FICurve' in g.name: # go through loop, until 'sam' is found
|
||||||
|
# break
|
||||||
|
|
||||||
|
rtag_data = g.tags[0] # rtag_data = tags within this group
|
||||||
|
rtag_data.metadata.pprint(max_depth=-1)
|
||||||
|
|
||||||
|
print(40*'*')
|
||||||
|
|
||||||
|
stim_tag = g.multi_tags[0]
|
||||||
|
stim_type = g.multi_tags[0].name
|
||||||
|
stim_pos = stim_tag.positions[:] # beginnings of stimuli
|
||||||
|
stim_extent = stim_tag.extents[:] # duration of stimuli
|
||||||
|
|
||||||
|
voltage_trace = rtag_data.references['V-1']
|
||||||
|
for i in range(len(voltage_trace)):
|
||||||
|
print(voltage_trace[i])
|
||||||
|
spike_data = []
|
||||||
|
|
||||||
|
for idx in range(len(stim_pos)):
|
||||||
|
spike_data.append(stim_tag.retrieve_data(idx, 'Spikes-1')[:])
|
||||||
|
|
||||||
|
|
||||||
|
# embed()
|
||||||
|
# exit()
|
||||||
|
dims = voltage_trace.dimensions[0].axis(len(voltage_trace))
|
||||||
|
|
||||||
|
for i in range(len(stim_pos)):
|
||||||
|
plt.plot(dims[:-1], voltage_trace[:-1], color='#3673A4')
|
||||||
|
stim_y = [np.max(voltage_trace)+1.25, np.max(voltage_trace)+1.25]
|
||||||
|
plt.plot([stim_pos[i], stim_pos[i] + stim_extent[i]], stim_y, 'k')
|
||||||
|
xmin = stim_pos[i] - .1
|
||||||
|
xmax = stim_pos[i] + stim_extent[i] + .1
|
||||||
|
y = np.ones(len(spike_data[i]))*(np.max(voltage_trace)+2.5)
|
||||||
|
plt.plot(spike_data[i], y, 'o', color='#DC143C')
|
||||||
|
plt.xlim(xmin, xmax)
|
||||||
|
plt.xlabel('time [s]')
|
||||||
|
plt.ylabel('voltage [mV]')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
data_dir = '/home/lisa/data/'
|
data_dir = '/home/lisa/data/'
|
||||||
os.chdir(data_dir)
|
os.chdir(data_dir)
|
||||||
data_set = glob.glob('2019-*')
|
data_set = glob.glob('2019*') # only look at single cells
|
||||||
|
# data_set = '2019*' # only look at single cells
|
||||||
for i in range(len(data_set)):
|
for i in range(len(data_set)):
|
||||||
# data_set = '2019-08-22-aa-invivo-1'
|
if '08' in data_set[i]:
|
||||||
print(data_dir + data_set[i] + '/' + data_set[i])
|
continue
|
||||||
|
# print(data_dir + data_set + '/' + data_set)
|
||||||
analyze_sams(data_dir + data_set[i] + '/' + data_set[i] + '.nix')
|
analyze_sams(data_dir + data_set[i] + '/' + data_set[i] + '.nix')
|
||||||
# analyze_sams(data_dir + data_set + '/' + data_set + '.nix')
|
|
||||||
|
|
||||||
|
32
frame_analysis.py
Normal file
32
frame_analysis.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import NixFrame as nf
|
||||||
|
from IPython import embed
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
data_dir = '/home/lisa/data/'
|
||||||
|
os.chdir(data_dir)
|
||||||
|
data_sets = glob.glob('2019-*')
|
||||||
|
for data_set in data_sets:
|
||||||
|
print(data_set)
|
||||||
|
df = nf.load_data(data_dir + data_set + '/' + data_set + '_dataframe.pickle')
|
||||||
|
embed()
|
||||||
|
exit()
|
||||||
|
for i in range(len(df)):
|
||||||
|
|
||||||
|
stim_type = df['tag_meta']['RePro'][i]
|
||||||
|
smpl_rt = df['samplingrate'][i]
|
||||||
|
# t = df['time'][i+1]
|
||||||
|
voltage = df['V-1'][i]
|
||||||
|
t = np.arange(0, len(voltage)*1./smpl_rt, 1./smpl_rt)
|
||||||
|
print(len(t))
|
||||||
|
spiketimes = df['Spikes-1'][i]
|
||||||
|
stim_onset = df['onset_times'][i]
|
||||||
|
stim_dur = df['durations'][i]
|
||||||
|
|
||||||
|
plt.plot(t, voltage, color='#BA2D22')
|
||||||
|
plt.plot([stim_onset, stim_dur], [np.max(voltage)+0.75, np.max(voltage)+0.75], color='#53379B')
|
||||||
|
plt.plot([spiketimes, spiketimes], [np.max(voltage)+1, np.max(voltage)+1.5], color='black')
|
||||||
|
plt.show()
|
8
frame_maker.py
Normal file
8
frame_maker.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from IPython import embed
|
||||||
|
import NixFrame as nf
|
||||||
|
|
||||||
|
folder = '../../data'
|
||||||
|
|
||||||
|
df = nf.NixToFrame(folder, before=0.0, after=0.0, skipold=True, saveto=None, mindepth=0)
|
||||||
|
|
||||||
|
print(df)
|
Loading…
Reference in New Issue
Block a user