Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
WeinaJi committed Sep 27, 2023
1 parent 2186890 commit 3d6b9e5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 45 deletions.
15 changes: 11 additions & 4 deletions src/coreneuron/io/nrn2core_direct.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,18 @@ extern int (*nrn2core_get_dat2_vecplay_inst_)(int tid,

extern void (*nrn2core_part2_clean_)();

extern void (*nrn2core_get_dat3_cell_count)(int&cell_count);
extern void (*nrn2core_get_dat3_cell_count)(int& cell_count);
extern void (*nrn2core_get_dat3_cellmapping)(int i, int& gid, int& nsec, int& nseg, int& n_seclist);
extern void (*nrn2core_get_dat3_secmapping)(int i_c, int i_sec, std::string& segname,
int& nsec, int& nseg, size_t& total_lfp_factors, int& n_electrode,
std::vector<int>& data_sec, std::vector<int>& data_seg, std::vector<double>& data_lfp);
extern void (*nrn2core_get_dat3_secmapping)(int i_c,
int i_sec,
std::string& segname,
int& nsec,
int& nseg,
size_t& total_lfp_factors,
int& n_electrode,
std::vector<int>& data_sec,
std::vector<int>& data_seg,
std::vector<double>& data_lfp);

/* what variables to send back to NEURON on each time step */
extern void (*nrn2core_get_trajectory_requests_)(int tid,
Expand Down
76 changes: 45 additions & 31 deletions src/coreneuron/io/nrn_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,16 @@ void (*nrn2core_all_weights_return_)(std::vector<double*>& weights);

void (*nrn2core_get_dat3_cell_count)(int& cell_count);
void (*nrn2core_get_dat3_cellmapping)(int i, int& gid, int& nsec, int& nseg, int& n_seclist);
void (*nrn2core_get_dat3_secmapping)(int i_c, int i_sec, std::string& segname,
int& nsec, int& nseg, size_t& total_lfp_factors, int& n_electrode,
std::vector<int>& data_sec, std::vector<int>& data_seg, std::vector<double>& data_lfp);
void (*nrn2core_get_dat3_secmapping)(int i_c,
int i_sec,
std::string& segname,
int& nsec,
int& nseg,
size_t& total_lfp_factors,
int& n_electrode,
std::vector<int>& data_sec,
std::vector<int>& data_seg,
std::vector<double>& data_lfp);
// file format defined in cooperation with nrncore/src/nrniv/nrnbbcore_write.cpp
// single integers are ascii one per line. arrays are binary int or double
// Note that regardless of the gid contents of a group, since all gids are
Expand Down Expand Up @@ -944,14 +951,23 @@ void read_phase3(NrnThread& nt, UserParams& userParams) {
int gid, nsec, nseg, nseclist;
nrn2core_get_dat3_cellmapping(i, gid, nsec, nseg, nseclist);
CellMapping* cmap = new CellMapping(gid);
for (int j=0; j<nseclist; j++) {
for (int j = 0; j < nseclist; j++) {
std::string segname;

Check warning on line 955 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L952-L955

Added lines #L952 - L955 were not covered by tests
int n_secsec, n_secseg, n_electrodes;
size_t total_lfp_factors;
std::vector<int> data_sec;
std::vector<int> data_seg;
std::vector<double> data_lfp;
nrn2core_get_dat3_secmapping(i, j, segname, n_secsec, n_secseg, total_lfp_factors, n_electrodes, data_sec, data_seg, data_lfp);
nrn2core_get_dat3_secmapping(i,

Check warning on line 961 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L958-L961

Added lines #L958 - L961 were not covered by tests
j,
segname,
n_secsec,
n_secseg,
total_lfp_factors,
n_electrodes,
data_sec,
data_seg,
data_lfp);
SecMapping* smap = new SecMapping();
smap->name = segname;
int factor_offset = 0;
Expand All @@ -962,46 +978,44 @@ void read_phase3(NrnThread& nt, UserParams& userParams) {
if (total_lfp_factors > 0) {

Check warning on line 978 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L971-L978

Added lines #L971 - L978 were not covered by tests
// Abort if the factors contains a NaN
nrn_assert(count_if(data_lfp.begin(), data_lfp.end(), [](double d) {

Check warning on line 980 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L980

Added line #L980 was not covered by tests
return std::isnan(d);
}) == 0);
return std::isnan(d);
}) == 0);
std::vector<double> segment_factors(data_lfp.begin() + factor_offset,
data_lfp.begin() + factor_offset + n_electrodes);
data_lfp.begin() + factor_offset +
n_electrodes);
cmap->add_segment_lfp_factor(data_seg[i], segment_factors);
}

Check warning on line 987 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L983-L987

Added lines #L983 - L987 were not covered by tests
}
cmap->add_sec_map(smap);
}
cmap->add_sec_map(smap);

}
ntmapping->add_cell_mapping(cmap);

Check warning on line 991 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L989-L991

Added lines #L989 - L991 were not covered by tests

}
}
} else {
int count = 0;

Check warning on line 994 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L994

Added line #L994 was not covered by tests

int count = 0;
F.read_mapping_cell_count(&count);

Check warning on line 996 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L996

Added line #L996 was not covered by tests

F.read_mapping_cell_count(&count);
/** number of cells in mapping file should equal to cells in NrnThread */
nrn_assert(count == nt.ncell);

Check warning on line 999 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L999

Added line #L999 was not covered by tests

/** number of cells in mapping file should equal to cells in NrnThread */
nrn_assert(count == nt.ncell);
/** for every neuron */
for (int i = 0; i < nt.ncell; i++) {

Check warning on line 1002 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L1002

Added line #L1002 was not covered by tests
int gid, nsec, nseg, nseclist;

/** for every neuron */
for (int i = 0; i < nt.ncell; i++) {
int gid, nsec, nseg, nseclist;
// read counts
F.read_mapping_count(&gid, &nsec, &nseg, &nseclist);

Check warning on line 1006 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L1006

Added line #L1006 was not covered by tests

// read counts
F.read_mapping_count(&gid, &nsec, &nseg, &nseclist);
CellMapping* cmap = new CellMapping(gid);

Check warning on line 1008 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L1008

Added line #L1008 was not covered by tests

CellMapping* cmap = new CellMapping(gid);
// read section-segment mapping for every section list
for (int j = 0; j < nseclist; j++) {
SecMapping* smap = new SecMapping();
F.read_mapping_info(smap, ntmapping, cmap);
cmap->add_sec_map(smap);

Check warning on line 1014 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L1011-L1014

Added lines #L1011 - L1014 were not covered by tests
}

// read section-segment mapping for every section list
for (int j = 0; j < nseclist; j++) {
SecMapping* smap = new SecMapping();
F.read_mapping_info(smap, ntmapping, cmap);
cmap->add_sec_map(smap);
ntmapping->add_cell_mapping(cmap);

Check warning on line 1017 in src/coreneuron/io/nrn_setup.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreneuron/io/nrn_setup.cpp#L1017

Added line #L1017 was not covered by tests
}

ntmapping->add_cell_mapping(cmap);
}
}
// make number #cells match with mapping size
nrn_assert((int) ntmapping->size() == nt.ncell);
Expand Down
19 changes: 12 additions & 7 deletions src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,29 +227,34 @@ void nrnthread_dat3_cell_count(int& cell_count) {
cell_count = mapinfo.size();
}

Check warning on line 228 in src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp#L226-L228

Added lines #L226 - L228 were not covered by tests

void nrnthread_dat3_cellmapping(int i, int& gid,
int& nsec, int& nseg, int& n_seclist) {
void nrnthread_dat3_cellmapping(int i, int& gid, int& nsec, int& nseg, int& n_seclist) {
CellMapping* c = mapinfo.mapping[i];
gid = c->gid;
nsec = c->num_sections();
nseg = c->num_segments();
n_seclist = c->size();
}

Check warning on line 236 in src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp#L230-L236

Added lines #L230 - L236 were not covered by tests

void nrnthread_dat3_secmapping(int i_c, int i_sec, std::string& segname,
int& nsec, int& nseg, size_t& total_lfp_factors, int& n_electrodes,
std::vector<int>& data_sec, std::vector<int>& data_seg, std::vector<double>& data_lfp) {
void nrnthread_dat3_secmapping(int i_c,

Check warning on line 238 in src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp#L238

Added line #L238 was not covered by tests
int i_sec,
std::string& segname,
int& nsec,
int& nseg,
size_t& total_lfp_factors,
int& n_electrodes,
std::vector<int>& data_sec,
std::vector<int>& data_seg,
std::vector<double>& data_lfp) {
CellMapping* c = mapinfo.mapping[i_c];
SecMapping* s = c->secmapping[i_sec];
segname=s->name.c_str();
segname = s->name.c_str();
nsec = s->nsec;
nseg = s->size();
total_lfp_factors = s->seglfp_factors.size();
n_electrodes = s->num_electrodes;
data_sec = s->sections;
data_seg = s->segments;
data_lfp = s->seglfp_factors;

}

Check warning on line 258 in src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp#L248-L258

Added lines #L248 - L258 were not covered by tests

// sizes and total data count
Expand Down
13 changes: 10 additions & 3 deletions src/nrniv/nrncore_write/callbacks/nrncore_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,16 @@ int nrnthread_dat2_vecplay_inst(int tid,
int& ubound_index);
void nrnthread_dat3_cell_count(int& cell_count);
void nrnthread_dat3_cellmapping(int i, int& gid, int& nsec, int& nseg, int& n_seclist);
void nrnthread_dat3_secmapping(int i_c, int i_sec, std::string& segname,
int& nsec, int& nseg, size_t& total_lfp_factors, int& n_electrode,
std::vector<int>& data_sec, std::vector<int>& data_seg, std::vector<double>& data_lfp);
void nrnthread_dat3_secmapping(int i_c,
int i_sec,
std::string& segname,
int& nsec,
int& nseg,
size_t& total_lfp_factors,
int& n_electrode,
std::vector<int>& data_sec,
std::vector<int>& data_seg,
std::vector<double>& data_lfp);

int* datum2int(int type,
Memb_list* ml,
Expand Down

0 comments on commit 3d6b9e5

Please sign in to comment.