Skip to content

Commit

Permalink
Merge pull request nipreps#50 from celprov/enh/averagedw-model
Browse files Browse the repository at this point in the history
ENH: Add regression to the mean model
  • Loading branch information
oesteban authored May 10, 2021
2 parents eddbf62 + 9431be0 commit 22d2056
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions eddymotion/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ def predict(self, gradient, **kwargs):
return self._S0


class AverageDWModel:
"""A trivial model that returns an average map."""

__slots__ = ("_data", "_gtab")

def __init__(self, gtab, **kwargs):
"""Implement object initialization."""
self._gtab = gtab

def fit(self, data, **kwargs):
"""Calculate the average."""
self._data = data[..., self._gtab[..., 3] > 50].mean(-1)

def predict(self, gradient, **kwargs):
"""Return the average map."""
return self._data


class DTIModel:
"""A wrapper of :obj:`dipy.reconst.dti.TensorModel."""

Expand Down

0 comments on commit 22d2056

Please sign in to comment.