Skip to content

Commit c1dad6c

Browse files
committed
logging and docstrings
1 parent 79977ac commit c1dad6c

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/trodes_to_nwb/convert_optogenetics.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from pathlib import Path
23
from typing import List, Tuple
34

@@ -30,20 +31,19 @@ def add_optogenetics(nwbfile: NWBFile, metadata: dict, device_metadata: List[dic
3031
device_metadata : list
3132
List of dictionaries containing metadata for devices used in the experiment.
3233
"""
34+
logger = logging.getLogger("convert")
3335
if not all(
3436
[
3537
x in metadata
3638
for x in [
37-
# "optogenetic_experiment",
3839
"virus_injection",
3940
"opto_excitation_source",
4041
"optical_fiber",
4142
"optogenetic_stimulation_software",
4243
]
4344
]
4445
):
45-
print("missing optogenetic metadata")
46-
# TODO Log lack of metadata
46+
logger.info("No available optogenetic metadata")
4747
return
4848

4949
# Add optogenetic experiment metadata
@@ -80,6 +80,16 @@ def add_optogenetics(nwbfile: NWBFile, metadata: dict, device_metadata: List[dic
8080
def make_optogenetic_source(
8181
nwbfile: NWBFile, source_metadata: dict, device_metadata: List[dict]
8282
) -> ExcitationSource:
83+
"""Create an ExcitationSource object and add it to the NWB file.
84+
85+
Args:
86+
nwbfile (NWBFile): The NWB file to which the excitation source will be added.
87+
source_metadata (dict): Metadata for the excitation source.
88+
device_metadata (List[dict]): Metadata for the excitation device used in the experiment.
89+
90+
Returns:
91+
ExcitationSource: The created ExcitationSource object.
92+
"""
8393
model_metadata = get_optogenetic_source_device(
8494
source_metadata["model_name"], device_metadata
8595
)
@@ -108,6 +118,16 @@ def make_optical_fiber(
108118
excitation_source: ExcitationSource,
109119
device_metadata: List[dict],
110120
) -> OpticalFiber:
121+
"""Create an OpticalFiberLocationsTable and populate it with optical fiber data.
122+
123+
Args:
124+
nwbfile (NWBFile): The NWB file to which the optical fiber locations table will be added.
125+
fiber_metadata_list (dict): Metadata for the optical fibers.
126+
excitation_source (ExcitationSource): The excitation source associated with the optical fibers.
127+
128+
Returns:
129+
OpticalFiber: The created OpticalFiber object.
130+
"""
111131
# make the locations table
112132
optical_fiber_locations_table = OpticalFiberLocationsTable(
113133
description="Information about implanted optical fiber locations",
@@ -172,6 +192,13 @@ def make_virus_injecton(
172192
----------
173193
virus_injection_metadata : dict
174194
Metadata containing information about the virus injection.
195+
device_metadata : list
196+
List of dictionaries containing metadata for virus "devices" used in the experiment.
197+
198+
Returns
199+
-------
200+
Tuple[OptogeneticViruses, OptogeneticVirusInjections]
201+
A tuple containing the OptogeneticViruses and OptogeneticVirusInjections objects.
175202
"""
176203
included_viruses = {}
177204
injections_list = []

0 commit comments

Comments
 (0)