4Quant / LungStageAnnotator

The documentation and support for the LungStageAnnotator tool
http://4quant.com/LungStageAnnotator
2 stars 0 forks source link

When recreating tables the annotator crashes #82

Closed kmader closed 7 years ago

kmader commented 7 years ago

The annotator crashes with the following message when recreating a table

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "petct_annotator.py", line 2144, in exportToTable
    table.SetCellText(rowIndex, columnIndex, str(self.labelStats[i, k]))
KeyError: (3, u'PET_Min')
kmader commented 7 years ago

The problem is because some images (or some regions of some images) are not completely covered by both scans, this means when you try to analyze them the CT comes up with a positive voxel count and the PET does not. We fix this by filling in dummy values (-1) when the values are missing

                    if stat1.GetVoxelCount() > 0:
                        # add an entry to the LabelStats list
                        if first_node:

                            self.labelStats["Labels"].append(i)
....
                    else:
                        if i in self.labelStats["Labels"]: # if it already exists
                            self.labelStats[i, "{}_VoxelSize mm^3".format(grayName)] = cubicMMPerVoxel
                            self.labelStats[i, "{}_Min".format(grayName)] = -1
                            self.labelStats[i, "{}_Max".format(grayName)] = -1
                            self.labelStats[i, "{}_Mean".format(grayName)] = -1
                            self.labelStats[i, "{}_StdDev".format(grayName)] = -1