Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon committed Dec 2, 2024
1 parent 31bf5b9 commit 797df36
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions neurots/generate/orientations.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,24 @@ def _mode_normal_pia_constraint(self, values_dict, tree_type, max_tries=100):

angles = []
for _ in range(n_orientations):
means = values_dict["direction"]["mean"]
means = means if isinstance(means, list) else [means]
stds = values_dict["direction"]["std"]
stds = stds if isinstance(stds, list) else [stds]
thetas = []
for mean, std in zip(means, stds):
if mean == 0:
if std > 0:
thetas.append(np.clip(self._rng.exponential(std), 0, np.pi))
else:
thetas.append(0)
else:
thetas.append(np.clip(self._rng.normal(mean, std), 0, np.pi))

phis = self._rng.uniform(0, 2 * np.pi, len(means))

def propose(_):
means = values_dict["direction"]["mean"]
means = means if isinstance(means, list) else [means]
stds = values_dict["direction"]["std"]
stds = stds if isinstance(stds, list) else [stds]

thetas = []
for mean, std in zip(means, stds):
if mean == 0:
if std > 0:
thetas.append(np.clip(self._rng.exponential(std), 0, np.pi))
else:
thetas.append(0)
else:
thetas.append(np.clip(self._rng.normal(mean, std), 0, np.pi))

phis = self._rng.uniform(0, 2 * np.pi, len(means))
return spherical_angles_to_pia_orientations(
phis, thetas, self._context.get("y_rotation", None)
).tolist()[0]
Expand Down

0 comments on commit 797df36

Please sign in to comment.