Skip to content

Commit

Permalink
changed spherical_mean to _spherical_mean
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerfick committed Feb 1, 2018
1 parent a6b573f commit f424594
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions dmipy/core/fitted_modeling_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def predict(self, acquisition_scheme=None, S0=None, mask=None):
if mask is None:
mask = self.mask

if self.model.spherical_mean:
if self.model._spherical_mean:
N_samples = len(acquisition_scheme.shell_bvalues)
else:
N_samples = len(acquisition_scheme.bvalues)
Expand All @@ -181,7 +181,7 @@ def predict(self, acquisition_scheme=None, S0=None, mask=None):

def R2_coefficient_of_determination(self, data):
"Calculates the R-squared of the model fit."
if self.model.spherical_mean:
if self.model._spherical_mean:
Nshells = len(self.model.scheme.shell_bvalues)
data_ = np.zeros(np.r_[data.shape[:-1], Nshells])
for pos in zip(*np.where(self.mask)):
Expand All @@ -200,7 +200,7 @@ def R2_coefficient_of_determination(self, data):

def mean_squared_error(self, data):
"Calculates the mean squared error of the model fit."
if self.model.spherical_mean:
if self.model._spherical_mean:
Nshells = len(self.model.scheme.shell_bvalues)
data_ = np.zeros(np.r_[data.shape[:-1], Nshells])
for pos in zip(*np.where(self.mask)):
Expand Down
9 changes: 5 additions & 4 deletions dmipy/core/modeling_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,13 @@ def _prepare_model_properties(self):
"""Checks that spherical mean and regular models cannot be optimized
together, and whether the model can estimate a Fiber Orientation
Distribution (FOD)."""
models_spherical_mean = [model.spherical_mean for model in self.models]
models_spherical_mean = [
model._spherical_mean for model in self.models]
if len(np.unique(models_spherical_mean)) > 1:
msg = "Cannot mix spherical mean and non-spherical mean models. "
msg = "Current model selection is {}".format(self.models)
raise ValueError(msg)
self.spherical_mean = np.all(models_spherical_mean)
self._spherical_mean = np.all(models_spherical_mean)
self.fod_available = False
for model in self.models:
try:
Expand Down Expand Up @@ -648,7 +649,7 @@ def fit(self, acquisition_scheme, data, parameter_initial_guess=None,

# if the models are spherical mean based then estimate the
# spherical mean of the data.
if self.spherical_mean:
if self._spherical_mean:
data_to_fit = np.zeros(
np.r_[data_.shape[:-1],
self.scheme.unique_dwi_indices.max() + 1])
Expand Down Expand Up @@ -721,7 +722,7 @@ def simulate_signal(self, acquisition_scheme, model_parameters_array):
The simulated signal of the microstructure model.
"""
Ndata = acquisition_scheme.number_of_measurements
if self.spherical_mean:
if self._spherical_mean:
Ndata = len(acquisition_scheme.shell_bvalues)
x0 = model_parameters_array

Expand Down
2 changes: 1 addition & 1 deletion dmipy/distributions/distribute_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class DistributedModel:
"Contains various properties of distributed models."
spherical_mean = False
_spherical_mean = False

def _check_for_double_model_class_instances(self):
"Checks if there are no models with the same class instantiation."
Expand Down
6 changes: 3 additions & 3 deletions dmipy/distributions/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SD1Watson(ModelProperties):
'mu': np.r_[1., 1.],
'odi': 1.,
}
spherical_mean = False
_spherical_mean = False

def __init__(self, mu=None, odi=None):
self.mu = mu
Expand Down Expand Up @@ -182,7 +182,7 @@ class SD2Bingham(ModelProperties):
'odi': 1.,
'beta_fraction': 1.
}
spherical_mean = False
_spherical_mean = False

def __init__(self, mu=None, psi=None, odi=None, beta_fraction=None):
self.mu = mu
Expand Down Expand Up @@ -346,7 +346,7 @@ class DD1GammaDistribution(ModelProperties):
'alpha': 1.,
'beta': BETA_SCALING,
}
spherical_mean = False
_spherical_mean = False

def __init__(self, alpha=None, beta=None, Nsteps=30,
normalization='standard'):
Expand Down
2 changes: 1 addition & 1 deletion dmipy/signal_models/capped_cylinder_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CC3CappedCylinderCallaghanApproximation(ModelProperties):
53-59.
"""

spherical_mean = False
_spherical_mean = False
_model_type = 'experimental'

def __init__(
Expand Down
8 changes: 4 additions & 4 deletions dmipy/signal_models/cylinder_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class C1Stick(ModelProperties):
'mu': np.r_[1., 1.],
'lambda_par': DIFFUSIVITY_SCALING
}
spherical_mean = False
_spherical_mean = False
_model_type = 'other'

def __init__(self, mu=None, lambda_par=None):
Expand Down Expand Up @@ -156,7 +156,7 @@ class C2CylinderSodermanApproximation(ModelProperties):
'lambda_par': DIFFUSIVITY_SCALING,
'diameter': DIAMETER_SCALING
}
spherical_mean = False
_spherical_mean = False
_model_type = 'cylinder'

def __init__(
Expand Down Expand Up @@ -291,7 +291,7 @@ class C3CylinderCallaghanApproximation(ModelProperties):
'lambda_par': DIFFUSIVITY_SCALING,
'diameter': DIAMETER_SCALING
}
spherical_mean = False
_spherical_mean = False
_model_type = 'cylinder'

def __init__(
Expand Down Expand Up @@ -456,7 +456,7 @@ class C4CylinderGaussianPhaseApproximation(ModelProperties):
'lambda_par': DIFFUSIVITY_SCALING,
'diameter': DIAMETER_SCALING
}
spherical_mean = False
_spherical_mean = False
_model_type = 'cylinder'
_CYLINDER_TRASCENDENTAL_ROOTS = np.sort(special.jnp_zeros(1, 100))

Expand Down
6 changes: 3 additions & 3 deletions dmipy/signal_models/gaussian_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class G1Ball(ModelProperties):
_parameter_scales = {
'lambda_iso': DIFFUSIVITY_SCALING
}
spherical_mean = False
_spherical_mean = False
_model_type = 'other'

def __init__(self, lambda_iso=None):
Expand Down Expand Up @@ -120,7 +120,7 @@ class G2Zeppelin(ModelProperties):
'lambda_par': DIFFUSIVITY_SCALING,
'lambda_perp': DIFFUSIVITY_SCALING
}
spherical_mean = False
_spherical_mean = False
_model_type = 'other'

def __init__(self, mu=None, lambda_par=None, lambda_perp=None):
Expand Down Expand Up @@ -224,7 +224,7 @@ class G3RestrictedZeppelin(ModelProperties):
'lambda_perp': DIFFUSIVITY_SCALING,
'A': A_SCALING
}
spherical_mean = False
_spherical_mean = False
_model_type = 'other'

def __init__(self, mu=None, lambda_par=None, lambda_inf=None, A=None):
Expand Down
2 changes: 1 addition & 1 deletion dmipy/signal_models/plane_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class P3PlaneCallaghanApproximation(ModelProperties):
'diameter': DIAMETER_SCALING
}

spherical_mean = False
_spherical_mean = False
_model_type = 'plane'

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions dmipy/signal_models/sphere_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class S1Dot(ModelProperties):
}
_parameter_scales = {
}
spherical_mean = False
_spherical_mean = False
_model_type = 'other'

def __call__(self, acquisition_scheme, **kwargs):
Expand Down Expand Up @@ -67,7 +67,7 @@ class S2SphereSodermanApproximation(ModelProperties):
_parameter_scales = {
'diameter': DIAMETER_SCALING
}
spherical_mean = False
_spherical_mean = False
_model_type = 'sphere'

def __init__(self, diameter=None):
Expand Down
6 changes: 3 additions & 3 deletions dmipy/signal_models/spherical_mean_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class C1StickSphericalMean(ModelProperties):
_parameter_scales = {
'lambda_par': DIFFUSIVITY_SCALING,
}
spherical_mean = True
_spherical_mean = True
_model_type = 'other'

def __init__(self, lambda_par=None):
Expand Down Expand Up @@ -101,7 +101,7 @@ class G2ZeppelinSphericalMean(ModelProperties):
'lambda_par': DIFFUSIVITY_SCALING,
'lambda_perp': DIFFUSIVITY_SCALING
}
spherical_mean = True
_spherical_mean = True
_model_type = 'other'

def __init__(self, lambda_par=None, lambda_perp=None):
Expand Down Expand Up @@ -175,7 +175,7 @@ class G3RestrictedZeppelinSphericalMean(ModelProperties):
'lambda_inf': DIFFUSIVITY_SCALING,
'A': A_SCALING
}
spherical_mean = True
_spherical_mean = True
_model_type = 'other'

def __init__(self, lambda_par=None, lambda_inf=None, A=None):
Expand Down

0 comments on commit f424594

Please sign in to comment.