Skip to content

Commit

Permalink
FIX: pass scheme to call of MultiCompartmentSphericalHarmonicsModel (#85
Browse files Browse the repository at this point in the history
)

* FIX: now correctly uses acquisition_scheme parameter in _construct_convolution_kernel call.
  • Loading branch information
matteofrigo committed Feb 20, 2020
1 parent 7706409 commit 2f109e8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions dmipy/core/modeling_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def _check_acquisition_scheme_has_b0s(self, acquisition_scheme):
raise ValueError('acquisition scheme must have b0-measurements '
'for signal-attenuation-based model fitting.')

def _construct_convolution_kernel(self, **kwargs):
def _construct_convolution_kernel(self, acquisition_scheme=None, **kwargs):
"""
Helper function that constructs the convolution kernel for the given
multi-compartment model and the initial condition x0_vector.
Expand All @@ -883,8 +883,8 @@ def _construct_convolution_kernel(self, **kwargs):
Parameters
----------
x0_vector: array of size (N_parameters),
Contains the fixed parameters of the convolution kernel.
acquisition_scheme: DmipyAcquisitionScheme instance,
An acquisition scheme that has been instantiated using Dmipy.
Returns
-------
Expand All @@ -894,6 +894,9 @@ def _construct_convolution_kernel(self, **kwargs):
"""
parameters_dict = self.add_linked_parameters_to_parameters(kwargs)

if acquisition_scheme is None:
acquisition_scheme = self.scheme

if self.volume_fractions_fixed:
if len(self.models) > 1:
partial_volumes = [
Expand All @@ -915,7 +918,7 @@ def _construct_convolution_kernel(self, **kwargs):
)
kernel += S0 * partial_volume * (
model.convolution_kernel_matrix(
self.scheme, self.sh_order, **parameters))
acquisition_scheme, self.sh_order, **parameters))
else:
kernel = []
for model, S0 in zip(self.models, self.S0_responses):
Expand All @@ -929,10 +932,10 @@ def _construct_convolution_kernel(self, **kwargs):
)
if 'orientation' in model.parameter_types.values():
kernel.append(S0 * model.convolution_kernel_matrix(
self.scheme, self.sh_order, **parameters))
acquisition_scheme, self.sh_order, **parameters))
else:
kernel.append(S0 * model.convolution_kernel_matrix(
self.scheme, 0, **parameters))
acquisition_scheme, 0, **parameters))

kernel = np.hstack(kernel)
return kernel
Expand Down Expand Up @@ -2161,13 +2164,11 @@ def __call__(self, acquisition_scheme, **kwargs):
----------
acquisition_scheme : DmipyAcquisitionScheme instance,
An acquisition scheme that has been instantiated using dMipy.
quantity : string
can be 'signal', 'FOD' or 'stochastic cost function' depending on
the need of the model.
kwargs: keyword arguments to the model parameter values,
Is internally given as **parameter_dictionary.
"""
A = self._construct_convolution_kernel(**kwargs)
A = self._construct_convolution_kernel(
acquisition_scheme=acquisition_scheme, **kwargs)
self.S0_responses = kwargs.get('S0_responses', self.S0_responses)
self.fit_S0_response = kwargs.get(
'fit_S0_response', self.fit_S0_response)
Expand Down

0 comments on commit 2f109e8

Please sign in to comment.