linux goes windows

This commit is contained in:
Lisa 2019-10-23 15:53:39 +02:00
parent fd558b213c
commit a483f40056
4 changed files with 556 additions and 598 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,17 +7,12 @@ from IPython import embed
def stimulus_collector(filename):
try:
stims = []
f = nix.File.open(filename, nix.FileMode.ReadOnly)
b = f.blocks[0]
for g in b.groups:
# embed()
# exit()
stims.append(g.multi_tags[0].name)
except KeyError:
embed()
exit()
stims = []
f = nix.File.open(filename, nix.FileMode.ReadOnly)
b = f.blocks[0]
embed()
exit()
return stims
@ -26,22 +21,18 @@ def analyze_sams(filename):
b = f.blocks[0]
b.metadata.pprint(max_depth=-1) # max_depth=-1: alles rausschreiben
for g in b.groups:
if 'sam' in g.name.lower(): # go through loop, until 'sam' is found
break
# embed()
# exit()
rtag_data = g.tags[0]
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 stimulations
stim_extent = stim_tag.extents[:] # duration of stimulations
# for r in rtag_data.references:
# print(r.name, r.type)
stim_pos = stim_tag.positions[:] # beginnings of stimuli
stim_extent = stim_tag.extents[:] # duration of stimuli
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]
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 k in range(len(spike_data[j])):
plt.plot(spike_data[j][k], np.max(voltage_trace)+5, 'o', color='k')
plt.xlim([stim_pos[0]-1, stim_extent[-1]+1])
plt.title(filename[-26:-13] + ': ' + stim_type)
# plt.show()
plt.plot(spike_data[j][k], np.max(voltage_trace)+2.5, 'o', color='k')
plt.xlim([stim_pos[0]-.5, stim_pos[0] + stim_extent[-1] + .5])
plt.xlabel('time [s]')
plt.ylabel('voltage [mV]')
plt.show()
print('saving...')
os.chdir('/home/lisa/Dropbox/Masterarbeit/')
plt.savefig(filename[-26:-13] + ': ' + stim_type + '.png')
plt.savefig(filename + stim_type + '.png')
plt.close()
# f.close()
# embed()
@ -73,13 +65,61 @@ def analyze_sams(filename):
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__':
data_dir = '/home/lisa/data/'
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)):
# data_set = '2019-08-22-aa-invivo-1'
print(data_dir + data_set[i] + '/' + data_set[i])
if '08' in 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 + '/' + data_set + '.nix')

32
frame_analysis.py Normal file
View 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
View 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)