Skip to content

Commit

Permalink
Merge pull request #15 from SFB-ELAINE/add_license_header
Browse files Browse the repository at this point in the history
Last touches before pre-release
  • Loading branch information
j-zimmermann authored Feb 12, 2024
2 parents aee6eab + 008a7a6 commit deb1ca3
Show file tree
Hide file tree
Showing 63 changed files with 287 additions and 98 deletions.
3 changes: 3 additions & 0 deletions leaddbsinterface/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Copyright 2023, 2024 Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

"""Lead-DBS interface: generate input files for OSS-DBS."""
3 changes: 3 additions & 0 deletions leaddbsinterface/convert_input_dictionary.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Konstantin Butenko, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import argparse
import json

Expand Down
4 changes: 4 additions & 0 deletions leaddbsinterface/default_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later


def load_default_for_lead(settings):
"""Add parameters that are not defined in Lead-DBS GUI.
Expand Down
15 changes: 9 additions & 6 deletions leaddbsinterface/lead_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Konstantin Butenko, Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import os
from dataclasses import asdict

Expand Down Expand Up @@ -186,8 +189,9 @@ def make_oss_settings(self, hemis_idx: int = 0, output_path: str = "") -> dict:
"FailFlag": side,
"TemplateSpace": self.get_est_in_temp(),
"Solver": {},
"FEMOrder": 2 + int(self.get_calc_axon_act()), # 2nd order is enough for stim volumes
"OutOfCore": bool(self.get_out_of_core())
# 2nd order enough for stim volumes
"FEMOrder": 2 + int(self.get_calc_axon_act()),
"OutOfCore": bool(self.get_out_of_core()),
}

# use actual signal parameters for PAM
Expand Down Expand Up @@ -332,10 +336,9 @@ def get_rot_z(self, index_side: int):
Always recalculated from the other settings
*IMPORTANT*: it is actually not native but scrf!
"""

if self.get_est_in_temp():
head_MNI = self.get_head_mni()[index_side, :]
y = self.get_y_mark_mni()[index_side, :] - head_MNI
y = self.get_y_mark_mni()[index_side, :] - head_MNI
else:
head_nat = self.get_head_nat()[index_side, :]
y = self.get_y_mark_nat()[index_side, :] - head_nat
Expand Down Expand Up @@ -394,7 +397,7 @@ def get_case_grnd(self):
def get_calc_axon_act(self):
"""Calculate axon activation."""
return self._get_num("calcAxonActivation")

def get_out_of_core(self):
"""Check if intermediate solution is unloaded."""
return self._get_num("outOfCore")
Expand Down Expand Up @@ -611,7 +614,7 @@ def import_implantation_settings(self, hemis_idx, elec_dict=None):
"DIXI D08-10AM": "DixiSEEG10",
"DIXI D08-12AM": "DixiSEEG12",
"DIXI D08-15AM": "DixiSEEG15",
"DIXI D08-18AM": "DixiSEEG18"
"DIXI D08-18AM": "DixiSEEG18",
}

for lead in electrode_names.keys():
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Konstantin Butenko, Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

"""Open-source software for deep brain stimulation."""
import logging

Expand Down
11 changes: 10 additions & 1 deletion ossdbs/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import logging

import numpy as np
Expand Down Expand Up @@ -362,7 +366,7 @@ def prepare_stimulation_signal(settings) -> FrequencyDomainSignal:
fourier_coefficients = np.ones(len(frequencies))
base_frequency = frequencies[0]
cutoff_frequency = frequencies[0]
signal_length = 1
signal_length = len(frequencies)
else:
spectrum_mode = signal_settings["SpectrumMode"]
if spectrum_mode == "OctaveBand":
Expand Down Expand Up @@ -424,6 +428,10 @@ def run_volume_conductor_model(settings, volume_conductor):
_logger.info("Will export solution to VTK")
else:
export_vtk = False
if "ExportFrequency" in settings:
export_frequency = settings["ExportFrequency"]
if export_frequency is not None:
_logger.info(f"Set custom export frequency to {export_frequency}.")

point_models = generate_point_models(settings)

Expand All @@ -433,6 +441,7 @@ def run_volume_conductor_model(settings, volume_conductor):
point_models=point_models,
activation_threshold=settings["ActivationThresholdVTA"],
out_of_core=out_of_core,
export_frequency=export_frequency
)
return vcm_timings

Expand Down
3 changes: 3 additions & 0 deletions ossdbs/dielectric_model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

"""Dielectric properties of required tissues."""
from .colecole3 import ColeCole3Model, default_cole_cole3_parameters
from .colecole4 import ColeCole4Model, ColeColeParameters, default_cole_cole4_parameters
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/dielectric_model/colecole3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Konstantin Butenko, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import numpy as np

from .colecole4 import ColeCole4Model, ColeColeParameters
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/dielectric_model/colecole4.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

from dataclasses import dataclass

import numpy as np
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/dielectric_model/constant.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

from dataclasses import dataclass

from scipy.constants import epsilon_0 as e0
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/dielectric_model/dielectric_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Jan Philipp Payonk, Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

from abc import ABC, abstractmethod

import numpy as np
Expand Down
4 changes: 4 additions & 0 deletions ossdbs/electrodes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

"""Electrode models for DBS."""
from .abbott_stjude import (
AbbottStJudeActiveTipModel,
Expand Down
4 changes: 4 additions & 0 deletions ossdbs/electrodes/abbott_stjude.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

# Abbott/St Jude Active Tip 6142-6145
from dataclasses import dataclass

Expand Down
5 changes: 5 additions & 0 deletions ossdbs/electrodes/boston_scientific_vercise.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Johannes Reding
# Copyright 2023, 2024 Tom Reincke, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

# Boston Scientific (Marlborough, Massachusetts, USA) vercise
from dataclasses import dataclass

Expand Down
8 changes: 8 additions & 0 deletions ossdbs/electrodes/defaults.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

from .abbott_stjude import (
AbbottStJudeActiveTipModel,
AbbottStJudeActiveTipParameters,
Expand Down Expand Up @@ -383,13 +387,15 @@ def PINSMedicalL303(
def DixiSEEG5(
rotation: float = 0, direction: tuple = (0, 0, 1), position: tuple = (0, 0, 0)
):
"""DixiSEEG5 electrode."""
parameters = default_electrode_parameters["DixiSEEG5"]
return DixiSEEGModel(parameters, rotation, direction, position)


def DixiSEEG8(
rotation: float = 0, direction: tuple = (0, 0, 1), position: tuple = (0, 0, 0)
):
"""DixiSEEG8 electrode."""
parameters = default_electrode_parameters["DixiSEEG8"]
return DixiSEEGModel(parameters, rotation, direction, position)

Expand All @@ -405,6 +411,7 @@ def DixiSEEG10(
def DixiSEEG12(
rotation: float = 0, direction: tuple = (0, 0, 1), position: tuple = (0, 0, 0)
):
"""DixiSEEG12 electrode."""
parameters = default_electrode_parameters["DixiSEEG12"]
return DixiSEEGModel(parameters, rotation, direction, position)

Expand All @@ -420,5 +427,6 @@ def DixiSEEG15(
def DixiSEEG18(
rotation: float = 0, direction: tuple = (0, 0, 1), position: tuple = (0, 0, 0)
):
"""DixiSEEG18 electrode."""
parameters = default_electrode_parameters["DixiSEEG18"]
return DixiSEEGModel(parameters, rotation, direction, position)
3 changes: 3 additions & 0 deletions ossdbs/electrodes/dixi_microtechniques.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

# Dixi Microtechniques SEEG
from dataclasses import asdict, dataclass

Expand Down
11 changes: 10 additions & 1 deletion ossdbs/electrodes/electrode_model_template.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import logging
from abc import ABC, abstractmethod
from dataclasses import asdict, dataclass
Expand Down Expand Up @@ -195,10 +199,15 @@ def export_electrode(self, output_path, brain_dict, n_electrode) -> None:
)
/ 2
)
try:
radius = self._parameters.lead_diameter / 2
except AttributeError:
radius = 1 # Set larger radius in case lead_diameter is not defined

cylinder = netgen.occ.Cylinder(
p=self._position,
d=self._direction,
r=self._parameters.lead_diameter,
r=radius,
h=height,
)

Expand Down
4 changes: 4 additions & 0 deletions ossdbs/electrodes/medtronic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

# Medtronic 3387
from dataclasses import dataclass

Expand Down
4 changes: 4 additions & 0 deletions ossdbs/electrodes/micro_probes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

from dataclasses import asdict, dataclass

import netgen
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/electrodes/microelectrode.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

from dataclasses import dataclass

import netgen
Expand Down
5 changes: 4 additions & 1 deletion ossdbs/electrodes/neuro_pace.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

# Boston Scientific (Marlborough, Massachusetts, USA) vercise
from dataclasses import dataclass

Expand All @@ -22,7 +25,7 @@ class NeuroPaceParameters:

def get_center_first_contact(self) -> float:
"""Returns distance between electrode tip and center of first contact."""
return 0.5 * self.tip_length
return self.tip_length + 0.5 * self.contact_length

def get_distance_l1_l4(self) -> float:
"""Returns distance between first level contact and fourth level contacts."""
Expand Down
4 changes: 4 additions & 0 deletions ossdbs/electrodes/pins_medical.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023, 2024 Konstantin Butenko, Shruthi Chakravarthy
# Copyright 2023, 2024 Jan Philipp Payonk, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

# PINS Medical L301
from dataclasses import dataclass

Expand Down
3 changes: 3 additions & 0 deletions ossdbs/electrodes/utilities.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import netgen.occ as occ


Expand Down
3 changes: 3 additions & 0 deletions ossdbs/fem/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

"""FEM part of OSS-DBS."""

from .mesh import Mesh
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/fem/mesh.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import os
from typing import List

Expand Down
3 changes: 3 additions & 0 deletions ossdbs/fem/preconditioner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import logging
from abc import ABC, abstractmethod

Expand Down
3 changes: 3 additions & 0 deletions ossdbs/fem/solver.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Jan Philipp Payonk, Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

from abc import ABC, abstractmethod

import ngsolve
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/fem/volume_conductor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

"""Core module for volume-conductor model."""
from .conductivity import ConductivityCF
from .floating import VolumeConductorFloating
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/fem/volume_conductor/conductivity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import logging

import ngsolve
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/fem/volume_conductor/floating.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Jan Philipp Payonk, Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import logging

import ngsolve
Expand Down
11 changes: 5 additions & 6 deletions ossdbs/fem/volume_conductor/floating_impedance.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Jan Philipp Payonk, Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import ngsolve

from ossdbs.fem.solver import Solver
Expand Down Expand Up @@ -60,18 +63,14 @@ def compute_solution(self, frequency: float) -> ngsolve.comp.GridFunction:
components = solution.components[1:]
self._floating_values = {
contact.name: component.vec[0]
for (contact, component) in zip(
self.contacts.floating, components
)
for (contact, component) in zip(self.contacts.floating, components)
}

def __create_space(self):
boundaries = [contact.name for contact in self.contacts.active]

h1_space = self.h1_space(boundaries=boundaries)
number_spaces = [
self.number_space() for _ in self.contacts.floating
]
number_spaces = [self.number_space() for _ in self.contacts.floating]
spaces = [h1_space, *number_spaces]
finite_elements_space = ngsolve.FESpace(spaces=spaces)
return ngsolve.CompressCompound(fespace=finite_elements_space)
Expand Down
3 changes: 3 additions & 0 deletions ossdbs/fem/volume_conductor/nonfloating.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, 2024 Johannes Reding, Julius Zimmermann
# SPDX-License-Identifier: GPL-3.0-or-later

import logging

import ngsolve
Expand Down
Loading

0 comments on commit deb1ca3

Please sign in to comment.