-
Notifications
You must be signed in to change notification settings - Fork 7
Complex data types
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.
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);
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
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