Esempio n. 1
0
    def saveReport(self, currentValuesDict):
        """ Save a JSON text file with the current values of the GUI stored in a dictionary.
        It also saves the current enhanced and labelmap volumes
        :param currentValuesDict: dictionary of values
        :return: file where the report was stored
        """
        p = os.path.join(self.getCurrentDataFolder(), "report.json")
        with open(p, "w+b") as f:
            json.dump(currentValuesDict, f)

        # Save the labelmap
        if self.currentLabelmapVolume.GetStorageNode() is None:
            SlicerUtil.saveNewNode(
                self.currentLabelmapVolume,
                os.path.join(self.getCurrentDataFolder(),
                             self.currentLabelmapVolume.GetName() + ".nrrd"))
        else:
            self.currentLabelmapVolume.GetStorageNode().WriteData(
                self.currentLabelmapVolume)

        # Save the enhanced volume
        if self.getEnhancedVolume().GetStorageNode() is None:
            SlicerUtil.saveNewNode(
                self.currentEnhancedVolume,
                os.path.join(self.getCurrentDataFolder(),
                             self.currentEnhancedVolume.GetName() + ".nrrd"))
        else:
            self.currentEnhancedVolume.GetStorageNode().WriteData(
                self.currentEnhancedVolume)

        self.isCurrentReportSaved = True
        return p