lassoan
(Andras Lasso)
May 5, 2022, 9:58pm
2
You can read the ECG signals to a table node. See for example how it is done in the UltrasoundImage3D reader:
ecg = source.GetECG()
tableNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLTableNode", baseName+" ECG")
ecgSamples = self.safeArrayToNumpy(ecg.samples)
numberOfSamples = len(ecgSamples)
ecgTimestamps = np.arange(ecg.start_time, ecg.start_time+numberOfSamples*ecg.delta_time, ecg.delta_time)
trigTimes = self.safeArrayToNumpy(ecg.trig_times)
slicer.util.updateTableFromArray(tableNode, [ecgTimestamps, ecgSamples, trigTimes], ["time", "ecg", "triggerTimes"])
You can find some more plotting examples in the script repository and more explanations in the documentation (user guide , developer guide ).
If you want to display a view outside the view layout (I would not recommend that, because it is probably better to choose or create an appropriate view layout instead) then you can follow this example:
I could not reproduce any crash with the scripts above, so maybe the issue is how you fill the tables with real data. I’ve made a couple of fixes and improvement (fix order of views, fit plot to the view, adjust labeling, etc.) and this is the result:
[image]
The updated code:
def SetLayout(nChannels):
customLayout=(
"<layout type=\"horizontal\" split=\"true\">"
"<item>"
"<layout type=\"vertical\" split=\"true\">"
"<item>"
"<vi…
There is also a simpler example in the script repository .
To display a marker on the signal, I would recommend to add a series that has a single point or vertical line segment and add that to the chart.