Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit db36558

Browse files
committed
Patternstip fix : allow restore phases to provide new pattern-stim
1 parent ba64cfa commit db36558

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

coreneuron/mech/modfile/pattern.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ void pattern_stim_setup_helper(int size, double* tv, int* gv, _threadargsproto_)
116116
info->size = size;
117117
info->tvec = tv;
118118
info->gidvec = gv;
119+
artcell_net_send ( _tqitem, -1, (Point_process*) _nt->_vdata[_ppvar[1*_STRIDE]], t + 0.0 , 1.0 ) ;
119120
}
120121
} // namespace coreneuron
121122
ENDVERBATIM

coreneuron/nrniv/main1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void nrn_init_and_load_data(int argc,
264264

265265
// Invoke PatternStim
266266
if (nrnopt_get_flag("--pattern")) {
267-
nrn_mkPatternStim(nrnopt_get_str("--pattern").c_str());
267+
nrn_mkPatternStim(nrnopt_get_str("--pattern").c_str(), nrnopt_get_dbl("--tstop"));
268268
}
269269

270270
/// Setting the timeout

coreneuron/nrniv/nrniv_decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extern int nrn_setup_multiple;
5959
extern int nrn_setup_extracon;
6060
extern void nrn_cleanup(bool clean_ion_global_map = true);
6161
extern void BBS_netpar_solve(double);
62-
extern void nrn_mkPatternStim(const char* filename);
62+
extern void nrn_mkPatternStim(const char* filename, double tstop);
6363
extern int nrn_extra_thread0_vdata;
6464
extern void nrn_set_extra_thread0_vdata(void);
6565
extern Point_process* nrn_artcell_instantiate(const char* mechname);

coreneuron/nrniv/patternstim.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern void pattern_stim_setup_helper(int size,
5757
NrnThread* _nt,
5858
double v);
5959

60-
static size_t read_raster_file(const char* fname, double** tvec, int** gidvec);
60+
static size_t read_raster_file(const char* fname, double** tvec, int** gidvec, double tstop);
6161

6262
int nrn_extra_thread0_vdata;
6363

@@ -76,7 +76,7 @@ void nrn_set_extra_thread0_vdata() {
7676

7777
// fname is the filename of an output_spikes.h format raster file.
7878
// todo : add function for memory cleanup (to be called at the end of simulation)
79-
void nrn_mkPatternStim(const char* fname) {
79+
void nrn_mkPatternStim(const char* fname, double tstop) {
8080
int type = nrn_get_mechtype("PatternStim");
8181
if (!memb_func[type].sym) {
8282
printf("nrn_set_extra_thread_vdata must be called (after mk_mech, and before nrn_setup\n");
@@ -92,7 +92,7 @@ void nrn_mkPatternStim(const char* fname) {
9292
int* gidvec;
9393

9494
// todo : handle when spike raster will be very large (int < size_t)
95-
size_t size = read_raster_file(fname, &tvec, &gidvec);
95+
size_t size = read_raster_file(fname, &tvec, &gidvec, tstop);
9696

9797
Point_process* pnt = nrn_artcell_instantiate("PatternStim");
9898
NrnThread* nt = nrn_threads + pnt->_tid;
@@ -122,7 +122,8 @@ static bool spike_comparator(const spike_type& l, const spike_type& r) {
122122
return l.first < r.first;
123123
}
124124

125-
size_t read_raster_file(const char* fname, double** tvec, int** gidvec) {
125+
126+
size_t read_raster_file(const char* fname, double** tvec, int** gidvec, double tstop) {
126127
FILE* f = fopen(fname, "r");
127128
nrn_assert(f);
128129

@@ -137,7 +138,9 @@ size_t read_raster_file(const char* fname, double** tvec, int** gidvec) {
137138
int gid;
138139

139140
while (fscanf(f, "%lf %d\n", &stime, &gid) == 2) {
140-
spikes.push_back(std::make_pair(stime, gid));
141+
if ( stime >= t && stime <= tstop) {
142+
spikes.push_back(std::make_pair(stime, gid));
143+
}
141144
}
142145

143146
fclose(f);

0 commit comments

Comments
 (0)