Skip to content

Commit a4c94ce

Browse files
authored
Merge pull request #69 from jaib1/dev
Setting dev up-to-date with master, plus incorporating additional changes made directly to dev (that were not made to master)
2 parents b9e0b93 + 109fd17 commit a4c94ce

File tree

5 files changed

+123
-71
lines changed

5 files changed

+123
-71
lines changed

+eui/AlyxPanel.m

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,16 @@ function dispWaterReq(obj, src, ~)
366366
colour = 'black'; % Mouse above 80% or no weight measured today
367367
weight_pct = '> 80%';
368368
end
369+
% Round up water remaining to the near 0.01
370+
remainder = obj.round(s(idx).water_requirement_remaining, 'up');
369371
% Set text
370372
set(obj.WaterRequiredText, 'ForegroundColor', colour, 'String', ...
371-
sprintf('Subject %s requires %.2f of %.2f today\n\t Weight today: %.2f (%s) Water today: %.2f', ...
372-
obj.Subject, s(idx).water_requirement_remaining, s(idx).water_requirement_total, weight, weight_pct, sum([water gel])));
373+
sprintf(['Subject %s requires %.2f of %.2f today\n\t '...
374+
'Weight today: %.2f (%s) Water today: %.2f'], obj.Subject, ...
375+
remainder, obj.round(s(idx).water_requirement_total, 'up'), weight, ...
376+
weight_pct, obj.round(sum([water gel]), 'down')));
373377
% Set WaterRemaining attribute for changeWaterText callback
374-
obj.WaterRemaining = s(idx).water_requirement_remaining;
378+
obj.WaterRemaining = remainder;
375379
end
376380
catch me
377381
d = me.message; %FIXME: JSON no longer returned
@@ -561,11 +565,11 @@ function viewSubjectHistory(obj, ax)
561565
ylabel(ax, 'weight as pct (%)');
562566

563567
axWater = axes('Parent',plotBox);
564-
plot(axWater, dates, [records.water_given]+[records.hydrogel_given], '.-');
568+
plot(axWater, dates, obj.round([records.water_given]+[records.hydrogel_given], 'up'), '.-');
565569
hold(axWater, 'on');
566-
plot(axWater, dates, [records.hydrogel_given], '.-');
567-
plot(axWater, dates, [records.water_given], '.-');
568-
plot(axWater, dates, [records.water_expected], 'r', 'LineWidth', 2.0);
570+
plot(axWater, dates, obj.round([records.hydrogel_given], 'down'), '.-');
571+
plot(axWater, dates, obj.round([records.water_given], 'down'), '.-');
572+
plot(axWater, dates, obj.round([records.water_expected], 'up'), 'r', 'LineWidth', 2.0);
569573
box(axWater, 'off');
570574
xlim(axWater, [min(dates) max(dates)]);
571575
set(axWater, 'XTickLabel', arrayfun(@(x)datestr(x, 'dd-mmm'), get(axWater, 'XTick'), 'uni', false))
@@ -619,11 +623,11 @@ function viewAllSubjects(obj)
619623
colorgen = @(colorNum,text) ['<html><body bgcolor=#',htmlColor(colorNum),'>',text,'</body></html>'];
620624

621625
wrdat = cellfun(@(x)colorgen(1-double(x>0)*[0 0.3 0.3],...
622-
sprintf('%.2f',x)), {wr.water_requirement_remaining}, 'uni', false);
626+
sprintf('%.2f',obj.round(x, 'up'))), {wr.water_requirement_remaining}, 'uni', false);
623627

624628
set(wrTable, 'ColumnName', {'Name', 'Water Required', 'Remaining Requirement'}, ...
625629
'Data', horzcat({wr.nickname}', ...
626-
cellfun(@(x)sprintf('%.2f',x),{wr.water_requirement_total}', 'uni', false), ...
630+
cellfun(@(x)sprintf('%.2f',obj.round(x, 'up')),{wr.water_requirement_total}', 'uni', false), ...
627631
wrdat'), ...
628632
'ColumnEditable', false(1,3));
629633
end
@@ -670,4 +674,18 @@ function log(obj, varargin)
670674
end
671675
end
672676

677+
methods (Static)
678+
function A = round(a, direction, sigFigures)
679+
if nargin < 3; sigFigures = 2; end
680+
c = 1*10^sigFigures;
681+
switch direction
682+
case 'up'
683+
A = ceil(a*c)/c;
684+
case 'down'
685+
A = ceil(a*c)/c;
686+
otherwise
687+
A = round(a*c)/c;
688+
end
689+
end
690+
end
673691
end

.gitmodules

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
[submodule "npy-matlab"]
1010
path = npy-matlab
1111
url = https://github.com/kwikteam/npy-matlab
12+
branch = master
1213
[submodule "wheelAnalysis"]
1314
path = wheelAnalysis
14-
url = https://github.com/cortex-lab/wheelAnalysis.git
15+
url = https://github.com/cortex-lab/wheelAnalysis
16+
branch = master

npy-matlab

readme.md

Lines changed: 91 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,142 @@
11
----------
22
# Rigbox
33

4-
Rigbox is a (mostly) object-oriented MATLAB software package for designing and controlling behavioural experiments. Principally, the steering wheel setup we developed to probe mouse behaviour. It requires two computers, one for stimulus presentation ('the stimulus server') and another for controlling and monitoring the experiment ('mc').
4+
Rigbox is a (mostly) object-oriented MATLAB software package for designing and controlling behavioural experiments (principally, the [steering wheel setup](https://www.ucl.ac.uk/cortexlab/tools/wheel) which [we](https://www.ucl.ac.uk/cortexlab) developed to probe mouse behaviour. Rigbox requires two machines, one for stimulus presentation ('the stimulus server') and another for controlling and monitoring the experiment ('mc').
55

66
## Getting Started
77

8-
The following is a brief description of how to install Rigbox on your experimental rig. However detailed, step-by-step information can be found [here](https://www.ucl.ac.uk/cortexlab/tools/wheel).
8+
The following is a brief description of how to install Rigbox on your experimental rig. Additional detailed, step-by-step information can be found [here](https://www.ucl.ac.uk/cortexlab/tools/wheel).
99

1010
## Prerequisites
11-
Rigbox has a number of essential and optional software dependencies, listed below:
12-
* Windows 7 or later
13-
* [MATLAB](https://uk.mathworks.com/downloads/web_downloads/?s_iid=hp_ff_t_downloads) 2016a or later
14-
* [Psychophsics Toolbox](https://github.com/Psychtoolbox-3/Psychtoolbox-3/releases) v3 or later
15-
* [NI-DAQmx support package](https://uk.mathworks.com/hardware-support/nidaqmx.html)
16-
* [GUI Layout Toolbox](https://uk.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox) v2 or later
17-
* Data Acquisition Toolbox
18-
* Signal Processing Toolbox
19-
* Instrument Control Toolbox
11+
12+
Rigbox has the following software dependencies:
13+
* Windows Operating System (7 or later)
14+
* MATLAB (2016a or later)
15+
* The following MathWorks MATLAB toolboxes:
16+
* Data Acquisition Toolbox
17+
* Signal Processing Toolbox
18+
* Instrument Control Toolbox
19+
* Statistics and Machine Learning Toolbox
20+
* The following community MATLAB toolboxes:
21+
* [GUI Layout Toolbox](https://uk.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox) (v2 or later)
22+
* [Psychophsics Toolbox](http://psychtoolbox.org/download.html) (v3 or later)
23+
* [NI-DAQmx support package](https://uk.mathworks.com/hardware-support/nidaqmx.html)
24+
25+
(* *Note*: You can download all required MathWorks MATLAB toolboxes directly within MATLAB via the "Add-Ons" button in the top Toolstrip with the "Home" tab selected.)
26+
![MATLAB Home Toolstrip](http://i67.tinypic.com/k0zue.png)
27+
28+
Afterwards, you can use the MATLAB "ver" command to bring up the list of installed MathWorks toolboxes.
2029

2130
Additionally, Rigbox works with a number of extra submodules (included):
22-
* [Signals](https://github.com/dendritic/signals) (for running bespoke experiment designs)
23-
* Statistics and Machine Learning Toolbox
24-
* [Microsoft Visual C++ Redistributable for Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145)
25-
* [Alyx-matlab](https://github.com/cortex-lab/alyx-matlab) (for registering data to, and retrieving from, an Alyx database
26-
* [NPY-matlab](https://github.com/kwikteam/npy-matlab) (for saving data in binary NPY format)
27-
28-
## Installing
29-
1. To install Rigbox, clone the repository in git. It is *not* recommended to clone directly into the MATLAB folder
30-
```git clone https://github.com/cortex-lab/Rigbox.git```
31-
2. Pull the latest Rigbox-lite branch. This branch is currently the 'cleanest' one, however in the future it will likely be merged with the master branch.
31+
* [signals](https://github.com/cortex-lab/signals) (for running bespoke experiment designs)
32+
* [alyx-matlab](https://github.com/cortex-lab/alyx-matlab) (for registering data to, and retrieving from, an Alyx database)
33+
* [npy-matlab](https://github.com/kwikteam/npy-matlab) (for saving data in binary NPY format)
34+
* [wheelAnalysis](https://github.com/cortex-lab/wheelAnalysis) (for analyzing data from the steering wheel task)
35+
36+
## Installation via git
37+
38+
0. It is highly recommended to install Rigbox via git. If not already downloaded and installed, install [git](https://git-scm.com/download/win) (and the included minGW software environment and Git Bash MinTTY terminal emulator). After installing, launch the Git Bash terminal.
39+
1. To install Rigbox, use the following commands in the Git Bash terminal to clone the repository from github to your local machine. (* *Note*: It is *not* recommended to clone directly into the MATLAB folder)
40+
```
41+
cd ~
42+
git clone https://github.com/cortex-lab/Rigbox.git
43+
```
44+
2. Pull the latest Rigbox-lite branch. This branch is currently the cleanest one, though in the future it will likely be merged with the master branch.
3245
```
3346
cd Rigbox/
3447
git checkout rigbox-lite
3548
```
36-
3. Run the following to clone the submodules:
37-
```git submodule update --init```
38-
3. In MATLAB run 'addRigboxPaths.m' and restart the program.
39-
4. Set the correct paths by following the instructions in Rigbox\+dat\paths.m on both computers.
40-
5. On the stimulus server, load the hardware.mat file in Rigbox\Repositories\code\config\exampleRig and edit according to your specific hardware setup (link to detailed instructions above, under 'Getting started').
49+
3. Clone the submodules:
50+
```
51+
git submodule update --init
52+
```
53+
4. Open MATLAB, make sure Rigbox and all subdirectories are in your path, run:
54+
> addRigboxPaths
55+
56+
and restart MATLAB.
57+
58+
5. Set the correct paths by following the instructions in the 'Rigbox\+dat\paths.m' file on both machines.
59+
6. On the stimulus server, load 'Rigbox\Repositories\code\config\exampleRig\hardware.mat' and edit according to your specific hardware setup (link to detailed instructions above, under 'Getting started').
4160

42-
To keep up to date, run the following:
61+
To keep the submodules up to date, run the following in the Git Bash terminal (within the Rigbox directory):
4362
```
4463
git pull
4564
git submodule update --remote
4665
```
47-
48-
## Running an experiment
66+
## Running an experiment in MATLAB
4967

5068
On the stimulus server, run:
5169
> srv.expServer
5270
5371
On the mc computer, run:
5472
> mc
5573
56-
This opens a GUI that will allow you to choose a subject, edit some of the experimental parameters and press 'Start' to begin the basic steering wheel task on the stimulus server.
74+
This opens a GUI that will allow you to choose a subject, edit some of the experimental parameters and press 'Start' to begin the basic steering wheel task on the stimulus server.
75+
76+
## Code organization
5777

58-
# Code organization
5978
Below is a list of the principle directories and their general purpose.
60-
## +dat
61-
The data package contains all the code pertaining to the organization and logging of data. It contains functions that generate and parse unique experiment reference ids, that return the file paths where subject data and rig configuration information is stored. Other functions include those that manage experimental log entries and parameter profiles. This package is akin to a lab notebook.
6279

63-
## +eui
64-
This package contains the code pertaining to the Rigbox user interface. It contains code for constructing the mc GUI (MControl.m), and for plotting live experiment data or generating tables for viewing experiment parameters and subject logs. This package is exclusively used by the mc computer.
80+
### +dat
81+
82+
The "data" package contains code pertaining to the organization and logging of data. It contains functions that generate and parse unique experiment reference ids, and return file paths where subject data and rig configuration information is stored. Other functions include those that manage experimental log entries and parameter profiles. A nice metaphor for this package is a lab notebook.
6583

66-
## +exp
67-
The experiment package is for the initialization and running of behavioural experiments. These files define a framework for event- and state-based experiments. Actions such as visual stimulus presentation or reward delivery can be controlled by experiment phases, and experiment phases are managed by an event-handling system (e.g. ResponseEventInfo).
84+
### +eui
6885

69-
The package also triggers auxiliary services (e.g. starting remote acquisition software), and loads parameters for presentation each trail. The principle two base classes that control these experiments are Experiment and its Signals counterpart, SignalsExp.
86+
The "user interface" package contains code pertaining to the Rigbox user interface. It contains code for constructing the mc GUI (MControl.m), and for plotting live experiment data or generating tables for viewing experiment parameters and subject logs.
7087

71-
This package is almost exclusively used by the stimulus server
88+
This package is exclusively used by the mc computer.
7289

73-
## +hw
74-
The hardware package is for configuring, and interfacing with, hardware such as screens, DAQ devices, weighing scales and lick detectors. Withing this is the +ptb package which contains classes for interacting with PsychToolbox.
90+
### +exp
7591

76-
The devices file loads and initializes all the hardware for a specific experimental rig. There are also classes for unifying system and hardware clocks.
92+
The "experiments" package is for the initialization and running of behavioural experiments. It contains code that define a framework for event- and state-based experiments. Actions such as visual stimulus presentation or reward delivery can be controlled by experiment phases, and experiment phases are managed by an event-handling system (e.g. ResponseEventInfo).
7793

78-
## +psy
79-
This package contains simple functions for processing and plotting psychometric data
94+
The package also triggers auxiliary services (e.g. starting remote acquisition software), and loads parameters for presentation for each trail. The principle two base classes that control these experiments are 'Experiment' and its "signals package" counterpart, 'SignalsExp'.
8095

81-
## +srv
82-
This package contains the expServer function as well as classes that manage communications between rig computers.
96+
This package is almost exclusively used by the stimulus server.
8397

84-
The Service base class allows the stimulus server to start and stop auxiliary acquisition systems at the beginning and end of experiments
98+
### +hw
8599

86-
The StimulusControl class is used by the mc computer to manage the stimulus server
100+
The "hardware" package is for configuring, and interfacing with, hardware (such as screens, DAQ devices, weighing scales and lick detectors). Within this is the "+ptb" package which contains classes for interacting with PsychToolbox.
87101

88-
NB: Lower-level communication protocol code is found in the +io package
102+
'devices.m' loads and initializes all the hardware for a specific experimental rig. There are also classes for unifying system and hardware clocks.
89103

90-
## cb-tools\burgbox
91-
Burgbox contains many simply helper functions that are used by the main packages. Within this directory are further packages:
104+
### +psy
105+
106+
The "psychometrics" package contains simple functions for processing and plotting psychometric data.
107+
108+
### +srv
109+
110+
The "stim server" package contains the expServer function as well as classes that manage communications between rig computers.
111+
112+
The 'Service' base class allows the stimulus server to start and stop auxiliary acquisition systems at the beginning and end of experiments.
113+
114+
The 'StimulusControl' class is used by the mc computer to manage the stimulus server.
115+
116+
* *Note*: Lower-level communication protocol code is found in the "cortexlab/+io" package.
117+
118+
### cb-tools/burgbox
119+
120+
Burgbox contains many simple helper functions that are used by the main packages. Within this directory are additional packages:
92121

93122
* +bui --- Classes for managing graphics objects such as axes
94123
* +aud --- Functions for interacting with PsychoPortAudio
95124
* +file --- Functions for simplifying directory and file management, for instance returning the modified dates for specified folders or filtering an array of directories by those that exist
96125
* +fun --- Convenience functions for working with function handles in MATLAB, e.g. functions similar cellfun that are agnostic of input type, or ones that cache function outputs
97-
* +img --- Classes that deal with image and frame data (DEPRICATED)
126+
* +img --- Classes that deal with image and frame data (DEPRECATED)
98127
* +io --- Lower-level communications classes for managing UDP and TCP/IP Web sockets
99-
* +plt --- A few small plotting functions (DEPRICATED)
128+
* +plt --- A few small plotting functions (DEPRECATED)
100129
* +vis --- Functions for returning various windowed visual stimuli (i.g. gabor gratings)
101-
* +ws --- An early Web socket package using SuperWebSocket (DEPRICATED)
130+
* +ws --- An early Web socket package using SuperWebSocket (DEPRECATED)
131+
132+
### cortexlab
102133

103-
## cortexlab
104-
The cortexlab directory is intended for functions and classes that are rig or lab specific, for instance code that allows compatibility with other stimulus presentation packages used by cortexlab (i.e. MPEP)
134+
The cortexlab directory is intended for functions and classes that are rig or cortexlab specific, for instance code that allows compatibility with other stimulus presentation packages used by cortexlab (e.g. MPEP)
105135

106-
## alyx-matlab/@Alyx
107-
This class allows interation with an instance of the Alyx database. More information about Alyx can be found [here](http://alyx.readthedocs.io/en/latest/). Information about using the alyx-matlab class can be found in [alyx-matlab/Examples.m](https://github.com/cortex-lab/alyx-matlab/blob/alyx-as-class/Examples.m).
136+
### submodules
137+
138+
Additional information on the [alyx-matlab](https://github.com/cortex-lab/alyx-matlab), [npy-matlab](https://github.com/kwikteam/npy-matlab), [signals](https://github.com/cortex-lab/signals) and [wheelAnalysis](https://github.com/cortex-lab/wheelAnalysis) submodules can be found in their respective github repositories.
108139

109140
## Authors
110-
The majority of the Rigbox code was written by [Chris Burgess](https://github.com/dendritic/) in 2013. It is now maintained and developed by a number of people at [CortexLab](https://www.ucl.ac.uk/cortexlab).
141+
142+
The majority of the Rigbox code was written by [Chris Burgess](https://github.com/dendritic/) in 2013. It is now maintained and developed by a number of people at [CortexLab](https://www.ucl.ac.uk/cortexlab).

0 commit comments

Comments
 (0)