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

Commit

Permalink
Read lfp factors from neurodamus
Browse files Browse the repository at this point in the history
  • Loading branch information
jorblancoa committed Oct 27, 2021
1 parent 89b0657 commit f654226
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
8 changes: 7 additions & 1 deletion coreneuron/io/nrn_filehandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sys/stat.h>

#include "coreneuron/utils/nrn_assert.h"
#include "coreneuron/io/nrnsection_mapping.hpp"

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

Expand All @@ -124,14 +125,19 @@ class FileHandler {

if (nseg) {
std::vector<int> sec, seg;
std::vector<double> lfp_factors;
sec.reserve(nseg);
seg.reserve(nseg);
lfp_factors.reserve(nseg);

read_array<int>(&sec[0], nseg);
read_array<int>(&seg[0], nseg);
read_array<double>(&lfp_factors[0], nseg);

for (int i = 0; i < nseg; i++) {
mapinfo->add_segment(sec[i], seg[i]);
ntmapping->add_segment_id(seg[i]);
ntmapping->add_segment_lfp_factor(seg[i], lfp_factors[i]);
}
}
return nseg;
Expand Down
2 changes: 1 addition & 1 deletion coreneuron/io/nrn_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ void read_phase3(NrnThread& nt, UserParams& userParams) {
// read section-segment mapping for every section list
for (int j = 0; j < nseclist; j++) {
SecMapping* smap = new SecMapping();
F.read_mapping_info(smap);
F.read_mapping_info(smap, ntmapping);
cmap->add_sec_map(smap);
}

Expand Down
17 changes: 17 additions & 0 deletions coreneuron/io/nrnsection_mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <vector>
#include <map>
#include <iostream>
#include <unordered_map>

namespace coreneuron {

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

/** list of segment ids */
std::vector<int> segment_ids;

/** map containing segment ids an its respective lfp factors */
std::unordered_map<int, double> lfp_factors;

/** @brief number of cells */
size_t size() const {
return mappingvec.size();
Expand Down Expand Up @@ -182,6 +189,16 @@ struct NrnThreadMappingInfo {
void add_cell_mapping(CellMapping* c) {
mappingvec.push_back(c);
}

/** @brief add a new segment */
void add_segment_id(const int segment_id) {
segment_ids.push_back(segment_id);
}

/** @brief add the lfp factor of a segment_id */
void add_segment_lfp_factor(const int segment_id, double factor) {
lfp_factors.insert({segment_id, factor});
}
};
} // namespace coreneuron

Expand Down

0 comments on commit f654226

Please sign in to comment.