Example 1: Examining the contents of a VHLab database

After reading the database instructions, it is useful to walk through a set of specific examples.

First, let's download some example data from GitHub:

Download the data at https://github.com/VH-Lab/Example-data-for-tutorial

Windows XP Users: To mount the drive, click "My computer", "My network places" (to the left), "Add a network place", and enter \\kfc.bio.brandeis.edu\SoftwareDistribution. You can then log in with the username and password above. You may need to enter KFC\vhtools as the username.

Unpacking the example data

Let's unpack the data at any location you choose; let's use a variable name to store your path of choice to make life easier.

Suppose the unpacked data is in '/Users/vanhoosr/data/2008-06-18' (on a PC, this would be something like 'C:\mydata\2008-06-18'). Let's write:

mydatapath = '/Users/vanhoosr/';

Reading in all the cell data from the database

Let's create a dirstruct object to make reading the data easier.

ds = dirstruct([mydatapath '2008-06-18']); % should take a few seconds to complete as it examines directories

The getexperimentfile() function will return the experiment file associated with that experiment. Try it out:


Now let's read in all the cell data from this experiment

[celldata,cellnames] = load2celllist(getexperimentfile(ds),'cell*','-mat');

Taking a look at the contents

How many cells are there here?

One can use




to find out how many cells there are.

Examining associates

For any given cell i, one can type

A = findassociate(celldata{i},'','','');

to get a complete list of all associates. Let's start with i = 1:

i = 1;

A = findassociate(celldata{i},'','','')

Depending upon the number of associates, you should see output that looks like :

A =

1x2 struct array with fields:





That is, it is an array of structures with elements type, owner, data, and desc. We can examine the contents of, say, the second associate by typing


and looking at the output:

ans =

type: 'Layer 4 boarder depths'

owner: ''

data: [1175 1475]

desc: ''

This particular associate contains data that describes the depth of layer 4 for this electrode penetration.

Note: some cell records will have more associates than others, depending upon what types of stimuli were run for that cell, or if the cell was deemed worthy of examination during the experiment.

Let's look at another cell:

i = 34;

A = findassociate(celldata{i},'','','')

A =

1x281 struct array with fields:





This cell has a whopping 281 associates, as it was run under multiple stimulus conditions and has already undergone a lot of analysis.

We can check out the cell's name by typing


You can check out several of its associates by typing A(1), A(2), A(3), etc.

Let's look at one in particular:

B = findassociate(celldata{i},'FineDir test','','')

This should return something like:

B =

type: 'FineDir test'

owner: 'gratingsheetlet'

data: 't00039'

desc: 'FineDir test'

This tells us where we can find the data associated with the 'FineDir test', it's in directory t00039 (the value of B.data).

We could then look at files in that directory, using something like:

dir([getpathname(ds) filesep B.data])

One more example, let's look for

C = findassociate(celldata{i},'SP F0 Ach OT Response curve','','')

which should return:

C =

type: 'SP F0 Ach OT Response curve'

owner: 'twophoton'

data: [4x16 double]

desc: ''

This is the average responses to the achromatic orientation response curve; the SP indicates that it is a spiking record, the F0 indicates that it is the mean response (not a modulated response), I have no idea why the owner is 'twophoton', that is erroneous but is only informational (it doesn't actually carry through to any processing) (see item 4 below), and the data are in C.data:


which should return:

ans =

Columns 1 through 7

0 22.5000 45.0000 67.5000 90.0000 112.5000 135.0000

11.2000 0.4000 0.5000 0.1000 2.3000 5.6000 5.8000

5.5295 0.6519 1.1180 0.2236 3.0125 1.4318 1.9875

2.4729 0.2915 0.5000 0.1000 1.3472 0.6403 0.8888

Columns 8 through 14

157.5000 180.0000 202.5000 225.0000 247.5000 270.0000 292.5000

16.0000 15.7000 0.7000 0.2000 0.3000 0.3000 6.6000

4.2279 5.7184 0.8367 0.4472 0.4472 0.2739 1.9812

1.8908 2.5573 0.3742 0.2000 0.2000 0.1225 0.8860

Columns 15 through 16

315.0000 337.5000

8.9000 14.6000

4.4074 7.6273

1.9710 3.4110

The first row are the directions in which the gratings drifted, the second row are the mean responses in each direction, the third row is the standard deviation of the response across trials, and the fourth row is the standard error across trials. You could quickly plot this by typing



ylabel('Firing rate (Hz)');

xlabel('Drift direction (degrees)');

or, if you want to get fancier, with error bars:


ylabel('Firing rate (Hz)');

xlabel('Drift direction (degrees)');

As you can see, associates are great for associating all kinds of different data with a cell, be it 1) notes made by the experimenter at the time of recording, 2) information about where certain records pertaining to the cell exist on disk, and 3) results of data analysis programs.

Seeing the type names of all of the associates of a given cell

If you have a list of all the associates in a variable A, then one can print all the names to the Matlab Command Window by the following line of code:

A = findassociate(celldata{i},'','','');


This is really just a bit of standard Matlab code. First, A is an array of structures that can be many elements long, say it is 1xN elements long. We can ask for all of the 'type' fields in the list by typing A.type; however, this will return the N type strings as output arguments. In order to collect all of these outputs into one (unnamed) variable, we enclose the whole business in brackets { } to make a Matlab cell list. Finally, we'd like to have the contents print one line at a time, so we transpose the cell list using the single quote (') so the output will display as one vertical column.

What is the meaning of the data in each associate type?

See this link.

How can I read in a set of databases that comprise a whole study?

A handy function is readcellsfromexperimentlist, which will read cells from an entire study. An example is provided in the help for that function:

prefix = '/Volumes/Data1/mystudydir/'; % the directory where the experiments are stored

% this is for a Mac, where forward slashes are used to separate directories

expernames = {'2011-01-01','2011-01-02','2011-01-03'}; % a cell list of experiment names

verbose = 1; % print out the name of each experiment as it is reading in data

threshold = 4; % exclude cells with fewer than 4 associates

[celldata,cellnames] = readcellsfromexperimentlist(prefix, expernames, 1, 4);