-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spike time tiling coefficient produces values larger than 1 #563
Comments
Hey @Celine-075 , I've created to the following minimal example to reproduce this, I get the results:
import neo
import quantities as pq
from elephant.spike_train_correlation import spike_time_tiling_coefficient
spiketrain_E7 = neo.SpikeTrain([ 1678. , 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1], units='ms', t_stop=160000*pq.ms)
spiketrain_E3 = neo.SpikeTrain([ 1678. , 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1], units='ms', t_stop=160000*pq.ms)
print(spike_time_tiling_coefficient(spiketrain_E7, spiketrain_E3, dt=0.10 * pq.s))
# result: 1.152482370309056
spiketrain_E8 = neo.SpikeTrain([ 20646.8, 25875.1, 26154.4, 35121. , 55909.7, 79164.8,
110849.8, 117484.1, 3731.5, 4213.9, 119995.1, 123748.1,
171016.8, 172989. , 185145.2, 12043.5, 185995.9, 186740.1,
12629.8, 23394.3, 34993.2], units='ms', t_stop=210000*pq.ms)
spiketrain_B3 = neo.SpikeTrain([ 10600.7, 19699.6, 22803. , 40769.3, 121385.7, 127402.9,
130829.2, 134363.8, 1193.5, 8012.7, 142037.3, 146628.2,
165925.3, 168489.3, 175194.3, 10339.8, 178676.4, 180807.2,
201431.3, 22231.1, 38113.4], units='ms', t_stop=210000*pq.ms)
print(spike_time_tiling_coefficient(spiketrain_E8, spiketrain_B3, dt=0.10 * pq.s))
# result: 2.2166419047619055 Which seems very close to what you get, did I reproduce this correctly? |
Hi,
Thank you for answering on such short notice!
Yes, its somewhat similar to what I got, although not entirely the same but that probably has to do with t_stop being 160 000 in your example, while I used 300 000, but you also produce a number > 1 (e.g., between E8 and B3, it is 2.2 in your example). Is this correct? Shouldn’t it be a number between -1 and +1?
Kind Regards,
Celine
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: Moritz ***@***.***>
Sent: Friday, May 12, 2023 10:01 AM
To: ***@***.***>
Cc: ***@***.***>; ***@***.***>
Subject: Re: [NeuralEnsemble/elephant] Spike time tiling coefficient produces values larger than 1 (Issue #563)
Hey @Celine-075<https://github.com/Celine-075> ,
thanks for reaching out to us.
I've created to the following minimal example to reproduce this, I get the results:
* STTC for E7 and E3: 1.152482370309056
* STTC for E8 and B3: 2.2166419047619055
import neo
import quantities as pq
from elephant.spike_train_correlation import spike_time_tiling_coefficient
spiketrain_E7 = neo.SpikeTrain([ 1678. , 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1], units='ms', t_stop=160000*pq.ms)
spiketrain_E3 = neo.SpikeTrain([ 1678. , 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1], units='ms', t_stop=160000*pq.ms)
print(spike_time_tiling_coefficient(spiketrain_E7, spiketrain_E3, dt=0.10 * pq.s))
# result: 1.152482370309056
spiketrain_E8 = neo.SpikeTrain([ 20646.8, 25875.1, 26154.4, 35121. , 55909.7, 79164.8,
110849.8, 117484.1, 3731.5, 4213.9, 119995.1, 123748.1,
171016.8, 172989. , 185145.2, 12043.5, 185995.9, 186740.1,
12629.8, 23394.3, 34993.2], units='ms', t_stop=210000*pq.ms)
spiketrain_B3 = neo.SpikeTrain([ 10600.7, 19699.6, 22803. , 40769.3, 121385.7, 127402.9,
130829.2, 134363.8, 1193.5, 8012.7, 142037.3, 146628.2,
165925.3, 168489.3, 175194.3, 10339.8, 178676.4, 180807.2,
201431.3, 22231.1, 38113.4], units='ms', t_stop=210000*pq.ms)
print(spike_time_tiling_coefficient(spiketrain_E8, spiketrain_B3, dt=0.10 * pq.s))
# result: 2.2166419047619055
Which seems very close to what you get, did I reproduce this correctly?
—
Reply to this email directly, view it on GitHub<#563 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A6MBEVZIWBG7SFD3ZXNIYTTXFXU4NANCNFSM6AAAAAAX7EADDA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hey @Celine-075 , A reworked version of the code is proposed in PR #564 . The results I get now are:
You can test this version of the code by installing:
Then run your code and see if the results you obtain are within [-1 1]. |
Thank you so much! I will check this right away.
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: Moritz ***@***.***>
Sent: Friday, May 12, 2023 4:40 PM
To: ***@***.***>
Cc: ***@***.***>; ***@***.***>
Subject: Re: [NeuralEnsemble/elephant] Spike time tiling coefficient produces values larger than 1 (Issue #563)
Hey @Celine-075<https://github.com/Celine-075> ,
A reworked version of the code is proposed in PR #564<#564> .
The results I get now are:
* STTC for E7 and E3: 1.0
* STTC for E8 and B3: -0.02
You can test this version of the code by installing:
pip install ***@***.***/sttc
Then run your code and see if the results you obtain are within [-1 1].
I agree the values should be between -1 and 1.
—
Reply to this email directly, view it on GitHub<#563 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A6MBEV63NV7WOD56QKKJGFLXFZDUBANCNFSM6AAAAAAX7EADDA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Between E7 and E3 I also get 1.0 now, but for E8 and B3 I get 120.83066666666667 |
Hey @Celine-075 ,
This time I adjusted
|
Ah let me check! Thanks for the help!
Verzonden vanaf mijn Galaxy
…-------- Oorspronkelijk bericht --------
Van: Moritz Kern ***@***.***>
Datum: 12-05-2023 23:43 (GMT+01:00)
Aan: NeuralEnsemble/elephant ***@***.***>
Cc: Celine-075 ***@***.***>, Mention ***@***.***>
Onderwerp: Re: [NeuralEnsemble/elephant] Spike time tiling coefficient produces values larger than 1 (Issue #563)
Hey @Celine-075<https://github.com/Celine-075> ,
I ran the example in the following environment using those versions of neo, numpy and quantities:
Package Version
--------------- -------- -----------------------------
elephant 0.13.0b1 @ branch fix/sttc
Jinja2 3.1.2
neo 0.12.0
numpy 1.24.3
quantities 0.14.1
This time I adjusted t_stop to 300 000 ms.
Now I get:
* STTC for E7 and E3: 1.0
* STTC for E8 and B3: -0.014
—
Reply to this email directly, view it on GitHub<#563 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A6MBEV4YXOECQJDNUCITHZLXF2VH5ANCNFSM6AAAAAAX7EADDA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I've updated to the same versions as you showed, but unfortunately I still get a very large value (120.83066666666667). Ive noticed my spiketimes were not sorted so checked if that could be the problem, but that resulted in an even larger number: (645.9386666666666). |
Hey @Celine-075 , I used the following example to check the difference between using sorted and unsorted spiketimes: import neo
import quantities as pq
from elephant.spike_train_correlation import spike_time_tiling_coefficient
spiketrain_E7 = neo.SpikeTrain([ 1678. , 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1], units='ms', t_stop=160000*pq.ms)
spiketrain_E3 = neo.SpikeTrain([ 1678. , 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1], units='ms', t_stop=160000*pq.ms)
print("results obtained with unsorted spiketrains:")
print(spike_time_tiling_coefficient(spiketrain_E7, spiketrain_E3, dt=0.10 * pq.s))
spiketrain_E8 = neo.SpikeTrain([ 20646.8, 25875.1, 26154.4, 35121. , 55909.7, 79164.8,
110849.8, 117484.1, 3731.5, 4213.9, 119995.1, 123748.1,
171016.8, 172989. , 185145.2, 12043.5, 185995.9, 186740.1,
12629.8, 23394.3, 34993.2], units='ms', t_stop=210000*pq.ms)
spiketrain_B3 = neo.SpikeTrain([ 10600.7, 19699.6, 22803. , 40769.3, 121385.7, 127402.9,
130829.2, 134363.8, 1193.5, 8012.7, 142037.3, 146628.2,
165925.3, 168489.3, 175194.3, 10339.8, 178676.4, 180807.2,
201431.3, 22231.1, 38113.4], units='ms', t_stop=210000*pq.ms)
print(spike_time_tiling_coefficient(spiketrain_E8, spiketrain_B3, dt=0.10 * pq.s))
print("results obtained with sorted spiketrains:")
spiketrain_E7.sort()
spiketrain_E3.sort()
spiketrain_E8.sort()
spiketrain_B3.sort()
print(spike_time_tiling_coefficient(spiketrain_E7, spiketrain_E3, dt=0.10 * pq.s))
print(spike_time_tiling_coefficient(spiketrain_E8, spiketrain_B3, dt=0.10 * pq.s)) The results I obtain are:
Maybe you get correct results if you use sorted spiketimes with the original implementation? |
Yes I did sort the spiketrains, however, it produced even larger numbers after I did that. I'm also not sure why I dont obtain the same results while running the same versions of the packages .. |
Hi,
Im working with the spike time tiling coefficient and have noticed that some values are larger than 1, while I thought the maximum value was 1. For example:
spiketrain E7:
array([ 1678. , 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1])
spiketrain E3:
array([ 1678. , 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1])
result in an STTC of 1.063003420467317
While spiketrain E8
array([ 20646.8, 25875.1, 26154.4, 35121. , 55909.7, 79164.8,
110849.8, 117484.1, 3731.5, 4213.9, 119995.1, 123748.1,
171016.8, 172989. , 185145.2, 12043.5, 185995.9, 186740.1,
12629.8, 23394.3, 34993.2])
spiketrain B3
array([ 10600.7, 19699.6, 22803. , 40769.3, 121385.7, 127402.9,
130829.2, 134363.8, 1193.5, 8012.7, 142037.3, 146628.2,
165925.3, 168489.3, 175194.3, 10339.8, 178676.4, 180807.2,
201431.3, 22231.1, 38113.4])
Are less synchronous, but have an STTC of 2.2794178907759863, while I thought the maximum value would be 1, suggesting perfect synchronicity?
I calculated the STTC as: sttc = spike_time_tiling_coefficient(spiketrain1, spiketrain2, dt), with dt being 0.10 * pq.s. I also I made sure I used Neo in the right way to make the spike trains.
Is it possible that there is a bug in the code for calculating the spike time tiling coefficient?
The text was updated successfully, but these errors were encountered: