Re: Driving synaptic event using vecStim
Posted: Thu Feb 14, 2019 6:52 am
* the setup works fine in regular neuron
The NEURON Forum
https://www.neuron.yale.edu/phpBB/
Code: Select all
NEURON {
THREADSAFE
ARTIFICIAL_CELL VecStim
BBCOREPOINTER ptr
}
ASSIGNED {
index
etime (ms)
ptr
}
VERBATIM
#if NRNBBCORE /* running in CoreNEURON */
#define IFNEWSTYLE(arg) arg
#else /* running in NEURON */
/*
1 means noiseFromRandom was called when _ran_compat was previously 0 .
2 means noiseFromRandom123 was called when _ran_compart was previously 0.
*/
static int _ran_compat; /* specifies the noise style for all instances */
#define IFNEWSTYLE(arg) if(_ran_compat == 2) { arg }
#endif /* running in NEURON */
ENDVERBATIM
...... (INITIAL block, NET_RECEIVE block etc.)
VERBATIM
#include "nrnran123.h"
#if !NRNBBCORE
/* backward compatibility */
double nrn_random_pick(void* r);
void* nrn_random_arg(int argpos);
int nrn_random_isran123(void* r, uint32_t* id1, uint32_t* id2, uint32_t* id3);
#endif
ENDVERBATIM
VERBATIM
static void bbcore_write(double* x, int* d, int* xx, int *offset, _threadargsproto_) {
/* error if using the legacy scop_exprand */
if (!_p_ptr) {
fprintf(stderr, "NetStim: cannot use the legacy scop_negexp generator for the random stream.\n");
assert(0);
}
if (d) {
uint32_t* di = ((uint32_t*)d) + *offset;
if (_ran_compat == 1) {
void** pv = (void**)(&_p_ptr);
/* error if not using Random123 generator */
if (!nrn_random_isran123(*pv, di, di+1, di+2)) {
fprintf(stderr, "NetStim: Random123 generator is required\n");
assert(0);
}
}else{
nrnran123_State** pv = (nrnran123_State**)(&_p_ptr);
nrnran123_getids3(*pv, di, di+1, di+2);
}
/*printf("Netstim bbcore_write %d %d %d\n", di[0], di[1], di[3]);*/
}
*offset += 3;
}
static void bbcore_read(double* x, int* d, int* xx, int* offset, _threadargsproto_) {
assert(!_p_ptr);
if (noise) {
uint32_t* di = ((uint32_t*)d) + *offset;
nrnran123_State** pv = (nrnran123_State**)(&_p_ptr);
*pv = nrnran123_newstream3(di[0], di[1], di[2]);
}else{
return;
}
*offset += 3;
}
ENDVERBATIM
The file distributed with NEURON is called vecevent.mod, even though it defines the properties of an ARTIFICIAL_CELL class called VecStim. Among my own files, I find something called vecstim.mod from 2002, the source code for which differed from vecevent.mod, and which became deprecated by 2008 if not earlier. Looking to the future, wouldn't it be best to abandon vecstim.mod and base new development on vecevent.mod? zyc, are you so far along in your own code development that you are now stuck with vecstim.mod?