From f7f0b1082830943bd01d46b98d149d794d0139c0 Mon Sep 17 00:00:00 2001
From: Lisa <lisa-ruth.vial@student.uni-tuebingen.de>
Date: Thu, 31 Oct 2019 15:22:12 +0100
Subject: [PATCH] figure out graphs

---
 ephys_analysis.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/ephys_analysis.py b/ephys_analysis.py
index 1af0b94..6c0dc8e 100644
--- a/ephys_analysis.py
+++ b/ephys_analysis.py
@@ -20,8 +20,9 @@ def analyze_sams(filename):
     f = nix.File.open(filename, nix.FileMode.ReadOnly)
     b = f.blocks[0]
     b.metadata.pprint(max_depth=-1) # max_depth=-1: alles rausschreiben
+    print(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
 
     rtag_data = g.tags[0]   # rtag_data = tags within this group
@@ -42,22 +43,23 @@ def analyze_sams(filename):
         spike_data.append(stim_tag.retrieve_data(idx, 'Spikes-1')[:])
 
     dims = voltage_trace.dimensions[0].axis(len(voltage_trace))
+    os.chdir('/home/lisa/PycharmProjects/torus_ephys')
+    print(os.getcwd())
     plt.plot(dims[:-1], voltage_trace[:-1])
     for i in range(len(stim_pos)):
         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)+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...')
-        plt.savefig(filename + stim_type + '.png')
-        plt.close()
+        for s_i in range(len(b.groups)):
+            plt.savefig(filename + stim_type + str(s_i) + '.png')
         # f.close()
         # embed()
         # exit()