From 340e959763370970e58a08581ab127bfe116d189 Mon Sep 17 00:00:00 2001
From: Aaron Cuevas Lopez <aacuelo@teleco.upv.es>
Date: Fri, 13 Mar 2015 23:57:57 +0100
Subject: [PATCH] Make PSTH node use channel event data

---
 .../PSTH/PeriStimulusTimeHistogramNode.cpp    | 23 +++++++++----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/Source/Processors/PSTH/PeriStimulusTimeHistogramNode.cpp b/Source/Processors/PSTH/PeriStimulusTimeHistogramNode.cpp
index d65d36c06..669e10546 100644
--- a/Source/Processors/PSTH/PeriStimulusTimeHistogramNode.cpp
+++ b/Source/Processors/PSTH/PeriStimulusTimeHistogramNode.cpp
@@ -350,21 +350,20 @@ void PeriStimulusTimeHistogramNode::dumpTimestampEventToDisk(int64 softwareTS,in
 
 void PeriStimulusTimeHistogramNode::syncInternalDataStructuresWithSpikeSorter()
 {
-	ProcessorGraph *g = getProcessorGraph();
-	Array<GenericProcessor*> p = g->getListOfProcessors();
-	for (int k=0;k<p.size();k++)
+	Array<Electrode*> electrodes;
+	
+	for (int k=0;k<eventChannels.size();k++)
 	{
-		if (p[k]->getName() == "Spike Sorter")
+		if ((eventChannels[k]->type == ELECTRODE_CHANNEL) && 
+			( static_cast<SpikeChannel*>(eventChannels[k]->extraData.get())->dataType == SpikeChannel::Sorted ))
 		{
-			SpikeSorter *node = (SpikeSorter*)p[k];
-			Array<Electrode*> electrodes = node->getElectrodes();
-
-			// for each electrode, verify that 
-			// 1. We have it in our internal structure 
-			// 2. All channels match
-			// 3. We have all sorted unit information
-			trialCircularBuffer->syncInternalDataStructuresWithSpikeSorter(electrodes);
+			electrodes.add(static_cast<Electrode*>(eventChannels[k]->extraData->dataPtr));
 		}
+		// for each electrode, verify that 
+		// 1. We have it in our internal structure 
+		// 2. All channels match
+		// 3. We have all sorted unit information
+		trialCircularBuffer->syncInternalDataStructuresWithSpikeSorter(electrodes);
 	}
 }
 
-- 
GitLab