From 8022307470d3ac90d7883874539aae4c4cc5abd4 Mon Sep 17 00:00:00 2001 From: Konstantin Butenko <35195806+Kinway25@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:05:31 +0100 Subject: [PATCH] UPD: brain approx. uses directionality and span (#64) * UPD: brain approx. uses directionality and span * fix formatting --------- Co-authored-by: JPPayonk --- leaddbsinterface/lead_settings.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/leaddbsinterface/lead_settings.py b/leaddbsinterface/lead_settings.py index b750295..eb28509 100644 --- a/leaddbsinterface/lead_settings.py +++ b/leaddbsinterface/lead_settings.py @@ -114,6 +114,24 @@ def make_oss_settings(self, hemis_idx: int = 0, output_path: str = "") -> dict: elec_dict["Name"], hemis_idx, unit_directions, specs_array_length ) + # check the distance between first and last contact for brain approx. dimensions + contact_locations = self.get_cntct_loc() + first_contact = np.array( + [ + contact_locations[hemis_idx][0][0], + contact_locations[hemis_idx][1][0], + contact_locations[hemis_idx][2][0], + ] + ) + last_contact = np.array( + [ + contact_locations[hemis_idx][0][-1], + contact_locations[hemis_idx][1][-1], + contact_locations[hemis_idx][2][-1], + ] + ) + actual_span = np.linalg.norm(last_contact - first_contact) + # MAKE THE DICTIONARY partial_dict = { "ModelSide": 0, # hardcoded for now, always keep to 0 @@ -123,7 +141,16 @@ def make_oss_settings(self, hemis_idx: int = 0, output_path: str = "") -> dict: "x[mm]": self.get_imp_coord()[hemis_idx, 0], "y[mm]": self.get_imp_coord()[hemis_idx, 1], "z[mm]": self.get_imp_coord()[hemis_idx, 2], - } + }, + # define brain approximation according to the electrode directionality + "Dimension": { + "x[mm]": 50.0 + + np.abs(unit_directions[hemis_idx, 0]) * actual_span * 2.0, + "y[mm]": 50.0 + + np.abs(unit_directions[hemis_idx, 1]) * actual_span * 2.0, + "z[mm]": 50.0 + + np.abs(unit_directions[hemis_idx, 2]) * actual_span * 2.0, + }, }, "Electrodes": elec_dicts, "Surfaces": [