FAQ


I only ever seem to interact with measureddata objects by using findassociate, which seems much slower (1000x) than accessing fields in native matlab structures. Clearly matlab structures lack the other methods of measureddata objects, which I'm sure I'm overlooking and not using the measureddata objects to their fullest. Any thoughts would be appreciated.

So measureddata objects offer a bit more flexibility than Matlab native structures...there is the spikedata object (a descendent class of measureddata), which stores spike times and the intervals over which spikes were recorded (so you know when the neuron spiked and when you were recording; a lack of spike outside the window when you were recording indicates no information rather than no spikes).  One could imagine making an roidata object that offered similar features.

But this isn't really the question you're asking.

The short answer is that Matlab's native features have a couple of problems that the associates overcome.

First, imagine you have 2 cells, one that had an orientation measurement, one that has a contrast measurement.  If you wanted to use Matlab native structure fields, you might do:

cellA.orientationtest = 't00001';

cellB.contrasttest = 't00002';

Now, you can't concatenate these like this:

mycelllist = [cellA cellB]
??? Error using ==> horzcat
CAT arguments are not consistent in structure field names.

because the structures do not have the same fields in the same order (these 2 conditions are necessary for structures to be concatenated).

So you either have to create a "dummy" field with an empty value for all of your fields and all of your cells, like:

cellA.orientationtest = 't00001'; 
cellA.contrasttest = '';

cellB.orientationtest = ''; 
cellB.contrasttest = 't000002';

When you added a field, you'd have to make sure you added it to all your structures.  This can get complicated, especially if you don't know the fields that you might add ahead of time.

Second, you could do this, and this might be legitimately faster:

cellA.orientationtest = 't00001';
cellB.contrasttest = 't00002';

mycelllist = {cellA cellB}

Here, the structures are in a cell array, so you'd access the fields like this:

if isfield(mycelllist{1},'orientationtest'),
orivalue = mycelllist(1).orientationtest;
end;

I didn't do this but it might be better.

The associates implementation as it stands achieves (above the Matlab native method):

1) arbitrary fields for each cell (though the second method above also can do this)
2) the ability to use field names that include spaces/phrases and other characters that are not legal matlab variable names
3) the ability to add an "owner", so a program or user could find all of the fields that it/he/she added (though I _rarely_ use this)
4) the ability to add a description (which I don't always do a good job of)


Comments