Skip to content

Commit

Permalink
Merge branch 'hotfix/exp_description_gui'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	iblrig/__init__.py
#	release_notes.md
  • Loading branch information
Michele Fabbri committed Oct 13, 2022
2 parents fc0de01 + 940bd33 commit 876aa26
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 15 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ conda activate iblrig
conda install git --yes
git clone https://github.com/int-brain-lab/iblrig C:\iblrig
cd C:\iblrig
git checkout tags/7.0.2
git checkout tags/7.0.3
pip install --editable .
pip install pybpod-gui-api==1.8.3b1 pybpod-gui-plugin-alyx==1.1.3b1
pip uninstall ibllib --yes
Expand Down Expand Up @@ -55,19 +55,17 @@ of use.
Copy-Item "C:\iblrig\pybpod-Anaconda_Powershell_Prompt.lnk" -Destination "$Env:HOMEPATH\Desktop"
```

#### Setup instructions for launching the 'Experiment Description GUI' prior to task launch

The 'Experiment Description GUI' is currently being housed on the iblscripts repo. This GUI is intended to simplify the
#### Setup instructions for launching the 'Experiment Description GUI' prior to task launch (DEVELOP)
The 'Experiment Description GUI' is currently being developed in the iblscripts repo. This GUI is intended to simplify the
categorization of an experiment and cleanly define what projects and procedures an experiment is for. In order to add the GUI to
a custom task:

* clone the iblscripts repo: `git clone https://github.com/int-brain-lab/iblscripts`
* launch pybpod
* select the custom task protocol to modify
* click on the plus button to add a "pre command"
* use the drop-down box to select `Execute an external command`
* depending on where the iblscripts repo was clones, enter into the text box something like the following:
* `python C:\iblscripts\deploy\project_procedure_gui\experiment_form.py`
the tasks listed in the `add_ex_desc_gui_to_tasks` script, run the following commands from the **Anaconda Powershell Prompt**:
```powershell
conda activate iblrig
git clone -b develop https://github.com/int-brain-lab/iblscripts C:\iblscripts
pip install -r C:\iblscripts\deploy\project_procedure_gui\pp_requirements.txt
python C:\iblrig\scripts\add_ex_desc_gui_to_tasks.py
```
- Note: Any custom tasks will need to have this pre-task command manually configured

---
## How to develop on this repository
Expand Down
2 changes: 1 addition & 1 deletion iblrig/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "7.0.2"
__version__ = "7.0.3"
import logging

import colorlog
Expand Down
4 changes: 4 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# **Release notes**

## **Release Notes 7.0.3**

- added instructions and deployment script for experiment description gui

## **Release Notes 7.0.2**

- removal of the move_passive.py script call from the passiveChoiceWorldIndependent json task configuration file
Expand Down
66 changes: 66 additions & 0 deletions scripts/add_ex_desc_gui_to_tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""
Adds a call to the experiment description GUI to select tasks
"""
import os
from pathlib import Path
from sys import platform
import json

# Add any custom tasks to this list
TASK_LIST = ['_iblrig_tasks_biasedChoiceWorld',
'_iblrig_tasks_trainingChoiceWorld',
'_iblrig_tasks_passiveChoiceWorld',
'_iblrig_tasks_ephysChoiceWorld',
'_iblrig_tasks_passiveChoiceWorldIndependent',
'_iblrig_tasks_habituationChoiceWorld']

TASKS_PATH = "" # Set path for platform
if platform == "win32":
TASKS_PATH = Path("C:\\iblrig_params\\IBL\\tasks")
else:
TASKS_PATH = Path.home() / "Documents" / "iblrig_params" / "IBL" / "tasks"

# Command to prepend to each task in the TASK_LIST
PYTHON_CMD = "python C:\\iblscripts\\deploy\\project_procedure_gui\\experiment_form.py"


if __name__ == "__main__":
dirs = [Path(f) for f in os.scandir(TASKS_PATH) if f.is_dir()] if Path(TASKS_PATH).exists() else None
for dir in dirs:
if dir.parts[-1] in TASK_LIST:
# set path to json file
json_file_path = dir / (dir.name + ".json")

# open file and create dict from json
f = open(json_file_path)
data = json.load(f)
f.close()

# check if there are no commands in the json file; add PYTHON_CMD
json_write_needed = False
if not data["commands"]:
data["commands"] = [{
"cmd": PYTHON_CMD,
"type": "create_execcmd",
"when": 0
}]
json_write_needed = True
else:
# check command list PYTHON_CMD, insert if missing
insert_needed = True
for cmds in data["commands"]:
if PYTHON_CMD in cmds["cmd"]:
insert_needed = False
break
if insert_needed:
data["commands"].insert(0, {
"cmd": PYTHON_CMD,
"type": "create_execcmd",
"when": 0})
json_write_needed = True

# write formatted data back to json file
if json_write_needed:
formatted_data = json.dumps(data, indent=4)
with open(json_file_path, "w") as f:
f.write(formatted_data)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
==========================
Unsupported Python version
==========================
Python {}.{} was found, but this version of iblrig requires Python {}.{} or greater.
Python {}.{} was found, but this version of iblrig requires Python {}.{}.
"""
if CURRENT_PYTHON != REQUIRED_PYTHON:
sys.stderr.write(VER_ERR_MSG.format(*REQUIRED_PYTHON + CURRENT_PYTHON))
Expand Down

0 comments on commit 876aa26

Please sign in to comment.