diff --git a/Project.toml b/Project.toml index ffd9b37..34d0e04 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PyMNE" uuid = "6c5003b2-cbe8-491c-a0d1-70088e6a0fd6" authors = ["Beacon Biosignals, Inc."] -version = "0.1.1" +version = "0.1.2" [deps] PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" @@ -15,4 +15,4 @@ PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["PyCall", "Test"] +test = ["PyCall", "Test"] diff --git a/README.md b/README.md index bf03daf..3b0f9e5 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ be changed via the `ENV["MNEVERSION"] = version_number` for your preferred the rather rapid API changes and deprecation cycle in MNE and as such, it is incumbent upon the user to manage these versions accordingly. +Note that MNE-Python uses [scikit-learn](https://scikit-learn.org/stable/) for certain functionality (e.g. ICA and the `decoding` module), but does not install it automatically as a dependency. +If you wish to take advantage of this functionality, the non-exported `install_sklearn` function will install `sklearn`, using the same environment variables as the main installation. MNE-Python can also be installed them manually ahead of time. From the shell, use `python -m pip install mne` for the latest stable release diff --git a/src/PyMNE.jl b/src/PyMNE.jl index a6f4883..d51828c 100644 --- a/src/PyMNE.jl +++ b/src/PyMNE.jl @@ -41,4 +41,25 @@ function __init__() return nothing end +""" + install_sklearn(ver="") + +Install scikit-learn using the specified version. + +The default version is the latest stable version. +""" +function install_sklearn(version="latest"; verbose=false) + verbose && @info "Installing scikit-learn" + pip = pyimport("pip") + flags = split(get(ENV, "PIPFLAGS", "")) + packages = ["scikit-learn" * (version == "latest" ? "" : "==$version")] + if verbose + @info "Package requirements:" packages + @info "Flags for pip install:" flags + @info "scikit-learn version:" version + end + pip.main(["install"; flags; packages]) + return nothing +end + end # module diff --git a/test/runtests.jl b/test/runtests.jl index d0ab8aa..88dcf7c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,6 +4,12 @@ using Test using PyCall: PyError +@testset "sklearn" begin + PyMNE.install_sklearn() + # requires sklearn + @test PyMNE.preprocessing.ICA(method="fastica") isa PyObject +end + @testset "create_info and get_info" begin dat = zeros(1, 100) naive_info = PyMNE.mne.create_info([:a], 100)