@@ -58,7 +58,7 @@ extern void pattern_stim_setup_helper(int size,
58
58
NrnThread* _nt,
59
59
double v);
60
60
61
- static size_t read_raster_file (const char * fname, double ** tvec, int ** gidvec);
61
+ static size_t read_raster_file (const char * fname, double ** tvec, int ** gidvec, double tstop );
62
62
63
63
int nrn_extra_thread0_vdata;
64
64
@@ -77,7 +77,7 @@ void nrn_set_extra_thread0_vdata() {
77
77
78
78
// fname is the filename of an output_spikes.h format raster file.
79
79
// todo : add function for memory cleanup (to be called at the end of simulation)
80
- void nrn_mkPatternStim (const char * fname) {
80
+ void nrn_mkPatternStim (const char * fname, double tstop ) {
81
81
int type = nrn_get_mechtype (" PatternStim" );
82
82
if (!corenrn.get_memb_func (type).sym ) {
83
83
printf (" nrn_set_extra_thread_vdata must be called (after mk_mech, and before nrn_setup\n " );
@@ -93,7 +93,7 @@ void nrn_mkPatternStim(const char* fname) {
93
93
int * gidvec;
94
94
95
95
// todo : handle when spike raster will be very large (int < size_t)
96
- size_t size = read_raster_file (fname, &tvec, &gidvec);
96
+ size_t size = read_raster_file (fname, &tvec, &gidvec, tstop );
97
97
98
98
Point_process* pnt = nrn_artcell_instantiate (" PatternStim" );
99
99
NrnThread* nt = nrn_threads + pnt->_tid ;
@@ -123,7 +123,8 @@ static bool spike_comparator(const spike_type& l, const spike_type& r) {
123
123
return l.first < r.first ;
124
124
}
125
125
126
- size_t read_raster_file (const char * fname, double ** tvec, int ** gidvec) {
126
+
127
+ size_t read_raster_file (const char * fname, double ** tvec, int ** gidvec, double tstop) {
127
128
FILE* f = fopen (fname, " r" );
128
129
nrn_assert (f);
129
130
@@ -138,7 +139,9 @@ size_t read_raster_file(const char* fname, double** tvec, int** gidvec) {
138
139
int gid;
139
140
140
141
while (fscanf (f, " %lf %d\n " , &stime, &gid) == 2 ) {
141
- spikes.push_back (std::make_pair (stime, gid));
142
+ if ( stime >= t && stime <= tstop) {
143
+ spikes.push_back (std::make_pair (stime, gid));
144
+ }
142
145
}
143
146
144
147
fclose (f);
0 commit comments