: $Id: myfit.mod,v 1.2 2006/02/14 13:11:29 hines Exp $ :* COMMENT COMMENT ENDCOMMENT NEURON { SUFFIX nothing GLOBAL FIT_INSTALLED } PARAMETER { FIT_INSTALLED=0 } ASSIGNED { RES } VERBATIM #include #include /*#include /* contains MAXLONG */ #include /* contains MAXLONG */ #include extern double* hoc_pgetarg(); extern double hoc_call_func(Symbol*, int narg); extern FILE* hoc_obj_file_arg(int narg); extern Object** hoc_objgetarg(); extern void vector_resize(); extern int vector_instance_px(); extern void* vector_arg(); extern double* vector_vec(); extern double hoc_epsilon; extern void set_seed(); extern int ivoc_list_count(Object*); extern Object* ivoc_list_item(Object*, int); extern int list_vector_px2(); int list_vector_px(); int list_vector_resize(); typedef struct BVEC { int size; int bufsize; short *x; Object* o; } bvec; ENDVERBATIM : spkcmp(modlist,targlist,flag) : compare spike times from left to right finding the closest for each one : better algorithm would do all pairwise comparisons and take the smallest, next smallest, etc. VERBATIM static double spkcmp (void* vv) { int flag, i, j, k, nx, nm[10], nt[10], num, sum, minind; Object *ob, *ob1; double *vvm[10], *vvt[10], *x, err, diff, min; nx = vector_instance_px(vv, &x); ob = *hoc_objgetarg(1); ob1 = *hoc_objgetarg(2); if (ifarg(3)) flag=(int)*getarg(3); else flag=0; num = ivoc_list_count(ob); i = ivoc_list_count(ob1); if (num>10) hoc_execerror("ERR: spkcmp can only handle 10 vectors", 0); if (num!=i) hoc_execerror("ERR: spkcmp different sized lists", 0); if (nx!=num*2) hoc_execerror("ERR: spkcmp vec should be 2*list length", 0); for (i=0;i10) hoc_execerror("ERR: spkcmp can only handle 10 vectors", 0); if (nx!=2*num) hoc_execerror("ERR: spkcmp vec should be 2*list length", 0); for (i=0;i