Skip to content

Commit

Permalink
UPD: brain approx. uses directionality and span (#64)
Browse files Browse the repository at this point in the history
* UPD: brain approx. uses directionality and span

* fix formatting

---------

Co-authored-by: JPPayonk <[email protected]>
  • Loading branch information
Kinway25 and JPPayonk authored Dec 20, 2024
1 parent bc13f5e commit 8022307
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion leaddbsinterface/lead_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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": [
Expand Down

0 comments on commit 8022307

Please sign in to comment.