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

Commit 74867a2

Browse files
committed
Read lfp factors from neurodamus
1 parent 956bde6 commit 74867a2

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

coreneuron/io/nrn_filehandler.hpp

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

1616
#include "coreneuron/utils/nrn_assert.h"
17+
#include "coreneuron/io/nrnsection_mapping.hpp"
1718

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

@@ -123,14 +124,19 @@ class FileHandler {
123124

124125
if (nseg) {
125126
std::vector<int> sec, seg;
127+
std::vector<double> lfp_factors;
126128
sec.reserve(nseg);
127129
seg.reserve(nseg);
130+
lfp_factors.reserve(nseg);
128131

129132
read_array<int>(&sec[0], nseg);
130133
read_array<int>(&seg[0], nseg);
134+
read_array<double>(&lfp_factors[0], nseg);
131135

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

coreneuron/io/nrn_setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ void read_phase3(NrnThread& nt, UserParams& userParams) {
947947
// read section-segment mapping for every section list
948948
for (int j = 0; j < nseclist; j++) {
949949
SecMapping* smap = new SecMapping();
950-
F.read_mapping_info(smap);
950+
F.read_mapping_info(smap, ntmapping);
951951
cmap->add_sec_map(smap);
952952
}
953953

coreneuron/io/nrnsection_mapping.hpp

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

1819
namespace coreneuron {
1920

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

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

0 commit comments

Comments
 (0)