Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty/initialize fields #1248

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
20 changes: 18 additions & 2 deletions src/foraging_gui/Foraging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3766,6 +3766,22 @@ def _set_default_project(self):
self.Metadata_dialog.project_info = project_info
self.Metadata_dialog.ProjectName.addItems([project_name])
return project_name

def _empty_initialize_fields(self):
'''empty fields from the previous session'''
self.open_ephys=[]
self.ManualWaterVolume=[0,0]
# clear camera start and end time
if not self.Camera_dialog.StartRecording.isChecked():
self.Camera_dialog.camera_start_time=''
self.Camera_dialog.camera_stop_time=''
# clear fiber start and end time
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite know the downstream effect but would these variables be better initialized as None? seems weird to me that they are just empty stings but maybe that is what the code is expecting downstream

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also does this fix #1124?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's related to the downstream metadata generation. This empty str indicates no camera datastream detected.

Yes, that issue was fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@micahwoodard is the concern here addressed?

if hasattr(self, 'fiber_photometry_end_time'):
del self.fiber_photometry_end_time
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we deleting this one and not clearing it like the others?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way should work. I have updated to empty string to keep consistent.

if not self.StartExcitation.isChecked():
if hasattr(self, 'fiber_photometry_start_time'):
del self.fiber_photometry_start_time

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here


def _Start(self):
'''start trial loop'''
Expand Down Expand Up @@ -4054,8 +4070,8 @@ def _Start(self):
self._StopCurrentSession()
# to see if we should start a new session
if self.StartANewSession==1 and self.ANewTrial==1:
# generate a new session id
self.ManualWaterVolume=[0,0]
# if we are starting a new session, we should initialize/empty some fields
self._empty_initialize_fields()
# start a new logging
try:
# Do not start a new session if the camera is already open, this means the session log has been started or the existing session has not been completed.
Expand Down