From c01a251a135ebdf32788664f3719f03b05ee0b48 Mon Sep 17 00:00:00 2001
From: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 12 Dec 2024 04:55:51 +0000
Subject: [PATCH 01/12] ci: version bump [skip actions]

---
 src/foraging_gui/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/__init__.py b/src/foraging_gui/__init__.py
index 18683c510..ceae0e561 100644
--- a/src/foraging_gui/__init__.py
+++ b/src/foraging_gui/__init__.py
@@ -1,3 +1,3 @@
-__version__ = "1.6.11"
+__version__ = "1.6.12"
 
 

From 05d0c9c6bb6cc1f0cd36c8081328c92059e3e93a Mon Sep 17 00:00:00 2001
From: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 12 Dec 2024 05:05:46 +0000
Subject: [PATCH 02/12] ci: version bump [skip actions]

---
 src/foraging_gui/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/__init__.py b/src/foraging_gui/__init__.py
index ceae0e561..0a6b5300e 100644
--- a/src/foraging_gui/__init__.py
+++ b/src/foraging_gui/__init__.py
@@ -1,3 +1,3 @@
-__version__ = "1.6.12"
+__version__ = "1.6.13"
 
 

From 98e46a8069a4c1bc828d2d0c07c907cb090084e4 Mon Sep 17 00:00:00 2001
From: XX-Yin <109394934+XX-Yin@users.noreply.github.com>
Date: Wed, 11 Dec 2024 21:09:30 -0800
Subject: [PATCH 03/12] Revert "Fix 1155 waterlog post session weight"

---
 src/foraging_gui/Foraging.py | 19 +++++++++++++------
 tash                         | 31 -------------------------------
 2 files changed, 13 insertions(+), 37 deletions(-)
 delete mode 100644 tash

diff --git a/src/foraging_gui/Foraging.py b/src/foraging_gui/Foraging.py
index 5b02a87f7..5d33b0721 100644
--- a/src/foraging_gui/Foraging.py
+++ b/src/foraging_gui/Foraging.py
@@ -1361,15 +1361,14 @@ def _AddWaterLogResult(self, session: Session):
 
         # extract software information
         logging.info('Extracting software information from first data stream')
-        software = session.stimulus_epochs[0].software[0]
+        software = session.data_streams[0].software[0]
 
         # create model
         logging.info('Creating SlimsWaterlogResult based on session information.')
         model = models.SlimsWaterlogResult(
             mouse_pk=mouse.pk,
             date=session.session_start_time,
-            weight_g=session.animal_weight_post,
-            operator=self.behavior_session_model.experimenter[0],
+            weight_g=session.animal_weight_prior,
             water_earned_ml=water['water_in_session_foraging'],
             water_supplement_delivered_ml=water['water_after_session'],
             water_supplement_recommended_ml=None,
@@ -3187,7 +3186,7 @@ def _Open(self,open_last = False,input_file = ''):
                         self.stage_widget.movement_page_view.lineEdit_y1.setText(str(last_positions['y1']))
                         self.stage_widget.movement_page_view.lineEdit_y2.setText(str(last_positions['y2']))
                         self.stage_widget.movement_page_view.lineEdit_z.setText(str(last_positions['z']))
-                        self.move_aind_stage()
+                        threading.Thread(target=self.move_aind_stage).start()
                 elif 'B_NewscalePositions' in Obj.keys() and len(Obj['B_NewscalePositions']) != 0:  # cross compatibility for mice run on older version of code.
                     last_positions = Obj['B_NewscalePositions'][-1]
                     self.current_stage.move_absolute_3d(float(last_positions[0]),
@@ -3232,8 +3231,16 @@ def move_aind_stage(self):
         """
         Move all axis of stage in stage widget
         """
-        positions = self.stage_widget.movement_page_view.get_positions_from_line_edit()
-        self.stage_widget.movement_page_view.signal_position_change.emit(positions)
+        # save current positions since stage widget will reset once returnPressed in emitted
+        axes = ['x', 'y1', 'y2', 'z']
+        textboxes = [getattr(self.stage_widget.movement_page_view, f'lineEdit_{axis}') for axis in axes]
+        positions = [textbox.text() for textbox in textboxes]
+        for textbox, position in zip(textboxes, positions):
+            textbox.setText(position)
+            textbox.returnPressed.emit()
+            time.sleep(1)    # allow worker to initialize
+            while self.stage_widget.stage_model.move_thread.isRunning():
+                time.sleep(.1)
 
     def _LoadVisualization(self):
         '''To visulize the training when loading a session'''
diff --git a/tash b/tash
deleted file mode 100644
index 343951745..000000000
--- a/tash
+++ /dev/null
@@ -1,31 +0,0 @@
-diff --git a/src/foraging_gui/Foraging.py b/src/foraging_gui/Foraging.py
-index 122706fe..b9a37510 100644
---- a/src/foraging_gui/Foraging.py
-+++ b/src/foraging_gui/Foraging.py
-@@ -9,7 +9,7 @@ import math
- import logging
- from hashlib import md5
- 
--import logging_loki
-+#import logging_loki
- import socket
- import harp
- import threading
-@@ -25,7 +25,7 @@ from aind_slims_api import models
- import serial
- import numpy as np
- import pandas as pd
--from pykeepass import PyKeePass
-+#from pykeepass import PyKeePass
- from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
- from scipy.io import savemat, loadmat
- from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox, QSizePolicy
-@@ -252,6 +252,8 @@ class Window(QMainWindow):
-     def _show_disk_space(self):
-         '''Show the disk space of the current computer'''
-         total, used, free = shutil.disk_usage(self.default_saveFolder)
-+        used = 450*1024**3
-+        free = total-used
-         self.diskspace.setText(f"Used space: {used/1024**3:.2f}GB    Free space: {free/1024**3:.2f}GB")
-         self.DiskSpaceProgreeBar.setValue(int(used/total*100))
-         if free/1024**3 < 100 or used/total > 0.9:

From 36e83aea8e5a2d0dc9b4ae66fd2130433217c16c Mon Sep 17 00:00:00 2001
From: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 12 Dec 2024 05:09:59 +0000
Subject: [PATCH 04/12] ci: version bump [skip actions]

---
 src/foraging_gui/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/__init__.py b/src/foraging_gui/__init__.py
index 0a6b5300e..9b52ff8dd 100644
--- a/src/foraging_gui/__init__.py
+++ b/src/foraging_gui/__init__.py
@@ -1,3 +1,3 @@
-__version__ = "1.6.13"
+__version__ = "1.6.14"
 
 

From 8df9cab9cfe66309b93c4cb7a59398eefcedd83a Mon Sep 17 00:00:00 2001
From: XX-Yin <109394934+XX-Yin@users.noreply.github.com>
Date: Wed, 11 Dec 2024 21:11:43 -0800
Subject: [PATCH 05/12] Revert "fix stream"

---
 src/foraging_gui/GenerateMetadata.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/GenerateMetadata.py b/src/foraging_gui/GenerateMetadata.py
index d4fbfd71c..f46abd9ab 100644
--- a/src/foraging_gui/GenerateMetadata.py
+++ b/src/foraging_gui/GenerateMetadata.py
@@ -569,7 +569,7 @@ def _combine_data_streams(self):
             self.data_streams = self.ophys_streams  
         elif self.ophys_streams != []:
             # add the ophys streams to the high speed camera streams
-            self.data_streams[0].stream_modalities = self.data_streams[0].stream_modalities + self.ophys_streams[0].stream_modalities
+            self.data_streams.stream_modalities = self.data_streams[0].stream_modalities + self.ophys_streams[0].stream_modalities
             self.data_streams[0].stream_start_time=min(self.data_streams[0].stream_start_time,self.ophys_streams[0].stream_start_time)
             self.data_streams[0].stream_end_time=max(self.data_streams[0].stream_end_time,self.ophys_streams[0].stream_end_time)
             self.data_streams[0].daq_names = self.data_streams[0].daq_names + self.ophys_streams[0].daq_names

From 2b53103c84950ffef7b8a6edbc54d8c327d65f6d Mon Sep 17 00:00:00 2001
From: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 12 Dec 2024 05:12:15 +0000
Subject: [PATCH 06/12] ci: version bump [skip actions]

---
 src/foraging_gui/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/__init__.py b/src/foraging_gui/__init__.py
index 9b52ff8dd..450109dc7 100644
--- a/src/foraging_gui/__init__.py
+++ b/src/foraging_gui/__init__.py
@@ -1,3 +1,3 @@
-__version__ = "1.6.14"
+__version__ = "1.6.15"
 
 

From 1bb13751f4c3975ec5c36561f433f5cd3498793e Mon Sep 17 00:00:00 2001
From: Xinxin Yin <yinxx15@tsinghua.org.cn>
Date: Wed, 11 Dec 2024 23:41:55 -0800
Subject: [PATCH 07/12] change to warning

---
 src/foraging_gui/Foraging.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/Foraging.py b/src/foraging_gui/Foraging.py
index 5d33b0721..a0bf230b0 100644
--- a/src/foraging_gui/Foraging.py
+++ b/src/foraging_gui/Foraging.py
@@ -2257,7 +2257,7 @@ def _ShowRewardPairs(self):
                         self.ShowRewardPairs_2.setText(self.ShowRewardPairs.text())
         except Exception as e:
             # Catch the exception and log error information
-            logging.error(traceback.format_exc())
+            logging.warning(traceback.format_exc())
 
     def closeEvent(self, event):
         # stop the current session first

From fff439518639ae1a48ff4e7571a18e8a1ce479aa Mon Sep 17 00:00:00 2001
From: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 12 Dec 2024 07:45:39 +0000
Subject: [PATCH 08/12] ci: version bump [skip actions]

---
 src/foraging_gui/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/__init__.py b/src/foraging_gui/__init__.py
index 450109dc7..22b8bd4f6 100644
--- a/src/foraging_gui/__init__.py
+++ b/src/foraging_gui/__init__.py
@@ -1,3 +1,3 @@
-__version__ = "1.6.15"
+__version__ = "1.6.16"
 
 

From 27c41077600e204f02c349eafef0834f49218938 Mon Sep 17 00:00:00 2001
From: XX-Yin <109394934+XX-Yin@users.noreply.github.com>
Date: Wed, 11 Dec 2024 23:56:32 -0800
Subject: [PATCH 09/12] fixed a typo

---
 src/foraging_gui/GenerateMetadata.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/GenerateMetadata.py b/src/foraging_gui/GenerateMetadata.py
index f46abd9ab..d4fbfd71c 100644
--- a/src/foraging_gui/GenerateMetadata.py
+++ b/src/foraging_gui/GenerateMetadata.py
@@ -569,7 +569,7 @@ def _combine_data_streams(self):
             self.data_streams = self.ophys_streams  
         elif self.ophys_streams != []:
             # add the ophys streams to the high speed camera streams
-            self.data_streams.stream_modalities = self.data_streams[0].stream_modalities + self.ophys_streams[0].stream_modalities
+            self.data_streams[0].stream_modalities = self.data_streams[0].stream_modalities + self.ophys_streams[0].stream_modalities
             self.data_streams[0].stream_start_time=min(self.data_streams[0].stream_start_time,self.ophys_streams[0].stream_start_time)
             self.data_streams[0].stream_end_time=max(self.data_streams[0].stream_end_time,self.ophys_streams[0].stream_end_time)
             self.data_streams[0].daq_names = self.data_streams[0].daq_names + self.ophys_streams[0].daq_names

From 4ca4f2869212baeda16d07ba736036e1130453ff Mon Sep 17 00:00:00 2001
From: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 12 Dec 2024 07:56:56 +0000
Subject: [PATCH 10/12] ci: version bump [skip actions]

---
 src/foraging_gui/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/__init__.py b/src/foraging_gui/__init__.py
index 22b8bd4f6..c2d56b6b7 100644
--- a/src/foraging_gui/__init__.py
+++ b/src/foraging_gui/__init__.py
@@ -1,3 +1,3 @@
-__version__ = "1.6.16"
+__version__ = "1.6.17"
 
 

From 4715b61a09b72684f25f5dd3c5d8540ed1694cec Mon Sep 17 00:00:00 2001
From: XX-Yin <109394934+XX-Yin@users.noreply.github.com>
Date: Wed, 11 Dec 2024 23:58:55 -0800
Subject: [PATCH 11/12] Revert "Revert "Fix 1155 waterlog post session weight""

---
 src/foraging_gui/Foraging.py | 19 ++++++-------------
 tash                         | 31 +++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 13 deletions(-)
 create mode 100644 tash

diff --git a/src/foraging_gui/Foraging.py b/src/foraging_gui/Foraging.py
index a0bf230b0..894857408 100644
--- a/src/foraging_gui/Foraging.py
+++ b/src/foraging_gui/Foraging.py
@@ -1361,14 +1361,15 @@ def _AddWaterLogResult(self, session: Session):
 
         # extract software information
         logging.info('Extracting software information from first data stream')
-        software = session.data_streams[0].software[0]
+        software = session.stimulus_epochs[0].software[0]
 
         # create model
         logging.info('Creating SlimsWaterlogResult based on session information.')
         model = models.SlimsWaterlogResult(
             mouse_pk=mouse.pk,
             date=session.session_start_time,
-            weight_g=session.animal_weight_prior,
+            weight_g=session.animal_weight_post,
+            operator=self.behavior_session_model.experimenter[0],
             water_earned_ml=water['water_in_session_foraging'],
             water_supplement_delivered_ml=water['water_after_session'],
             water_supplement_recommended_ml=None,
@@ -3186,7 +3187,7 @@ def _Open(self,open_last = False,input_file = ''):
                         self.stage_widget.movement_page_view.lineEdit_y1.setText(str(last_positions['y1']))
                         self.stage_widget.movement_page_view.lineEdit_y2.setText(str(last_positions['y2']))
                         self.stage_widget.movement_page_view.lineEdit_z.setText(str(last_positions['z']))
-                        threading.Thread(target=self.move_aind_stage).start()
+                        self.move_aind_stage()
                 elif 'B_NewscalePositions' in Obj.keys() and len(Obj['B_NewscalePositions']) != 0:  # cross compatibility for mice run on older version of code.
                     last_positions = Obj['B_NewscalePositions'][-1]
                     self.current_stage.move_absolute_3d(float(last_positions[0]),
@@ -3231,16 +3232,8 @@ def move_aind_stage(self):
         """
         Move all axis of stage in stage widget
         """
-        # save current positions since stage widget will reset once returnPressed in emitted
-        axes = ['x', 'y1', 'y2', 'z']
-        textboxes = [getattr(self.stage_widget.movement_page_view, f'lineEdit_{axis}') for axis in axes]
-        positions = [textbox.text() for textbox in textboxes]
-        for textbox, position in zip(textboxes, positions):
-            textbox.setText(position)
-            textbox.returnPressed.emit()
-            time.sleep(1)    # allow worker to initialize
-            while self.stage_widget.stage_model.move_thread.isRunning():
-                time.sleep(.1)
+        positions = self.stage_widget.movement_page_view.get_positions_from_line_edit()
+        self.stage_widget.movement_page_view.signal_position_change.emit(positions)
 
     def _LoadVisualization(self):
         '''To visulize the training when loading a session'''
diff --git a/tash b/tash
new file mode 100644
index 000000000..343951745
--- /dev/null
+++ b/tash
@@ -0,0 +1,31 @@
+diff --git a/src/foraging_gui/Foraging.py b/src/foraging_gui/Foraging.py
+index 122706fe..b9a37510 100644
+--- a/src/foraging_gui/Foraging.py
++++ b/src/foraging_gui/Foraging.py
+@@ -9,7 +9,7 @@ import math
+ import logging
+ from hashlib import md5
+ 
+-import logging_loki
++#import logging_loki
+ import socket
+ import harp
+ import threading
+@@ -25,7 +25,7 @@ from aind_slims_api import models
+ import serial
+ import numpy as np
+ import pandas as pd
+-from pykeepass import PyKeePass
++#from pykeepass import PyKeePass
+ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
+ from scipy.io import savemat, loadmat
+ from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox, QSizePolicy
+@@ -252,6 +252,8 @@ class Window(QMainWindow):
+     def _show_disk_space(self):
+         '''Show the disk space of the current computer'''
+         total, used, free = shutil.disk_usage(self.default_saveFolder)
++        used = 450*1024**3
++        free = total-used
+         self.diskspace.setText(f"Used space: {used/1024**3:.2f}GB    Free space: {free/1024**3:.2f}GB")
+         self.DiskSpaceProgreeBar.setValue(int(used/total*100))
+         if free/1024**3 < 100 or used/total > 0.9:

From f6de3470a14a3ed256e6e0a3d034aeda9c47f66f Mon Sep 17 00:00:00 2001
From: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 12 Dec 2024 07:59:25 +0000
Subject: [PATCH 12/12] ci: version bump [skip actions]

---
 src/foraging_gui/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/foraging_gui/__init__.py b/src/foraging_gui/__init__.py
index c2d56b6b7..3e4631852 100644
--- a/src/foraging_gui/__init__.py
+++ b/src/foraging_gui/__init__.py
@@ -1,3 +1,3 @@
-__version__ = "1.6.17"
+__version__ = "1.6.18"