Skip to content

Commit

Permalink
Merge branch 'iblrigv8' of github.com:int-brain-lab/iblrig into iblrigv8
Browse files Browse the repository at this point in the history
  • Loading branch information
oliche committed Jul 5, 2023
2 parents d4ff619 + 1883d12 commit 9a5f084
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
7 changes: 7 additions & 0 deletions docs/source/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ To run a task using command line, open a terminal and type the task path and the
cd C:\iblrigv8\
python .\iblrig_tasks\_iblrig_tasks_TrainingChoiceWorld\task.py --subject algernon

## Flush valve

To flush valve 1 of the Bpod, enter

flush

Press ENTER to close the valve.

## Copy commands

Expand Down
2 changes: 1 addition & 1 deletion iblrig/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "8.4.2"
__version__ = "8.5.0"
17 changes: 16 additions & 1 deletion iblrig/commands.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import argparse
from pathlib import Path
import yaml

from deploy.transfer_data import transfer_sessions
from iblutil.util import setup_logger

import iblrig
from iblrig.hardware import Bpod
from iblrig.path_helper import load_settings_yaml, get_iblrig_path
from iblrig.online_plots import OnlinePlots

Expand All @@ -28,6 +30,7 @@ def transfer_data():
>>> transfer_data -l /full/path/to/iblrig_data/Subjects -r /full/path/to/remote/folder/Subjects
:return:
"""
from deploy.transfer_data import transfer_sessions
help_str = ">>> transfer_data -l /full/path/to/iblrig_data/Subjects -r /full/path/to/remote/folder/Subjects"

iblrig_settings = load_settings_yaml()
Expand Down Expand Up @@ -73,3 +76,15 @@ def transfer_data():

# launch transfer after all checks
transfer_sessions(local, remote)


def flush():
"""
Flushes the valve until the user hits enter
:return:
"""
file_settings = Path(iblrig.__file__).parents[1].joinpath('settings', 'hardware_settings.yaml')
hardware_settings = yaml.safe_load(file_settings.read_text())
bpod = Bpod(hardware_settings['device_bpod']['COM_BPOD'])
bpod.flush()
bpod.close()
23 changes: 19 additions & 4 deletions iblrig/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""
from pathlib import Path
import json
import os
import logging
import time

import serial
import numpy as np
Expand Down Expand Up @@ -125,9 +125,24 @@ def get_ambient_sensor_reading(self, save_to=None):

return {k: v.tolist()[0] for k, v in Measures.items()}

def bpod_lights(self, command: int):
fpath = Path(self.IBLRIG_FOLDER) / "scripts" / "bpod_lights.py"
os.system(f"python {fpath} {command}")
def flush(self):
"""
Flushes valve 1
:return:
"""
self.toggle_valve()

def toggle_valve(self, duration=None):
"""
Flushes valve 1 for duration (seconds)
:return:
"""
self.manual_override(self.ChannelTypes.OUTPUT, self.ChannelNames.VALVE, 1, 1)
if duration is None:
input("Press ENTER when done.")
else:
time.sleep(duration)
self.manual_override(self.ChannelTypes.OUTPUT, self.ChannelNames.VALVE, 1, 0)


class MyRotaryEncoder(object):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_version(rel_path):
entry_points={
'console_scripts': [
'viewsession=iblrig.commands:viewsession',
'transfer_data=iblrig.commands:transfer_data'],
'transfer_data=iblrig.commands:transfer_data',
'flush=iblrig.commands:flush'],
},
)

0 comments on commit 9a5f084

Please sign in to comment.