Plot output from OSG

In the demo to run python on the open science grid (OSG), we generated compressed numpy files that contain our results.

In this notebook, we extract these results and plot them on our data to confirm that our program ran correctly.

1. iterate through tar files and unzip them


In [1]:
import tarfile

fname_base = 'C:/gh/data/example/lfp_set_PsTs/out.29419325.'
Nfiles = 10
for n in range(Nfiles):
    fname = fname_base + str(n) + '.tar.gz'
    tar = tarfile.open(fname, "r:gz")
    tar.extractall('C:/gh/data/example/lfp_set_PsTs/' + str(n) + '/')
    tar.close()

2. Load each array of Ps and Ts


In [2]:
import numpy as np

Ps = np.zeros(Nfiles, dtype=np.ndarray)
Ts = np.zeros(Nfiles, dtype=np.ndarray)
for n in range(Nfiles):
    Ps[n] = np.load('C:/gh/data/example/lfp_set_PsTs/' + str(n) + '/out/Ps_data.npy')
    Ts[n] = np.load('C:/gh/data/example/lfp_set_PsTs/' + str(n) + '/out/Ts_data.npy')

3. Load signals


In [3]:
lfps = np.zeros(Nfiles, dtype=np.ndarray)
for n in range(Nfiles):
    if n == 0:
        lfps[n] = np.load('C:/gh/data/example/lfp_set/' + str(10) + '.npy')
    else:
        lfps[n] = np.load('C:/gh/data/example/lfp_set/' + str(n) + '.npy')

4. Plot peaks and troughs on top of signals


In [4]:
import matplotlib.pyplot as plt
%matplotlib inline

plt.figure(figsize=(10,10))
for n in range(Nfiles):
    plt.subplot(Nfiles, 1, n+1)
    plt.plot(lfps[n], 'k')
    plt.plot(Ps[n], lfps[n][Ps[n]], 'bo')
    plt.plot(Ts[n], lfps[n][Ts[n]], 'ro')
    if n == Nfiles-1:
        plt.xlabel('Time (ms)')
    else:
        plt.xticks([])
    plt.ylim((-3000,3000))
    plt.yticks([-3000,0,3000])
    if n == 0:
        plt.ylabel('Voltage (uV)')


Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7b3b6d8>
Out[4]:
[<matplotlib.lines.Line2D at 0x7cc9c88>]
Out[4]:
[<matplotlib.lines.Line2D at 0x7cea240>]
Out[4]:
[<matplotlib.lines.Line2D at 0x7cea748>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x7bfca58>,
  <matplotlib.axis.YTick at 0x7c82eb8>,
  <matplotlib.axis.YTick at 0x7cea6a0>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.text.Text at 0x7bfc5c0>
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7bdbef0>
Out[4]:
[<matplotlib.lines.Line2D at 0x7d27a58>]
Out[4]:
[<matplotlib.lines.Line2D at 0x7d1d5f8>]
Out[4]:
[<matplotlib.lines.Line2D at 0x7d1d4e0>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x7d1dcc0>,
  <matplotlib.axis.YTick at 0x7d42c50>,
  <matplotlib.axis.YTick at 0x7c827f0>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7d32780>
Out[4]:
[<matplotlib.lines.Line2D at 0x7ed5ef0>]
Out[4]:
[<matplotlib.lines.Line2D at 0x7f28550>]
Out[4]:
[<matplotlib.lines.Line2D at 0x7f28a90>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x7e23400>,
  <matplotlib.axis.YTick at 0x7e232e8>,
  <matplotlib.axis.YTick at 0x7f28eb8>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7e45710>
Out[4]:
[<matplotlib.lines.Line2D at 0x7fd5208>]
Out[4]:
[<matplotlib.lines.Line2D at 0x7f7ab38>]
Out[4]:
[<matplotlib.lines.Line2D at 0x7f581d0>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x7f857b8>,
  <matplotlib.axis.YTick at 0x7f855f8>,
  <matplotlib.axis.YTick at 0x7f4cdd8>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc4128>
Out[4]:
[<matplotlib.lines.Line2D at 0x80d5ac8>]
Out[4]:
[<matplotlib.lines.Line2D at 0x80e7128>]
Out[4]:
[<matplotlib.lines.Line2D at 0x80e75f8>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x7ffd9b0>,
  <matplotlib.axis.YTick at 0x7c82438>,
  <matplotlib.axis.YTick at 0x80e7a90>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x80e7ba8>
Out[4]:
[<matplotlib.lines.Line2D at 0x82075c0>]
Out[4]:
[<matplotlib.lines.Line2D at 0x81c1438>]
Out[4]:
[<matplotlib.lines.Line2D at 0x81b7780>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x80fdf60>,
  <matplotlib.axis.YTick at 0x81b7d68>,
  <matplotlib.axis.YTick at 0x81aaeb8>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x81aa668>
Out[4]:
[<matplotlib.lines.Line2D at 0x8302b00>]
Out[4]:
[<matplotlib.lines.Line2D at 0x8311240>]
Out[4]:
[<matplotlib.lines.Line2D at 0x8311710>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x81aa358>,
  <matplotlib.axis.YTick at 0x81aaf60>,
  <matplotlib.axis.YTick at 0x8311ba8>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x821c358>
Out[4]:
[<matplotlib.lines.Line2D at 0x83e4eb8>]
Out[4]:
[<matplotlib.lines.Line2D at 0x83f4518>]
Out[4]:
[<matplotlib.lines.Line2D at 0x83f49e8>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x832a668>,
  <matplotlib.axis.YTick at 0x832a3c8>,
  <matplotlib.axis.YTick at 0x83f4e80>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x83f4400>
Out[4]:
[<matplotlib.lines.Line2D at 0x8510cc0>]
Out[4]:
[<matplotlib.lines.Line2D at 0x8520320>]
Out[4]:
[<matplotlib.lines.Line2D at 0x8520860>]
Out[4]:
([], <a list of 0 Text xticklabel objects>)
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x82262e8>,
  <matplotlib.axis.YTick at 0x821c2e8>,
  <matplotlib.axis.YTick at 0x8520c88>],
 <a list of 3 Text yticklabel objects>)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x85207f0>
Out[4]:
[<matplotlib.lines.Line2D at 0x8640358>]
Out[4]:
[<matplotlib.lines.Line2D at 0x8640978>]
Out[4]:
[<matplotlib.lines.Line2D at 0x8640eb8>]
Out[4]:
<matplotlib.text.Text at 0x852de48>
Out[4]:
(-3000, 3000)
Out[4]:
([<matplotlib.axis.YTick at 0x859eb00>,
  <matplotlib.axis.YTick at 0x8520e48>,
  <matplotlib.axis.YTick at 0x864d320>],
 <a list of 3 Text yticklabel objects>)