Skip to content

Commit 583fc7e

Browse files
committed
new branch features
1 parent 92fc634 commit 583fc7e

28 files changed

Lines changed: 1140 additions & 613 deletions

village/calibration/water_calibration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ def create_trial(self) -> None:
2424
Adds states for each valve to be calibrated and a final wait state.
2525
"""
2626
for i in range(len(self.states) - 1):
27-
self.bpod.add_state(
27+
self.controller.add_state(
2828
state_name=self.states[i],
2929
state_timer=self.times[i],
3030
state_change_conditions={Event.Tup: self.wait_states[i]},
3131
output_actions=self.outputs[i],
3232
)
33-
self.bpod.add_state(
33+
self.controller.add_state(
3434
state_name=self.wait_states[i],
3535
state_timer=0.1,
3636
state_change_conditions={Event.Tup: self.states[i + 1]},

village/classes/collection.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
import numpy as np
88
import pandas as pd
99

10-
from village.classes.abstract_classes import EventBase
1110
from village.custom_classes.training_protocol_base import TrainingProtocolBase
1211
from village.scripts.log import log
1312
from village.scripts.time_utils import time_utils
1413
from village.scripts.utils import get_x_value_interp
1514
from village.settings import settings
1615

1716

18-
class Collection(EventBase):
17+
class Collection:
1918
"""Manages a collection of data entries stored in a CSV file and a pandas DataFrame.
2019
2120
Attributes:
@@ -324,7 +323,8 @@ def get_sound_gain(self, speaker: int, dB: float, sound_name: str) -> float:
324323
def save_from_df(
325324
self, training: TrainingProtocolBase = TrainingProtocolBase()
326325
) -> None:
327-
"""Saves values from the current DataFrame to the CSV file, processing formatting.
326+
"""Saves values from the current DataFrame to the CSV file,
327+
processing formatting.
328328
329329
Args:
330330
training (TrainingProtocolBase): Protocol for formatting specific fields.
@@ -340,7 +340,8 @@ def df_from_df(
340340
341341
Args:
342342
df (pd.DataFrame): The input DataFrame.
343-
training (TrainingProtocolBase): The training protocol for custom formatting.
343+
training (TrainingProtocolBase): The training protocol for
344+
custom formatting.
344345
345346
Returns:
346347
pd.DataFrame: The processed DataFrame.

village/classes/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Color(SuperEnum):
7070
WHITE = "WHITE"
7171

7272

73-
class Controller(SuperEnum):
73+
class ControllerEnum(SuperEnum):
7474
BPOD = "BPOD"
7575
ARDUINO = "ARDUINO"
7676
RASPBERRY = "RASPBERRY"
Lines changed: 39 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,34 @@
44
from PyQt5.QtWidgets import QWidget
55

66
from village.classes.enums import Active
7-
from village.pybpodapi.session import Session
87
from village.scripts.time_utils import time_utils
98
from village.settings import settings
109

1110

12-
class PyBpodBase:
13-
"""Base class for Bpod interface.
11+
class NullBpod:
12+
def close(self) -> None:
13+
pass
1414

15-
Attributes:
16-
error (str): Error message.
17-
session (Session | Any): Bpod session object.
18-
connected (bool): Connection status.
19-
"""
15+
def send_state_machine(self, sma: Any) -> None:
16+
pass
2017

21-
error: str = "Error connecting to the bpod "
22-
session: Session | Any = None
23-
connected: bool = False
18+
def run_state_machine(self, sma: Any) -> None:
19+
pass
2420

25-
def connect(self, functions: list[Callable]) -> None:
26-
"""Connects to the Bpod device.
21+
def register_value(self, name: str, value: Any) -> None:
22+
pass
2723

28-
Args:
29-
functions (list[Callable]): List of callback functions for softcodes.
30-
"""
31-
return
24+
def manual_override(
25+
self,
26+
channel_type: Any,
27+
channel_name: Any,
28+
channel_number: Any,
29+
value: Any,
30+
) -> None:
31+
pass
3232

33+
34+
class NullStateMachine:
3335
def add_state(
3436
self,
3537
state_name: Any,
@@ -45,7 +47,7 @@ def add_state(
4547
state_change_conditions (Any): Conditions to transition to other states.
4648
output_actions (Any): Actions to perform in this state.
4749
"""
48-
return
50+
pass
4951

5052
def set_global_timer(
5153
self,
@@ -74,7 +76,7 @@ def set_global_timer(
7476
send_events (int): Whether to send events.
7577
oneset_triggers (Any | None): Triggers to set.
7678
"""
77-
return
79+
pass
7880

7981
def set_condition(
8082
self, condition_number: Any, condition_channel: Any, channel_value: Any
@@ -86,104 +88,28 @@ def set_condition(
8688
condition_channel (Any): The channel to check.
8789
channel_value (Any): The value to match.
8890
"""
89-
return
91+
pass
9092

9193
def set_global_counter(
9294
self, counter_number: Any, target_event: Any, threshold: Any
9395
) -> None:
94-
"""Configures a global counter.
95-
96-
Args:
97-
counter_number (Any): The counter ID.
98-
target_event (Any): The event to count.
99-
threshold (Any): The count threshold.
100-
"""
101-
return
102-
103-
def create_state_machine(self) -> None:
104-
"""Creates and initializes a new state machine."""
105-
return
106-
107-
def send_and_run_state_machine(self) -> None:
108-
"""Sends the current state machine to the Bpod and starts it."""
109-
return
110-
111-
def close(self) -> None:
112-
"""Closes the connection to the Bpod."""
113-
return
114-
115-
def stop(self) -> None:
116-
"""Stops the current trial or operation."""
117-
return
118-
119-
def manual_override_input(self, message: str) -> None:
120-
"""Simulates an input event manually.
121-
122-
Args:
123-
message (str): The input message/event string.
124-
"""
125-
return
126-
127-
def manual_override_output(self, message: str | tuple) -> None:
128-
"""Manually triggers an output.
129-
130-
Args:
131-
message (str | tuple): The output command.
132-
"""
133-
return
96+
pass
13497

135-
def register_value(self, name: str, value: Any) -> None:
136-
"""Registers a value to be tracked or logged.
137-
138-
Args:
139-
name (str): Name of the value.
140-
value (Any): The value itself.
141-
"""
142-
return
143-
144-
def receive_softcode(self, idx: int) -> None:
145-
"""Handles received softcodes.
146-
147-
Args:
148-
idx (int): The softcode index.
149-
"""
150-
return
15198

152-
def led(self, i: int, close: bool) -> None:
153-
"""Controls an LED.
99+
class NullSoftCodeToBpod:
100+
def send(self, idx: int) -> None:
101+
pass
154102

155-
Args:
156-
i (int): The LED index.
157-
close (bool): Whether to turn it off (or close the circuit).
158-
"""
159-
return
103+
def kill(self) -> None:
104+
pass
160105

161-
def water(self, i: int, close: bool) -> None:
162-
"""Controls a water valve.
163106

164-
Args:
165-
i (int): The valve index.
166-
close (bool): Whether to close the valve.
167-
"""
168-
return
107+
class NullSession:
108+
def current_trial(self) -> None:
109+
pass
169110

170-
def poke(self, i: int, close: bool) -> None:
171-
"""Simulates a poke event.
172-
173-
Args:
174-
i (int): The poke index.
175-
close (bool): State of the poke.
176-
"""
177-
return
178-
179-
180-
class TelegramBotBase:
181-
"""Base class for Telegram Bot interface.
182-
183-
Attributes:
184-
error (str): Error message.
185-
"""
186111

112+
class NullTelegramBot:
187113
error: str = "Error connecting to the telegram_bot "
188114

189115
def alarm(self, message: str) -> None:
@@ -195,13 +121,7 @@ def alarm(self, message: str) -> None:
195121
return
196122

197123

198-
class ScaleBase:
199-
"""Base class for Scale interface.
200-
201-
Attributes:
202-
error (str): Error message.
203-
"""
204-
124+
class NullScale:
205125
error: str = "Error connecting to the scale "
206126

207127
def tare(self) -> None:
@@ -225,13 +145,7 @@ def get_weight(self) -> float:
225145
return 0.0
226146

227147

228-
class TempSensorBase:
229-
"""Base class for Temperature Sensor interface.
230-
231-
Attributes:
232-
error (str): Error message.
233-
"""
234-
148+
class NullTempSensor:
235149
error: str = "Error connecting to the temp_sensor "
236150

237151
def start(self) -> None:
@@ -247,15 +161,7 @@ def get_temperature(self) -> tuple[float, float, str]:
247161
return 0.0, 0.0, ""
248162

249163

250-
class MotorBase:
251-
"""Base class for Motor interface.
252-
253-
Attributes:
254-
error (str): Error message.
255-
open_angle (int): Angle for open position.
256-
close_angle (int): Angle for close position.
257-
"""
258-
164+
class NullMotor:
259165
error: str = "Error connecting to the motor "
260166
open_angle: int = 0
261167
close_angle: int = 0
@@ -269,14 +175,7 @@ def close(self) -> None:
269175
return
270176

271177

272-
class SoundDeviceBase:
273-
"""Base class for Sound Device interface.
274-
275-
Attributes:
276-
samplerate (int): Audio sample rate.
277-
error (str): Error message.
278-
"""
279-
178+
class NullSoundDevice:
280179
samplerate: int = 44100
281180
error: str = (
282181
""
@@ -310,9 +209,7 @@ def load_wav(self, file: str) -> None:
310209
return
311210

312211

313-
class EventBase:
314-
"""Base class for event logging interfaces."""
315-
212+
class NullCollection:
316213
def log(self, date: str, type: str, subject: str, description: str) -> None:
317214
"""Logs a generic event.
318215
@@ -335,31 +232,7 @@ def log_temp(self, date: str, temperature: float, humidity: float) -> None:
335232
return
336233

337234

338-
class CameraBase:
339-
"""Base class for Camera interface.
340-
341-
Attributes:
342-
area1 (list[int]): Coordinates for area 1.
343-
area2 (list[int]): Coordinates for area 2.
344-
area3 (list[int]): Coordinates for area 3.
345-
area4 (list[int]): Coordinates for area 4.
346-
areas (list[list[int]]): List of all area coordinates.
347-
area1_is_triggered (bool): Trigger status for area 1.
348-
area2_is_triggered (bool): Trigger status for area 2.
349-
area3_is_triggered (bool): Trigger status for area 3.
350-
area4_is_triggered (bool): Trigger status for area 4.
351-
change (bool): Flag for property changes.
352-
annotation (str): Current annotation text.
353-
path_picture (str): Path to save pictures.
354-
error (str): Error message.
355-
trial (int): Current trial number.
356-
is_recording (bool): Recording status.
357-
show_time_info (bool): Time info display flag.
358-
x_position (int): X coordinate of tracked object.
359-
y_position (int): Y coordinate of tracked object.
360-
chrono (time_utils.Chrono): Timer utility.
361-
"""
362-
235+
class NullCamera:
363236
area1: list[int] = []
364237
area2: list[int] = []
365238
area3: list[int] = []
@@ -478,13 +351,7 @@ def take_picture(self) -> None:
478351
return
479352

480353

481-
class BehaviorWindowBase(QWidget):
482-
"""Base class for Behavior Window GUI.
483-
484-
Attributes:
485-
background_color: The background color.
486-
"""
487-
354+
class NullBehaviorWindow(QWidget):
488355
background_color = None
489356

490357
def start_drawing(self) -> None:

0 commit comments

Comments
 (0)