Export Statistics to CSV

Hi,

I am trying to export the calculated statistics/table from the following code to CSV, but obviously the exportToCSVFile isn’t working properly. I don’t know what to replace self with or how to structure this function. Any help greatly appreciated!

## Set masterVolumeNode to first volume node, similar to export Script
masterVolumeNode = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLScalarVolumeNode')

segmentationNode = getNode('Segmentation')

# Compute segment volumes
resultsTableNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLTableNode')
import SegmentStatistics
segStatLogic = SegmentStatistics.SegmentStatisticsLogic()
segStatLogic.getParameterNode().SetParameter("Segmentation", segmentationNode.GetID())
segStatLogic.getParameterNode().SetParameter("ScalarVolume", masterVolumeNode.GetID())
segStatLogic.getParameterNode().SetParameter("LabelmapSegmentStatisticsPlugin.enabled","False")
segStatLogic.getParameterNode().SetParameter("ScalarVolumeSegmentStatisticsPlugin.voxel_count.enabled","False")
segStatLogic.getParameterNode().SetParameter("ScalarVolumeSegmentStatisticsPlugin.volume_mm3.enabled","False")
segStatLogic.computeStatistics()
segStatLogic.exportToTable(resultsTableNode)
segStatLogic.showTable(resultsTableNode)

testCSV = "/Users/pete/Desktop/test.csv"

segStatLogic.exportToCSVFile(self, testCSV)

Everything is correct except the last line. The correct syntax is:

segStatLogic.exportToCSVFile(testCSV)

So obvious, thank you again!