Overview

The Process you've created doesn't have any internal states, so it can only create very uninteresting outputs. Let's add some state variables now, and get some dynamics going.

Keeping a state

Modify your source file as follows, to add a state, initialise it, and output it on one of our two output channels.

M Source Code (against 1258)
case persist.constants.EVENT_STATE_SET
% initialise a state
persist.currentMembranePotential = 0.5;
% ok output.event.response = persist.constants.C_OK;
M Source Code (against 1258)
% write output output.operations{end+1} = { persist.constants.OPERATION_SET_CONTENT, input.oif.default.out,
[persist.currentMembranePotential double(input.time.now)]'
};
Matlab Console
>> test Columns 1 through 7 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 Columns 8 through 10 0.5000 0.5000 0.5000 7.0000 8.0000 9.0000

Good, now we've got an internal state, and we're sending it out on our output port. Now let's add some dynamics.

Modifying internal state

This is going to be the cell's membrane potential (which we'll model as being between zero and one, so it doesn't get too neuroscience-y). Let's implement its decay back towards zero. We'll also make the sample rate a bit more realistic, moving from 10Hz to 1000Hz, and run for a quarter of a second, so we get some nice behaviour displayed. We'll get 250 samples logged, now, so we'll plot the output log instead of just displaying it to console. Modify source file and test script as shown below.

M Source Code (against 995)
% add process state = [];
fS = 1000;
cls = 'dev/quickstart/1258'; sys = sys.addprocess('neuron', cls, fS, state);
M Source Code (against 995)
% execution exe = brahms_execution; exe.all = true; exe.name = 'process';
exe.stop = 0.25;
M Source Code (against 995)
% show output
disp(out.neuron.out)
figure(1)
t = ((1:length(out.neuron.out))-1)/fS;
plot(t, out.neuron.out(1, :))
xlabel('time (seconds)');
ylabel('membrane potential (unitless)')

(The t=... stuff just makes sure the plot is in seconds...)

M Source Code (against 1258)
case persist.constants.EVENT_RUN_SERVICE
% run dynamics
tau = 0.01; % 10ms membrane time constant
fS = input.time.sampleRate.rate;
lambda = exp(-1.0/(tau * fS));
persist.currentMembranePotential = persist.currentMembranePotential * lambda;
% write output

Which should generate a plot something like this one.

Where do I go from here?

This is entirely up to you. You can keep as much state as you like, in the same way as shown above.