Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1061 : Changed all S0 to 1.0 #1063

Merged
merged 4 commits into from Jul 15, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dipy/data/__init__.py
Expand Up @@ -313,7 +313,7 @@ def dsi_deconv_voxels():
for iz in range(2):
data[ix, iy, iz], dirs = SticksAndBall(gtab,
d=0.0015,
S0=100,
S0=1.,
angles=[(0, 0),
(90, 0)],
fractions=[50, 50],
Expand Down
4 changes: 2 additions & 2 deletions dipy/reconst/csdeconv.py
Expand Up @@ -180,7 +180,7 @@ def fit(self, data):
return SphHarmFit(self, shm_coeff, None)


def predict(self, sh_coeff, gtab=None, S0=1):
def predict(self, sh_coeff, gtab=None, S0=1.):
"""Compute a signal prediction given spherical harmonic coefficients
for the provided GradientTable class instance.

Expand Down Expand Up @@ -951,7 +951,7 @@ def recursive_response(gtab, data, mask=None, sh_order=8, peak_thr=0.01,
the fiber response function for spherical deconvolution of
diffusion MRI data.
"""
S0 = 1
S0 = 1.
evals = fa_trace_to_lambdas(init_fa, init_trace)
res_obj = (evals, S0)

Expand Down
6 changes: 3 additions & 3 deletions dipy/reconst/dki.py
Expand Up @@ -889,7 +889,7 @@ def axial_kurtosis(dki_params, min_kurtosis=0, max_kurtosis=3):
return AK.reshape(outshape)


def dki_prediction(dki_params, gtab, S0=150):
def dki_prediction(dki_params, gtab, S0=1.):
""" Predict a signal given diffusion kurtosis imaging parameters.

Parameters
Expand Down Expand Up @@ -1038,7 +1038,7 @@ def fit(self, data, mask=None):

return DiffusionKurtosisFit(self, dki_params)

def predict(self, dki_params, S0=1):
def predict(self, dki_params, S0=1.):
""" Predict a signal for this DKI model class instance given
parameters.

Expand Down Expand Up @@ -1263,7 +1263,7 @@ def rk(self, min_kurtosis=0, max_kurtosis=3):
"""
return radial_kurtosis(self.model_params, min_kurtosis, max_kurtosis)

def predict(self, gtab, S0=1):
def predict(self, gtab, S0=1.):
r""" Given a DKI model fit, predict the signal on the vertices of a
gradient table

Expand Down
4 changes: 2 additions & 2 deletions dipy/reconst/dti.py
Expand Up @@ -806,7 +806,7 @@ def fit(self, data, mask=None):

return TensorFit(self, dti_params)

def predict(self, dti_params, S0=1):
def predict(self, dti_params, S0=1.):
"""
Predict a signal for this TensorModel class instance given parameters.

Expand Down Expand Up @@ -1132,7 +1132,7 @@ def adc(self, sphere):
"""
return apparent_diffusion_coef(self.quadratic_form, sphere)

def predict(self, gtab, S0=1, step=None):
def predict(self, gtab, S0=1., step=None):
r"""
Given a model fit, predict the signal on the vertices of a sphere

Expand Down
4 changes: 2 additions & 2 deletions dipy/reconst/mapmri.py
Expand Up @@ -108,7 +108,7 @@ def __init__(self,
>>> data, gtab = dsi_voxels()
>>> sphere = get_sphere('symmetric724')
>>> from dipy.sims.voxel import SticksAndBall
>>> data, golden_directions = SticksAndBall(gtab, d=0.0015, S0=1, angles=[(0, 0), (90, 0)], fractions=[50, 50], snr=None)
>>> data, golden_directions = SticksAndBall(gtab, d=0.0015, S0=100, angles=[(0, 0), (90, 0)], fractions=[50, 50], snr=None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're at it, would you mind making this PEP8 compliant, by introducing a line-break?

It should look like this:

data, golden_directions = SticksAndBall(gtab, d=0.0015, S0=100,
... angles=[(0, 0), (90, 0)], fractions=[50, 50], snr=None)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying again:

>>> data, golden_directions = SticksAndBall(gtab, d=0.0015, S0=100,
... angles=[(0, 0), (90, 0)], fractions=[50, 50], snr=None)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - like my second attempt (hard to indent and align things in this GH textbox...).

>>> from dipy.reconst.mapmri import MapmriModel
>>> radial_order = 4
>>> map_model = MapmriModel(gtab, radial_order=radial_order)
Expand Down Expand Up @@ -326,7 +326,7 @@ def rtop(self):
i, 2]) / 2.0) * self._mapmri_coef[i] * Bm[i]
return const * rtop

def predict(self, gtab, S0=1.0):
def predict(self, gtab, S0=1.):
"""
Predict a signal for this MapmriModel class instance given a gradient
table.
Expand Down
2 changes: 1 addition & 1 deletion dipy/reconst/shore.py
Expand Up @@ -157,7 +157,7 @@ def __init__(self,
gtab = gradient_table(bvals, bvecs)
from dipy.sims.voxel import SticksAndBall
data, golden_directions = SticksAndBall(gtab, d=0.0015,
S0=1, angles=[(0, 0), (90, 0)],
S0=1., angles=[(0, 0), (90, 0)],
fractions=[50, 50], snr=None)
from dipy.reconst.canal import ShoreModel
radial_order = 4
Expand Down
2 changes: 1 addition & 1 deletion dipy/sims/tests/test_voxel.py
Expand Up @@ -307,7 +307,7 @@ def test_DKI_crossing_fibers_simulations():
assert_array_almost_equal(dt, dt_ref)
assert_array_almost_equal(kt, kt_ref)
assert_array_almost_equal(signal,
DKI_signal(gtab_2s, dt_ref, kt_ref, S0=100,
DKI_signal(gtab_2s, dt_ref, kt_ref, S0=1.,
snr=None),
decimal=5)

Expand Down
10 changes: 5 additions & 5 deletions dipy/sims/voxel.py
Expand Up @@ -133,7 +133,7 @@ def add_noise(signal, snr, S0, noise_type='rician'):
return noise_adder[noise_type](signal, noise1, noise2)


def sticks_and_ball(gtab, d=0.0015, S0=100, angles=[(0, 0), (90, 0)],
def sticks_and_ball(gtab, d=0.0015, S0=1., angles=[(0, 0), (90, 0)],
fractions=[35, 35], snr=20):
""" Simulate the signal for a Sticks & Ball model.

Expand Down Expand Up @@ -188,7 +188,7 @@ def sticks_and_ball(gtab, d=0.0015, S0=100, angles=[(0, 0), (90, 0)],
return S, sticks


def single_tensor(gtab, S0=1, evals=None, evecs=None, snr=None):
def single_tensor(gtab, S0=1., evals=None, evecs=None, snr=None):
""" Simulated Q-space signal with a single tensor.

Parameters
Expand Down Expand Up @@ -244,7 +244,7 @@ def single_tensor(gtab, S0=1, evals=None, evecs=None, snr=None):
return S.reshape(out_shape)


def multi_tensor(gtab, mevals, S0=100, angles=[(0, 0), (90, 0)],
def multi_tensor(gtab, mevals, S0=1., angles=[(0, 0), (90, 0)],
fractions=[50, 50], snr=20):
r""" Simulate a Multi-Tensor signal.

Expand Down Expand Up @@ -305,7 +305,7 @@ def multi_tensor(gtab, mevals, S0=100, angles=[(0, 0), (90, 0)],
return add_noise(S, snr, S0), sticks


def multi_tensor_dki(gtab, mevals, S0=100, angles=[(90., 0.), (90., 0.)],
def multi_tensor_dki(gtab, mevals, S0=1., angles=[(90., 0.), (90., 0.)],
fractions=[50, 50], snr=20):
r""" Simulate the diffusion-weight signal, diffusion and kurtosis tensors
based on the DKI model
Expand Down Expand Up @@ -481,7 +481,7 @@ def kurtosis_element(D_comps, frac, ind_i, ind_j, ind_k, ind_l, DT=None,
return wijkl


def DKI_signal(gtab, dt, kt, S0=150, snr=None):
def DKI_signal(gtab, dt, kt, S0=1., snr=None):
r""" Simulated signal based on the diffusion and diffusion kurtosis
tensors of a single voxel. Simulations are preformed assuming the DKI
model.
Expand Down