unfoldtoolbox / UnfoldDecode.jl

MIT License
1 stars 4 forks source link

Error in tutorial while fitting decoding model #3

Closed geigermartin closed 4 months ago

geigermartin commented 8 months ago

Hi!

I was trying to run the tutorial overlapcorrectedLDA.jl, however, while fitting the decoding model, I'm running into this error:

ERROR: LoadError: TaskFailedException

    nested task error: MethodError: no method matching (::Colon)(::Int64, ::Tuple{Int64, Int64})

    Closest candidates are:
      (::Colon)(::T, ::Any, ::T) where T<:Real
       @ Base range.jl:45
      (::Colon)(::A, ::Any, ::C) where {A<:Real, C<:Real}
       @ Base range.jl:10
      (::Colon)(::A, ::Any, ::C) where {A<:Real, C<:Unitful.Quantity}
       @ Unitful ~/.julia/packages/Unitful/R4J37/src/range.jl:86
      ...

    Stacktrace:
     [1] macro expansion
       @ ~/.julia/packages/UnfoldDecode/fJ8fu/src/fit.jl:43 [inlined]
     [2] (::UnfoldDecode.var"#801#threadsfor_fun#5"{UnfoldDecode.var"#801#threadsfor_fun#4#6"{Symbol, NamedTuple{(), Tuple{}}, Dict{DataType, Tuple{StatsModels.FormulaTerm{StatsModels.ConstantTerm{Int64}, Tuple{StatsModels.ConstantTerm{Int64}, StatsModels.Term, StatsModels.Term}}, FIRBasis}}, DataFrames.DataFrame, Matrix{Float64}, MLJMultivariateStatsInterface.LDA, Pair{DataType, Symbol}, Vector{UnfoldDecode.DecodingFit}, Vector{Tuple{Vector{Int64}, UnitRange{Int64}}}, UnitRange{Int64}}})(tid::Int64; onethread::Bool)
       @ UnfoldDecode ./threadingconstructs.jl:206
     [3] #801#threadsfor_fun
       @ ./threadingconstructs.jl:173 [inlined]
     [4] (::Base.Threads.var"#1#2"{UnfoldDecode.var"#801#threadsfor_fun#5"{UnfoldDecode.var"#801#threadsfor_fun#4#6"{Symbol, NamedTuple{(), Tuple{}}, Dict{DataType, Tuple{StatsModels.FormulaTerm{StatsModels.ConstantTerm{Int64}, Tuple{StatsModels.ConstantTerm{Int64}, StatsModels.Term, StatsModels.Term}}, FIRBasis}}, DataFrames.DataFrame, Matrix{Float64}, MLJMultivariateStatsInterface.LDA, Pair{DataType, Symbol}, Vector{UnfoldDecode.DecodingFit}, Vector{Tuple{Vector{Int64}, UnitRange{Int64}}}, UnitRange{Int64}}}, Int64})()
       @ Base.Threads ./threadingconstructs.jl:145
Stacktrace:
 [1] threading_run(fun::UnfoldDecode.var"#801#threadsfor_fun#5"{UnfoldDecode.var"#801#threadsfor_fun#4#6"{Symbol, NamedTuple{(), Tuple{}}, Dict{DataType, Tuple{StatsModels.FormulaTerm{StatsModels.ConstantTerm{Int64}, Tuple{StatsModels.ConstantTerm{Int64}, StatsModels.Term, StatsModels.Term}}, FIRBasis}}, DataFrames.DataFrame, Matrix{Float64}, MLJMultivariateStatsInterface.LDA, Pair{DataType, Symbol}, Vector{UnfoldDecode.DecodingFit}, Vector{Tuple{Vector{Int64}, UnitRange{Int64}}}, UnitRange{Int64}}}, static::Bool)
   @ Base.Threads ./threadingconstructs.jl:163
 [2] macro expansion
   @ ./threadingconstructs.jl:211 [inlined]
 [3] macro expansion
   @ ~/.julia/packages/Unfold/3KeNp/src/utilities.jl:169 [inlined]
 [4] fit(UnfoldDecodingModel::Type{UnfoldDecodingModel}, design::Dict{DataType, Tuple{StatsModels.FormulaTerm{StatsModels.ConstantTerm{Int64}, Tuple{StatsModels.ConstantTerm{Int64}, StatsModels.Term, StatsModels.Term}}, FIRBasis}}, tbl::DataFrames.DataFrame, dat::Matrix{Float64}, model::MLJMultivariateStatsInterface.LDA, target::Pair{DataType, Symbol}; nfolds::Int64, eventcolumn::Symbol, UnfoldFitkwargs::NamedTuple{(), Tuple{}}, multithreading::Bool)
   @ UnfoldDecode ~/.julia/packages/UnfoldDecode/fJ8fu/src/fit.jl:26
 [5] top-level scope
   @ ~/Julia/overlapcorrectedLDA.jl:29
 [6] include(fname::String)
   @ Base.MainInclude ./client.jl:478
 [7] top-level scope
   @ REPL[4]:1
in expression starting at /home/marting/Julia/overlapcorrectedLDA.jl:29
behinger commented 8 months ago

indeed, the documentation fails here as well

behinger commented 8 months ago

I will only work on this after the changes in Unfold on predict are made. Hope this is not urgent work, happy to take PRs as well, but there are no unittests yet, so I wouldnt trust my code that much anyway;)

behinger commented 4 months ago

ok - this is now fixed. There was a mistake in the implementation anyway, where I did not correct for overlap of same events,only of overlap of other events.