Skip to content
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

Implemented extract coefs function #4

Merged
merged 13 commits into from
Mar 13, 2024
Merged

Conversation

jschepers
Copy link
Collaborator

  • Implemented extract_coefs function to extract the coefficients of a fitted UnfoldModel for a certain predictor variable and event type (also added tests & docstrings)
  • Implemented define_simulation and sim_and_fit functions to simulate multi-subject data using UnfoldSim and fit Unfold models for all subjects. (tests & docstrings are still missing) (I used traits to make simulating & model fitting more modular)

multichannel_signal =
MultichannelComponent(signal, projection[channels, source_idx], NoNoise())
return multichannel_signal
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
end

ChannelStyle(::Type{UnitTestSimulation}) = MultiChannel()

EventStyle(::Type) = SingleEventType()
EventStyle(::Type{UnitTestSimulation}) = MultipleEventTypes()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
EventStyle(::Type{UnitTestSimulation}) = MultipleEventTypes()
EventStyle(::Type{UnitTestSimulation}) = MultipleEventTypes()

coefs_all_subjects = cat(coefs_vector..., dims = ndims(coefs_vector[1]) + 1)#::Array{<:Union{<:Missing,<:Float64},4}

return coefs_all_subjects
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
end

).estimate
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
end

test/setup.jl Outdated
using StableRNGs

include("../benchmark/types.jl")
include("../benchmark/sim_and_fit.jl")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
include("../benchmark/sim_and_fit.jl")
include("../benchmark/sim_and_fit.jl")

Comment on lines +95 to +109
"""
extract_coefs(model::UnfoldModel, predictor, basisname)

Return the coefficients of an Unfold model for a certain `predictor` and `basisname`.

For extracting the terms of a predictor variable `predictor` must be a symbol e.g. :continuous.
For extracting the intercept `predictor` should be a String, i.e. "(Intercept)".

`basisname` must match one of the basis names which can be found in `coeftable(model)`.

Note: If a predictor variable has more than one term in the formula (e.g. a spline set, a categorical variable with several levels or an interaction),
the coefficients for all terms are returned.

The dimensions of the returned coefficients are channel x times x coefficients.
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@behinger Could you have a short look at the docstrings for the extract_coefs function and its methods and tell me whether they make sense or whether you would adapt them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!

Copy link

codecov bot commented Mar 12, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@jschepers jschepers merged commit d4f98ce into main Mar 13, 2024
5 checks passed
@jschepers jschepers deleted the extract_coefs-function branch March 13, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants