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

added the possibility of launching a stimulation without duration #10

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 15 additions & 5 deletions pyScienceMode/rehastimP24_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,12 @@ def start_stimulation(self, upd_list_channels: list, stimulation_duration: int |
safety : bool
Set to True if you want to check the pulse symmetry. False otherwise.
"""

"""
if not stimulation_duration:
raise ValueError("Please indicate the stimulation duration")
elif not isinstance(stimulation_duration, int | float):
raise TypeError("Please provide a int or float type for stimulation duration")
"""

if upd_list_channels is not None:
new_electrode_number = calc_electrode_number(upd_list_channels)
Expand All @@ -463,7 +464,7 @@ def start_stimulation(self, upd_list_channels: list, stimulation_duration: int |

self.list_channels = upd_list_channels
self._safety = safety
self._current_stim_duration = stimulation_duration
#self._current_stim_duration = stimulation_duration
self.ml_update.packet_number = self.get_next_packet_number()

for channel in upd_list_channels:
Expand All @@ -481,13 +482,22 @@ def start_stimulation(self, upd_list_channels: list, stimulation_duration: int |
"Or specify specific stimulation points.".format(channel._no_channel)
)
self._send_stimulation_update()

start_time = time.time()
while (time.time() - start_time) < stimulation_duration:
if not stimulation_duration:
self._get_current_data()
self._get_last_ack()
self.check_stimulation_errors()
time.sleep(0.005)
else:
if not isinstance(stimulation_duration, int | float):
raise TypeError("Please provide a int or float type for stimulation duration")
else:
self._current_stim_duration = stimulation_duration
start_time = time.time()
while (time.time() - start_time) < stimulation_duration:
self._get_current_data()
self._get_last_ack()
self.check_stimulation_errors()
time.sleep(0.005)

self.pause_stimulation()
self.stimulation_started = True
Expand Down