Skip to content

Commit

Permalink
Fix spikes_converter (#41)
Browse files Browse the repository at this point in the history
- Skip the first line if its '/scatter' or starts by a comment '#'
- Allow the node_ids to be represented by doubles
- Fixed out-of-bounds error in spike sorting by ensuring index is within range of counts vector
  • Loading branch information
jorblancoa authored Dec 22, 2023
1 parent b95d1c8 commit ab89587
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/library/implementation_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ struct ParallelImplementation {
// first find number of spikes in each time window
for (const auto& st : spikevec_time) {
int idx = (int) (st - min_time) / bin_t;
if (idx >= numprocs) {
idx = numprocs - 1;
}
snd_cnts[idx]++;
}

Expand Down
10 changes: 5 additions & 5 deletions tools/converter/spikes_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ int main(int argc, char* argv[]) {
return -2;
}

// remove /scatter
// remove /scatter and # commented lines
std::string scatter;
getline(infile, scatter);
if (scatter != "/scatter") {
if (scatter != "/scatter" && scatter[0] != '#') {
infile.seekg(0, std::ios::beg);
}

std::vector<double> spike_timestamps;
std::vector<int> spike_node_ids;
double timestamp;
int node_id;

// Some files could have node_ids as double
double node_id;
while (infile >> timestamp >> node_id) {
spike_timestamps.push_back(timestamp);
spike_node_ids.push_back(node_id);
spike_node_ids.push_back(static_cast<int>(node_id));
}

// Create a spike file
Expand Down

0 comments on commit ab89587

Please sign in to comment.