Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Dynamic Foraging Task
# Dynamic Foraging Task

A [Bonsai](https://bonsai-rx.org/) workflow for lick-based foraging experiments, with a [PyQt](https://wiki.python.org/moin/PyQt) frontend for visualizing performance and modifying task parameters.

Expand Down
38 changes: 27 additions & 11 deletions src/foraging_gui/Foraging.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
PlotV,
)
from foraging_gui.warning_widget import WarningWidget
import csv


logger = logging.getLogger(__name__)
logger.root.handlers.clear() # clear handlers so console output can be configured
Expand Down Expand Up @@ -1824,17 +1826,11 @@ def _GetApprovedAINDProjectNames(self):
)
return []

def parse_setting_csv_file(self, csv_file) -> dict:
settings = {}
with open(csv_file, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
if not line:
continue
if ',' in line:
key, value = line.split(',', 1)
settings[key.strip()] = value.strip()
return settings
def parse_setting_csv_file(self, csv_file: str) -> dict:
with open(csv_file, newline='') as csvfile:
reader = csv.reader(csvfile)
return {rows[0]:rows[1] for rows in reader}

def _GetSettings(self):
"""
Load the settings that are specific to this computer
Expand Down Expand Up @@ -7275,6 +7271,10 @@ def _generate_upload_manifest(self):
self.VideoFolder.replace("\\", "/")
]

# Determine sci email
sci = self._GetInfoFromSchedule(self.behavior_session_model.subject, "PI")
sci_email = "svc_aind_behavior@alleninstitute.org" if not sci else get_user_email(sci)

# Define contents of manifest file
contents = {
"acquisition_datetime": self.behavior_session_model.date,
Expand All @@ -7299,6 +7299,7 @@ def _generate_upload_manifest(self):
"schedule_time": schedule_time,
"project_name": self.Metadata_dialog.ProjectName.currentText(),
"script": {},
"user_email": sci_email
}

# Define filename of manifest
Expand All @@ -7324,6 +7325,21 @@ def _generate_upload_manifest(self):
+ "Please alert the mouse owner, and report on github.",
)

def get_user_email(username: str) -> str:
domain = ms_active_directory.ADDomain("corp.alleninstitute.org")
domain_username = getpass.getuser()
session = domain.create_session_as_user(
domain_username,
authentication_mechanism=ldap3.SASL,
sasl_mechanism=ldap3.GSSAPI,
)

ad_user = session.find_user_by_name(username, attributes_to_lookup=["mail"])
if ad_user is None:
raise ValueError(f"User '{username}' not found in Active Directory.")
return ad_user.all_attributes["mail"]


def validate_aind_username(
username: str,
domain: str = "corp.alleninstitute.org",
Expand Down
3 changes: 3 additions & 0 deletions src/foraging_gui/settings_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ class BonsaiSettingsModel(BaseModel):
default=8,
description="Gain for the body camera"
)

video_file_format: Literal["mp4", "mkv"] = Field(default="mkv", description="File format to write video files to.")

ffmpeg_output_args: str = Field() # required field so no default
ffmpeg_input_args: str = Field() # required field so no default

Expand Down
Loading
Loading