From 797df36753aa67a85fcc8d11c0394e33d8b21fc0 Mon Sep 17 00:00:00 2001 From: arnaudon Date: Mon, 2 Dec 2024 14:37:15 +0100 Subject: [PATCH] fix --- neurots/generate/orientations.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/neurots/generate/orientations.py b/neurots/generate/orientations.py index adaf09bc..236dae2c 100644 --- a/neurots/generate/orientations.py +++ b/neurots/generate/orientations.py @@ -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]