Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit 9d401d0

Browse files
committed
enh: rename eddymotion._sklearn -> eddymotion.gpr
* rename the module so that it is picked up by autodoc. * also fixes minor errors and improves docs.
1 parent 7e5f333 commit 9d401d0

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

docs/notebooks/dmri_covariance.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"import matplotlib.pyplot as plt\n",
2525
"import numpy as np\n",
2626
"\n",
27-
"from eddymotion.model._sklearn import (\n",
27+
"from eddymotion.model.gpr import (\n",
2828
" compute_pairwise_angles,\n",
2929
" exponential_covariance,\n",
3030
" spherical_covariance,\n",
@@ -345,7 +345,7 @@
345345
}
346346
],
347347
"source": [
348-
"from eddymotion.model._sklearn import EddyMotionGPR, SphericalKriging\n",
348+
"from eddymotion.model.gpr import EddyMotionGPR, SphericalKriging\n",
349349
"\n",
350350
"K = SphericalKriging(beta_a=PARAMETER_SPHERICAL_a, beta_l=PARAMETER_lambda)(X_real)\n",
351351
"K -= K.min()\n",

scripts/dwi_gp_estimation_error_analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import pandas as pd
3737
from sklearn.model_selection import KFold, RepeatedKFold, cross_val_predict, cross_val_score
3838

39-
from eddymotion.model._sklearn import (
39+
from eddymotion.model.gpr import (
4040
EddyMotionGPR,
4141
SphericalKriging,
4242
)
@@ -63,7 +63,7 @@ def cross_validate(
6363
Number of folds.
6464
n_repeats : :obj:`int`
6565
Number of times the cross-validator needs to be repeated.
66-
gpr : obj:`~eddymotion.model._sklearn.EddyMotionGPR`
66+
gpr : obj:`~eddymotion.model.gpr.EddyMotionGPR`
6767
The eddymotion Gaussian process regressor object.
6868
6969
Returns

scripts/dwi_gp_estimation_simulated_signal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import numpy as np
3434
from dipy.core.sphere import Sphere
3535

36-
from eddymotion.model._sklearn import EddyMotionGPR, SphericalKriging
36+
from eddymotion.model.gpr import EddyMotionGPR, SphericalKriging
3737
from eddymotion.testing import simulations as testsims
3838

3939
SAMPLING_DIRECTIONS = 200

src/eddymotion/estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from eddymotion import utils as eutils
3232
from eddymotion.data.splitting import lovo_split
33-
from eddymotion.model import ModelFactory
33+
from eddymotion.model.base import ModelFactory
3434
from eddymotion.registration.ants import _prepare_registration_data, _run_registration
3535

3636

src/eddymotion/model/_dipy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from dipy.reconst.base import ReconstModel
3232
from sklearn.gaussian_process import GaussianProcessRegressor
3333

34-
from eddymotion.model._sklearn import (
34+
from eddymotion.model.gpr import (
3535
EddyMotionGPR,
3636
ExponentialKriging,
3737
SphericalKriging,

src/eddymotion/model/_sklearn.py renamed to src/eddymotion/model/gpr.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
r"""
2424
Derivations from scikit-learn for Gaussian Processes.
2525
26+
2627
Gaussian Process Model: Pairwise orientation angles
2728
---------------------------------------------------
2829
Squared Exponential covariance kernel
@@ -101,10 +102,10 @@
101102
from sklearn.metrics.pairwise import cosine_similarity
102103
from sklearn.utils._param_validation import Interval, StrOptions
103104

104-
BOUNDS_A: tuple[float, float] = (0.1, np.pi)
105-
"""The limits for the parameter *a*."""
105+
BOUNDS_A: tuple[float, float] = (0.1, 0.75 * np.pi)
106+
"""The limits for the parameter *a* (angular distance)."""
106107
BOUNDS_LAMBDA: tuple[float, float] = (1e-3, 1000)
107-
"""The limits for the parameter lambda."""
108+
"""The limits for the parameter λ (signal scaling factor)."""
108109
THETA_EPSILON: float = 1e-5
109110
"""Minimum nonzero angle."""
110111
LBFGS_CONFIGURABLE_OPTIONS = {"disp", "maxiter", "ftol", "gtol"}
@@ -143,8 +144,7 @@ class EddyMotionGPR(GaussianProcessRegressor):
143144
144145
In principle, Scikit-Learn's implementation normalizes the training data
145146
as in [Andersson15]_ (see
146-
`FSL's souce code <https://git.fmrib.ox.ac.uk/fsl/eddy/-/blob/\
147-
2480dda293d4cec83014454db3a193b87921f6b0/DiffusionGP.cpp#L218>`__).
147+
`FSL's souce code <https://git.fmrib.ox.ac.uk/fsl/eddy/-/blob/2480dda293d4cec83014454db3a193b87921f6b0/DiffusionGP.cpp#L218>`__).
148148
From their paper (p. 167, end of first column):
149149
150150
Typically one just substracts the mean (:math:`\bar{\mathbf{f}}`)
@@ -161,7 +161,7 @@ class EddyMotionGPR(GaussianProcessRegressor):
161161
I believe this is overlooked in [Andersson15]_, or they actually did not
162162
use analytical gradient-descent:
163163
164-
_A note on optimisation_
164+
*A note on optimisation*
165165
166166
It is suggested, for example in Rasmussen and Williams (2006), that
167167
an optimisation method that uses derivative information should be
@@ -184,7 +184,7 @@ class EddyMotionGPR(GaussianProcessRegressor):
184184
"optimizer": [StrOptions(SUPPORTED_OPTIMIZERS), callable, None],
185185
"n_restarts_optimizer": [Interval(Integral, 0, None, closed="left")],
186186
"copy_X_train": ["boolean"],
187-
"zeromean_y": ["boolean"],
187+
"normalize_y": ["boolean"],
188188
"n_targets": [Interval(Integral, 1, None, closed="left"), None],
189189
"random_state": ["random_state"],
190190
}

test/test_sklearn.py renamed to test/test_gpr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import pytest
2727
from dipy.io import read_bvals_bvecs
2828

29-
from eddymotion.model import _sklearn as ems
29+
from eddymotion.model import gpr
3030

3131
GradientTablePatch = namedtuple("gtab", ["bvals", "bvecs"])
3232

@@ -263,7 +263,7 @@ def test_compute_pairwise_angles(bvecs1, bvecs2, closest_polarity, expected):
263263
if bvecs2 is not None:
264264
_bvecs2 = (bvecs2 / np.linalg.norm(bvecs2, axis=0)).T
265265

266-
obtained = ems.compute_pairwise_angles(_bvecs1, _bvecs2, closest_polarity)
266+
obtained = gpr.compute_pairwise_angles(_bvecs1, _bvecs2, closest_polarity)
267267

268268
if _bvecs2 is not None:
269269
assert (_bvecs1.shape[0], _bvecs2.shape[0]) == obtained.shape
@@ -282,7 +282,7 @@ def test_kernel(repodata, covariance):
282282

283283
bvecs = bvecs[bvals > 10]
284284

285-
KernelType = getattr(ems, f"{covariance}Kriging")
285+
KernelType = getattr(gpr, f"{covariance}Kriging")
286286
kernel = KernelType()
287287
K = kernel(bvecs)
288288

0 commit comments

Comments
 (0)