As described here, the VH lab database for a particular
experiment resides in the [DIRNAME]/analysis/experiment
file. This file is in Matlab
format, although it doesn’t contain the .mat extension (see notes on Matlab files that lack the .mat extension). Using the dirstruct interface can make reading and writing from the database easier One can create a new dirstruct object using the following: ds = dirstruct([DIRNAME]); An easy way to get the full filename for the experiment file is expfilename = getexperimentfile(ds) Reading the entire contents of the experiment file: One can read all of the variables in the experiment file using the following standard Matlab command: mydata = load(expfilename,'-mat'); What’s usually in the experiment file The experiment file can contain anything in principle, but typically contains 2 types of variables:
There are no true restrictions on what can be placed in variables in the experiment file, but as a rule of thumb, data that is particularly large or cumbersome might not be a good choice for inclusion. For example, for a cell that is extracellularly recorded, we typically store all spike times in the corresponding record in the database, but we do not store all the raw data. Likewise, for 2-photon data, we store the raw fluorescence brightness values for the region-of-interest that includes a given cell, but we do not store all the raw image data for the cell in the database. Instead, for both of these cells, we would store the directory information that would allow a program to access the appropriate data, if necessary. A useful tool for reading a list of cells The most common element that is read from the database is a list of cells. It is often convienient to read in a list of cell names and the associated cell data all at once, so I wrote a function that does this: [celldata,cellnames] = load2celllist(getexperimentfile(ds),'cell*','-mat'); The ‘cell*’ string tells the function to read only variable names within the experiment file that start with ‘cell’; this command will read in all of the cells in the experiment into the variables celldata and cellnames. Note that the ‘cell’ in load2celllist refers to the Matlab data type ‘cell’; that is, the non-matrix data type that can assume any size, and it is only a coincidence that it is commonly used to read in data that describes cells in the nervous system. The measureddata object format and its “children” If you type celldata{1}, you will notice that cells are of one of the following data types: spikedata, or, most likely, cksmultiunit. These data types are all based on a data type that SDV built called measureddata. The type measureddata provides some functionality for programmers working with data that has been acquired. There are 3 important services that are provided by measureddata:
These can be read using the A = findassociate(mymd,'','','') function; if the arguments are blank, as in this example, all associates are returned, but one can search for associates by field using A = findassociate(mymd,[type],[owner],[desc]); if any of those arguments are left empty (''), then they will not be used in the search (that is, it specifies “any type”, or “any owner”, or “any desc”). Examples of reading from associates and using the information to perform additional analysis text Adding associates to a measureddata object (example) One can add a new associate to a measureddata object using the associate command. For example, we can make a structure object for our associate: assoc.type = 'My new type'; One removes associates from a measureddata object using the disassociate command. First, you must know the index of all the associates you wish to remove. For example, to find the index values for all associates, use:
[Future text here]
Performing an operation on all of the cells in the database: The following code snippet calls the function performfunction (a made-up function) for all of the cells that were loaded into the database above (using the load2celllist example): for i=1:length(celldata), Writing or rewriting variables to the experiment file If you have new or modified variables to write back to the experiment file, you can use the function saveexpvar(ds, vardata, varnames) to save a cell list of variables vardata with the names varnames to the experiment file associated with the experiment ds. In the example above, where we ran a function on all cells and generated new associates or modified associates, we might use the following code to re-save the data to the experiment file: saveexpvar(ds, newcelldata, cellnames) Note that the function saveexpvars creates an “experiment-lock” file in the same directory as “experiment” so that other users cannot save data to the same file at the same time (this results in data corruption). However, if an error occurs during your save, you may need to manually remove the lock file (see help saveexpvars). |