Git Product home page Git Product logo

cotete.jl's People

Contributors

dpshorten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

orlandi

cotete.jl's Issues

Hi,

Thanks for making this interesting package.

The install instructions are not working for me.

david@home:~$ git clone --recurse-submodules --branch v0.2.2 https://github.com/dpshorten/CoTETE.jl.git
make sure that CoTETE.jl/src/ is on your JULIA_LOAD_PATH. eg:

david@home:~$ export JULIA_LOAD_PATH=:/home/user/git/CoTETE.jl/src/
Fire up the Julia REPL

david@home:~$ julia

I wonder if it would be possible to the package to the Julia registry?

JULIA: BoundsError when running in Python

I am testing the CoTETE package in Python and keep running into this odd error:

IndexError: <PyCall.jlwrap (in a Julia function called from Python)

JULIA: BoundsError: attempt to access 4333-element Vector{Float64} at index [0]

Stacktrace:

[1] getindex(A::Vector{Float64}, i1::Int64) @ Base ./array.jl:805

[2] make_one_embedding(observation_time_point::Float64, event_time_arrays::Vector{Vector{Float64}}, most_recent_event_indices::Vector{Integer}, embedding_lengths::Vector{Int64}) @ CoTETE ~/.bin/CoTETE.jl/src/preprocessing.jl:99

[3] make_embeddings_along_observation_time_points(observation_time_points::Vector{Float64}, start_observation_time_point::Int64, num_observation_time_points_to_use::Int64, event_time_arrays::Vector{Vector{Float64}}, embedding_lengths::Vector{Int64}) @ CoTETE ~/.bin/CoTETE.jl/src/preprocessing.jl:166

[4] preprocess_event_times(parameters::CoTETE.CoTETEParameters, target_events::Vector{Float64}; source_events::Vector{Float64}, conditioning_events::Vector{Vector{Float32}}) @ CoTETE ~/.bin/CoTETE.jl/src/preprocessing.jl:452

[5] estimate_TE_and_p_value_from_event_times(parameters::CoTETE.CoTETEParameters, target_events::Vector{Float64}, source_events::Vector{Float64}; conditioning_events::Vector{Vector{Float32}}, return_surrogate_TE_values::Bool) @ CoTETE ~/.bin/CoTETE.jl/src/CoTETE.jl:363

[6] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:return_surrogate_TE_values,), Tuple{Bool}}}) @ Base ./essentials.jl:710

[7] _pyjlwrap_call(f::Function, args_::Ptr{PyCall.PyObject_struct}, kw_::Ptr{PyCall.PyObject_struct}) @ PyCall ~/.julia/packages/PyCall/BD546/src/callback.jl:32

[8] pyjlwrap_call(self_::Ptr{PyCall.PyObject_struct}, args_::Ptr{PyCall.PyObject_struct}, kw_::Ptr{PyCall.PyObject_struct}) @ PyCall ~/.julia/packages/PyCall/BD546/src/callback.jl:44>

The length of the source and the target numpy arrays are both several thousand timesteps, and they are both float64 type.

The code runs fine for apparently identical inputs - I can't seem to figure out what is wrong with this particular set of sources and targets.

Error on high values of `l_x` in the `estimate_TE_from_event_times` function

I was trying to network properties by looking at TE and I found your package, which looks quite interesting. I'm trying to run the estimate_TE_from_event_times function to estimate effective transfer entropy (using this as a reference https://ieeexplore.ieee.org/document/9119388) and I was trying to increase the value of l_x and l_y in the function. Unfortunately, I get an error and the logs aren't very clear on why this could be happening.

My guess is that there is an empty collection created somewhere when it tries to run auto_find_start_and_num_events but I can't be certain.

Also, if you look in the logs I provide in the pastebin link, I get variances on the order of 0.1. Could you recommend a way so that I have a lower variance? For example, on the order of 0.001?

Thank you for the package! Please find my code and link to the pastebin below.

history_size = 30
parameters = CoTETE.CoTETEParameters(l_x = history_size, l_y = history_size);

function shuffle_times(dict)
    shuffled_dict = Dict()
    for (key, times) in dict
        shuffled_times = [(time + rand(10: last_spike - 20)) % last_spike for time in times]
        sort!(shuffled_times)
        shuffled_dict[key] = shuffled_times
    end
    return shuffled_dict
end

function find_te(spike_dict, repeats=25)
    shuffled_dicts = [shuffle_times(spike_dict) for i in 1:repeats];
    ret_matrix = zeros(length(spike_dict), length(spike_dict))
    i = 1
    j = 1
    @showprogress desc="Finding te..." for key1 in keys(spike_dict)
        j = 1
        for key2 in keys(spike_dict)
            te_arr = [
                CoTETE.estimate_TE_from_event_times(parameters, spike_dict[key1], spike_dict[key2])
                for i in 1:repeats
            ] 
            te  = mean(te_arr)
            println("(te) ", key2, " => ", key1, "\tmean: ", te, " std: ", std(te_arr))
            rte_arr = [
                    CoTETE.estimate_TE_from_event_times(parameters, shuffled_dict[key1], spike_dict[key2]) 
                    for shuffled_dict in shuffled_dicts
            ]
            rte = mean(rte_arr)
            println("(rte) ", key2, " => ", key1, "\tmean: ", rte, " std: ", std(rte_arr))
            # rte = 0
            ete = te - rte
            println("ete: ", ete)
            ret_matrix[i,j] = ete
            j = j + 1
        end
        i = i + 1
    end

    ret_matrix
end
te_15_l30 = find_te(spikes_15)

The complete error along with the print logs are here: https://pastebin.com/kvUBdHL3

I have copied the error below.

MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer

Stacktrace:
  [1] mapreduce_empty
    @ ./reduce.jl:372
  [2] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(max)}, ::Type{Float64})
    @ Base ./reduce.jl:361
  [3] reduce_empty_iter
    @ ./reduce.jl:384 [inlined]
  [4] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Float64}, ItrEltype::Base.HasEltype)
    @ Base ./reduce.jl:380
  [5] _mapreduce(f::typeof(identity), op::typeof(max), ::IndexLinear, A::Vector{Float64})
    @ Base ./reduce.jl:432
  [6] _mapreduce_dim
    @ ./reducedim.jl:365 [inlined]
  [7] mapreduce
    @ ./reducedim.jl:357 [inlined]
  [8] _maximum
    @ ./reducedim.jl:1015 [inlined]
  [9] _maximum
    @ ./reducedim.jl:1014 [inlined]
 [10] maximum(a::Vector{Float64})
    @ Base ./reducedim.jl:1010
 [11] estimate_TE_from_preprocessed_data(parameters::CoTETE.CoTETEParameters, preprocessed_data::CoTETE.PreprocessedData; AIS_only::Bool, return_locals::Bool)
    @ CoTETE ~/code/CoTETE.jl/src/CoTETE.jl:753
 [12] estimate_TE_from_preprocessed_data
    @ [~/code/CoTETE.jl/src/CoTETE.jl:637](http://localhost:8888/home/khan/code/CoTETE.jl/src/CoTETE.jl#line=636) [inlined]
 [13] #estimate_TE_from_event_times#6
    @ [~/code/CoTETE.jl/src/CoTETE.jl:279](http://localhost:8888/home/khan/code/CoTETE.jl/src/CoTETE.jl#line=278) [inlined]
 [14] estimate_TE_from_event_times(parameters::CoTETE.CoTETEParameters, target_events::Vector{Float64}, source_events::Vector{Float64})
    @ CoTETE [~/code/CoTETE.jl/src/CoTETE.jl:265](http://localhost:8888/home/khan/code/CoTETE.jl/src/CoTETE.jl#line=264)
 [15] (::var"#143#146"{Dict{Any, Any}, String, String})(shuffled_dict::Dict{Any, Any})
    @ Main ./essentials.jl:0
 [16] iterate
    @ ./generator.jl:47 [inlined]
 [17] collect_to!(dest::Vector{Float64}, itr::Base.Generator{Vector{Dict{Any, Any}}, var"#143#146"{Dict{Any, Any}, String, String}}, offs::Int64, st::Int64)
    @ Base ./array.jl:892
 [18] collect_to_with_first!(dest::Vector{Float64}, v1::Float64, itr::Base.Generator{Vector{Dict{Any, Any}}, var"#143#146"{Dict{Any, Any}, String, String}}, st::Int64)
    @ Base ./array.jl:870
 [19] collect(itr::Base.Generator{Vector{Dict{Any, Any}}, var"#143#146"{Dict{Any, Any}, String, String}})
    @ Base ./array.jl:844
 [20] macro expansion
    @ ./In[258]:15 [inlined]
 [21] macro expansion
    @ [~/.julia/packages/ProgressMeter/kVZZH/src/ProgressMeter.jl:1008](http://localhost:8888/home/khan/.julia/packages/ProgressMeter/kVZZH/src/ProgressMeter.jl#line=1007) [inlined]
 [22] find_te(spike_dict::Dict{Any, Any}, repeats::Int64)
    @ Main ./In[258]:6
 [23] find_te(spike_dict::Dict{Any, Any})
    @ Main ./In[258]:2
 [24] top-level scope
    @ In[259]:1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.