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

Commit f654226

Browse files
committed
Read lfp factors from neurodamus
1 parent 89b0657 commit f654226

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

coreneuron/io/nrn_filehandler.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <sys/stat.h>
1616

1717
#include "coreneuron/utils/nrn_assert.h"
18+
#include "coreneuron/io/nrnsection_mapping.hpp"
1819

1920
namespace coreneuron {
2021
/** Encapsulate low-level reading of coreneuron input data files.
@@ -111,7 +112,7 @@ class FileHandler {
111112
* Read count no of mappings for section to segment
112113
*/
113114
template <typename T>
114-
int read_mapping_info(T* mapinfo) {
115+
int read_mapping_info(T* mapinfo, NrnThreadMappingInfo* ntmapping) {
115116
int nsec, nseg, n_scan;
116117
char line_buf[max_line_length], name[max_line_length];
117118

@@ -124,14 +125,19 @@ class FileHandler {
124125

125126
if (nseg) {
126127
std::vector<int> sec, seg;
128+
std::vector<double> lfp_factors;
127129
sec.reserve(nseg);
128130
seg.reserve(nseg);
131+
lfp_factors.reserve(nseg);
129132

130133
read_array<int>(&sec[0], nseg);
131134
read_array<int>(&seg[0], nseg);
135+
read_array<double>(&lfp_factors[0], nseg);
132136

133137
for (int i = 0; i < nseg; i++) {
134138
mapinfo->add_segment(sec[i], seg[i]);
139+
ntmapping->add_segment_id(seg[i]);
140+
ntmapping->add_segment_lfp_factor(seg[i], lfp_factors[i]);
135141
}
136142
}
137143
return nseg;

coreneuron/io/nrn_setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ void read_phase3(NrnThread& nt, UserParams& userParams) {
941941
// read section-segment mapping for every section list
942942
for (int j = 0; j < nseclist; j++) {
943943
SecMapping* smap = new SecMapping();
944-
F.read_mapping_info(smap);
944+
F.read_mapping_info(smap, ntmapping);
945945
cmap->add_sec_map(smap);
946946
}
947947

coreneuron/io/nrnsection_mapping.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <vector>
1616
#include <map>
1717
#include <iostream>
18+
#include <unordered_map>
1819

1920
namespace coreneuron {
2021

@@ -154,6 +155,12 @@ struct NrnThreadMappingInfo {
154155
/** list of cells mapping */
155156
std::vector<CellMapping*> mappingvec;
156157

158+
/** list of segment ids */
159+
std::vector<int> segment_ids;
160+
161+
/** map containing segment ids an its respective lfp factors */
162+
std::unordered_map<int, double> lfp_factors;
163+
157164
/** @brief number of cells */
158165
size_t size() const {
159166
return mappingvec.size();
@@ -182,6 +189,16 @@ struct NrnThreadMappingInfo {
182189
void add_cell_mapping(CellMapping* c) {
183190
mappingvec.push_back(c);
184191
}
192+
193+
/** @brief add a new segment */
194+
void add_segment_id(const int segment_id) {
195+
segment_ids.push_back(segment_id);
196+
}
197+
198+
/** @brief add the lfp factor of a segment_id */
199+
void add_segment_lfp_factor(const int segment_id, double factor) {
200+
lfp_factors.insert({segment_id, factor});
201+
}
185202
};
186203
} // namespace coreneuron
187204

0 commit comments

Comments
 (0)