spykeutils: loading units from DB

29 views
Skip to first unread message

Orkan Oz

unread,
Sep 8, 2014, 9:51:39 AM9/8/14
to spyke-...@googlegroups.com
Hello all,

I am using neo 0.3.3 and OpenElectrophy 0.3.4 and spykeutils 0.4.1.

I have elicited spike trains and I want to analyse them with spykeutils. I load units in my script as below:


u1 = Unit.load (id=160)

u2 = Unit.load (id=172)


import spykeutils.rate_estimation

st_dict = {}

units = [1,2]

st_dict[units[0]] = u1.spiketrains

st_dict[units[1]] = u2.spiketrains


kernel_sizes = sp.logspace(2, 3.3, 100) * pq.ms

spykeutils.rate_estimation.spike_density_estimation(st_dict, optimize_steps=kernel_sizes)[0]



but I get the following error:


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\WinPython32\python-2.7.6\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "C:/WinPython32/python-2.7.6/Scripts/isi_140903.py", line 164, in <module>
    spykeutils.rate_estimation.spike_density_estimation(st_dict, optimize_steps=kernel_sizes)[0]
  File "C:\WinPython32\python-2.7.6\lib\site-packages\spykeutils\rate_estimation.py", line 181, in spike_density_estimation
    c = collapsed_spike_trains(t)
  File "C:\WinPython32\python-2.7.6\lib\site-packages\spykeutils\rate_estimation.py", line 215, in collapsed_spike_trains
    return neo.SpikeTrain([], 0 * pq.s)
  File "C:\WinPython32\python-2.7.6\lib\site-packages\neo\core\spiketrain.py", line 195, in __new__
    raise ValueError('you must specify units')
ValueError: you must specify units



Can you please help me with this problem?


Regards

Orkan
--

Orcun Orkan OZCAN
PhD student (NeuroTime)
Tel : +33 (0)3 88 45 66 32
Institute of Cellular and Integrative Neuroscience (INCI)
CNRS UPR 3212, University of Strasbourg
5, rue Blaise Pascal
67084 Strasbourg

Robert Pröpper

unread,
Sep 9, 2014, 9:30:19 AM9/9/14
to spyke-...@googlegroups.com
Hi Orkan,

it looks like you found a bug in spykeutils. It should be fixed in my most recent commit, so you can get a version without the bug from GitHub: https://github.com/rproepp/spykeutils/commit/1d070170425e1517972cf4760af528b75a645501

The bug only occurs for empty lists of spike trains, so it seems that at least one of your units doesn't have spikes. Also, I think it would be more convenient for you to just use the units as index for st_dict (i.e. in your example: st_dict[u1] = u1.spiketrains).

Best,
Robert
--
You received this message because you are subscribed to the Google Groups "Spyke Viewer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyke-viewer...@googlegroups.com.
To post to this group, send email to spyke-...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyke-viewer.

Orkan Oz

unread,
Sep 11, 2014, 9:57:35 AM9/11/14
to spyke-...@googlegroups.com
Hi Robert,

Thank you very much for the answer and the fix. I have another problem now, unfortunately.

I am running the script


import numpy

from neuronpy.graphics import spikeplot

from OpenElectrophy import *

import matplotlib

import matplotlib.colors as colors

import matplotlib.pyplot as plt

import spykeutils.plot

import neuronpy


import scipy as sp

import sys,os

from numpy import*# unique, ones, mean, std, arange, where, random, unique1d


open_db( url = url, myglobals= globals(), use_global_session = True)


" spike density estimation "

u1 = Unit.load (id=303)

u2 = Unit.load (id=321)


import spykeutils.rate_estimation


st_dict = {}

units=[]

units.append(u1)

units.append(u1)

units[0].spiketrains = u1.spiketrains

units[1].spiketrains = u2.spiketrains


st_dict[units[0]] = units[0].spiketrains

st_dict[units[1]] = units[1].spiketrains


kernel_sizes = sp.logspace(2, 3.3, 100) * pq.ms

spykeutils.rate_estimation.spike_density_estimation(st_dict, optimize_steps=kernel_sizes)[0]

spykeutils.plot.sde(st_dict, maximum_kernel=3000*pq.ms, optimize_steps=100)




and I get the following error:


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\WinPython32\python-2.7.6\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "C:/WinPython32/python-2.7.6/Scripts/rate_est_O.py", line 151, in <module>
    spykeutils.rate_estimation.spike_density_estimation(st_dict, optimize_steps=kernel_sizes)[0]
  File "C:\WinPython32\python-2.7.6\lib\site-packages\spykeutils\rate_estimation.py", line 184, in spike_density_estimation
    c = collapsed_spike_trains(t)
  File "C:\WinPython32\python-2.7.6\lib\site-packages\spykeutils\rate_estimation.py", line 225, in collapsed_spike_trains
    collapsed.extend(sp.asarray(t.rescale(stop.units)))
AttributeError: 'SpikeTrain' object has no attribute 'rescale'


Can you please check this?

Best,
Orkan

Robert Pröpper

unread,
Sep 11, 2014, 10:56:24 AM9/11/14
to spyke-...@googlegroups.com
I suspect that the spike train lists you get from OpenElectrophy (e.g. u1.spiketrains) do not actually contain Neo SpikeTrain objects, but something similar that is linked to the database. That explains why they don't have a rescale method.

I don't use OpenElectrophy myself, but there should be an easy way to convert these objects into real Neo SpikeTrains. You would need to do that for the contents of your lists before passing them to spykeutils.

Best,
Robert

Orkan Oz

unread,
Sep 12, 2014, 4:55:43 AM9/12/14
to spyke-...@googlegroups.com
Thanks again Robert.

I will check the contents of OE outputs.

Best
Orkan
Reply all
Reply to author
Forward
0 new messages