Skip to content
Mikhail Panko edited this page Aug 29, 2013 · 4 revisions

There are several powerful complex data types natively supported by most languages which can greatly simplify working with data. Learn and apply them when appropriate.

Dictionary

Very convenient for grouping parameters and other very different and unordered groups of variables.

MATLAB: structure

Python: dictionary

An example of a project parameter structure in MATLAB:

params.session = 'SS130829';
params.dataType = 'spikes';
params.sorted = false;
params.numSpikes = 1000;

[sortedSpikes, params] = sortSpikes(unsortedSpikes, params);

List

Convenient for grouping ordered values which are similar, but not enough to make an array/matrix or are not numerical. Allows to reference each value by its order number (index).

MATLAB: cell array

Python: list

Examples of cell arrays in MATLAB:

sessions = {'CS20120316', 'CS20120324', 'CS20120407', 'CS20120421', 'CS20120505'};
ftrStr = {'-features-lfp-[15-25Hz]-[0-500ms]', '-features-lfp-[80-500Hz]-[0-750ms]'};

for i = 1:length(sessions)
    data = loadData(sessions{i});
    analyzeData(data);
end

Set

Convenient for grouping unordered (and therefore, non-repeatable) values. Allows to easily check if some value belongs to a set or not and, in general, to apply the powerful set theory machinery.

MATLAB: vector/matrix or cell array

Python: set

Example of a set in MATLAB:

sessions = {'CS20120316', 'CS20120324', 'CS20120407', 'CS20120421', 'CS20120505'};

if ismember(session, sessions)
    analyzeData(session);
end
Clone this wiki locally