diff --git a/src/probeinterface/library.py b/src/probeinterface/library.py index 2f638bb..912e953 100644 --- a/src/probeinterface/library.py +++ b/src/probeinterface/library.py @@ -72,7 +72,7 @@ def get_from_cache(manufacturer: str, probe_name: str) -> Optional["Probe"]: return probe -def get_probe(manufacturer: str, probe_name: str) -> "Probe": +def get_probe(manufacturer: str, probe_name: str, name: Optional[str] = None) -> "Probe": """ Get probe from ProbeInterface library @@ -96,9 +96,9 @@ def get_probe(manufacturer: str, probe_name: str) -> "Probe": if probe is None: download_probeinterface_file(manufacturer, probe_name) probe = get_from_cache(manufacturer, probe_name) - if probe.annotations["manufacturer"] == "": - probe.annotations["manufacturer"] = manufacturer + if probe.manufacturer == "": + probe.manufacturer = manufacturer if name is not None: - probe.annotations["name"] = name + probe.name = name return probe diff --git a/src/probeinterface/probe.py b/src/probeinterface/probe.py index ad2f81e..5a7a9ba 100644 --- a/src/probeinterface/probe.py +++ b/src/probeinterface/probe.py @@ -81,12 +81,13 @@ def __init__( # annotation: a dict that contains all meta information about # the probe (name, manufacturor, date of production, ...) self.annotations = dict() - self.annotate( - name=name if name is not None else "", - serial_number=serial_number if serial_number is not None else "", - model_name=model_name if model_name is not None else "", - manufacturer=manufacturer if manufacturer is not None else "", - ) + + # set key properties + self.name = name + self.serial_number = serial_number + self.model_name = model_name + self.manufacturer = manufacturer + # same idea but handle in vector way for contacts self.contact_annotations = dict() @@ -122,18 +123,38 @@ def shank_ids(self): def name(self): return self.annotations.get("name", "") + @name.setter + def name(self, value): + if value is not None: + self.annotate(name=value) + @property def serial_number(self): return self.annotations.get("serial_number", "") + @serial_number.setter + def serial_number(self, value): + if value is not None: + self.annotate(serial_number=value) + @property def model_name(self): return self.annotations.get("model_name", "") + @model_name.setter + def model_name(self, value): + if value is not None: + self.annotate(model_name=value) + @property def manufacturer(self): return self.annotations.get("manufacturer", "") + @manufacturer.setter + def manufacturer(self, value): + if value is not None: + self.annotate(manufacturer=value) + def get_title(self) -> str: if self.contact_positions is None: txt = "Undefined probe"