Skip to content

Commit c4d4ab5

Browse files
committed
stimtree_explorer: create nice tab delimitted table
1 parent f827dc8 commit c4d4ab5

File tree

1 file changed

+45
-29
lines changed

1 file changed

+45
-29
lines changed

cmdline_tools/stimtree_explorer.cpp

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
using namespace hkLib;
2929

30-
void do_exploring(const hkTreeNode& root, int index, int ch) {
30+
void do_exploring(const hkTreeNode& root, int index, int /*ch*/) {
3131
//formatParamListExportIBW(root,parametersStimRoot,std::cout);
3232
auto headerList = hkLib::getHeaderList(parametersStimRoot, false, false, true);
3333
auto pList = hkLib::getParamList(root, parametersStimRoot, false, false, true);
@@ -39,20 +39,21 @@ void do_exploring(const hkTreeNode& root, int index, int ch) {
3939

4040
std::cout << "\nNum stim entries : " << root.Children.size() << '\n';
4141
const auto& stim_node = root.Children.at(index);
42-
StimulationRecord stim{ stim_node };
43-
std::cout << "entry name: " << stim.EntryName << ", file name: " << stim_node.getString(stFileName)
44-
<< "\nstartSegment: " << stim.DataStartSegment
45-
<< ", start time: " << stim.DataStartTime << '\n'
46-
<< "num ch: " << stim.Channels.size() << ", actual DAC channels: " << stim.ActualDacChannels << '\n';
47-
formatParamListExportIBW(stim_node,parametersStimulation,std::cout);
48-
42+
headerList = hkLib::getHeaderList(parametersStimulation, false, false, true);
43+
pList = hkLib::getParamList(stim_node, parametersStimulation, false, false, true);
44+
std::cout << "\nstimulation #" << index << ":\n";
45+
N = headerList.size();
46+
for (std::size_t i = 0; i < N; ++i) {
47+
std::cout << headerList.at(i) << '\t' << pList.at(i) << '\n';
48+
}
49+
4950
auto Nch = stim_node.Children.size();
5051
headerList= hkLib::getHeaderList(parametersChannel, false, false, true);
5152
std::vector<std::vector<std::string>> chData;
5253
chData.reserve(Nch);
5354
std::cout << "\nChannels";
5455
for (std::size_t i = 0; i < Nch; ++i) {
55-
std::cout << "\tChannel # " << i;
56+
std::cout << "\tChannel# " << i;
5657
chData.push_back(hkLib::getParamList(stim_node.Children.at(i), parametersChannel, false, false, true));
5758
}
5859
std::cout << '\n';
@@ -64,27 +65,42 @@ void do_exploring(const hkTreeNode& root, int index, int ch) {
6465
}
6566
std::cout << '\n';
6667
}
67-
68-
const auto& ch_node = stim.Channels.at(ch);
69-
std::cout << "ch# (from 0):" << ch //<< "\ndac ch: " << ch_node.DacChannel
70-
<< " mode: " << ch_node.DacMode << '\n' << "Linked: " << ch_node.LinkedChannel
71-
//<< "adc ch: " << ch_node.extractValue<int16_t>(chAdcChannel)
72-
//<< " mode: " << static_cast<int>(ch_node.getChar(chAdcMode)) << '\n'
73-
<< "\n#segments: " << ch_node.Segments.size() << "\nexploring:\n";
74-
75-
//formatParamListExportIBW(stim_node.Children.at(ch),parametersChannel,std::cout);
76-
int count{};
77-
for (const auto& segment : ch_node.Segments) {
78-
std::cout << "\nsegment " << ++count << "\n";
79-
formatParamListExportIBW(*segment.Node, parametersStimSegment, std::cout);
80-
81-
}
82-
std::cout << "\nContructing trace:\n";
83-
auto pts = stim.constructStimTrace(0);
84-
85-
for (const auto& p : pts) {
86-
std::cout << p.at(0) << '\t' << p.at(1) << '\n';
68+
69+
headerList = hkLib::getHeaderList(parametersStimSegment, false, false, true);
70+
N = headerList.size();
71+
bool more_segs = true;
72+
for(std::size_t seg_count = 0; more_segs; ++seg_count){
73+
more_segs = false;
74+
std::vector<std::vector<std::string>> seg_params(Nch);
75+
for(std::size_t ch_count{0}; ch_count < Nch; ++ch_count){
76+
const auto& channel_node = stim_node.Children.at(ch_count);
77+
if(seg_count < channel_node.Children.size()){
78+
more_segs = true;
79+
const auto& segment_node = channel_node.Children.at(seg_count);
80+
seg_params.at(ch_count) = hkLib::getParamList(segment_node, parametersStimSegment, false, false, true);
81+
}
82+
}
83+
if(!more_segs) break;
84+
//now print it:
85+
std::cout << "\nsegment# " << seg_count << ":\n";
86+
for(std::size_t i{0}; i < N; ++i) {
87+
std::cout << headerList.at(i);
88+
for(std::size_t ch_count{0}; ch_count < Nch; ++ch_count){
89+
std::cout << '\t';
90+
if(!seg_params.at(ch_count).empty()) {
91+
std::cout << seg_params.at(ch_count).at(i);
92+
}
93+
}
94+
std::cout << '\n';
95+
}
8796
}
97+
98+
// std::cout << "\nContructing trace:\n";
99+
// auto pts = stim.constructStimTrace(0);
100+
//
101+
// for (const auto& p : pts) {
102+
// std::cout << p.at(0) << '\t' << p.at(1) << '\n';
103+
// }
88104
}
89105

90106
int main(int argc, char** argv) {

0 commit comments

Comments
 (0)