Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jackd_triggers' into jackd_triggers
Browse files Browse the repository at this point in the history
# Conflicts:
#	autopilot/stim/sound/jackclient.py
#	autopilot/stim/sound/sounds.py
#	autopilot/tasks/task.py
  • Loading branch information
sneakers-the-rat committed Nov 2, 2021
2 parents 869e448 + 0ed9fee commit 0952d6b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 3 additions & 1 deletion autopilot/stim/sound/jackclient.py
Expand Up @@ -162,7 +162,7 @@ def __init__(self, name='jack_client', debug_timing=False):

self.debug_timing = debug_timing
self.querythread = None


def boot_server(self):
"""
Expand Down Expand Up @@ -485,6 +485,8 @@ def _pad_continuous(self, data:np.ndarray) -> np.ndarray:
pad_with.extend([(0, 0) for i in range(len(data.ndim - 1))])
data = np.pad(data, pad_with, 'constant')

return data

def _wait_for_end(self, end_time:int):
"""
Thread that waits for a time (returned by :attr:`jack.Client.frame_time`) passed as ``end_time``
Expand Down
16 changes: 5 additions & 11 deletions autopilot/stim/sound/sounds.py
Expand Up @@ -281,19 +281,13 @@ def chunk(self, pad=True):
else:
# Flag as not padded
self.padded = False


## Reshape into chunks, each of length `self.blocksize`
if sound.ndim == 1:
sound_list = [sound[i:i+self.blocksize] for i in range(0, sound.shape[0], self.blocksize)]

elif sound.ndim == 2:
sound_list = [sound[i:i + self.blocksize,:] for i in range(0, sound.shape[0], self.blocksize)]

else:
raise NotImplementedError(f"sounds with more than 2 dimensions arent supported, got ndim {sound.ndim}")
## Reshape into chunks, each of length `self.blocksize`
# the list comprehension version handles unpadded sounds (with
# the last array being smaller than blocksize) where the
# reshape argument is faster but chokes :(
self.chunks = [sound[i:i+self.blocksize] for i in range(0, sound.shape[0], self.blocksize)]

self.chunks = sound_list

def set_trigger(self, trig_fn):
"""
Expand Down
4 changes: 3 additions & 1 deletion autopilot/tasks/nafc.py
Expand Up @@ -14,6 +14,8 @@
# TODO: Move this to __init__
TASK = 'Nafc'



class Nafc(Task):
"""
A Two-alternative forced choice task.
Expand Down Expand Up @@ -452,5 +454,5 @@ def flash_leds(self):
flash lights for punish_dir
"""
for k, v in self.hardware['LEDS'].items():
if isinstance(v, autopilot.get_hardware('LED_RGB')):
if v.__class__.__name__ == "LED_RGB":
v.flash(self.punish_dur)

0 comments on commit 0952d6b

Please sign in to comment.