How to use the pypx.utils.dataPath function in pypx

To help you get started, we’ve selected a few pypx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FNNDSC / pypx / pypx / listen.py View on Github external
def processImage(self, dcm_info, log_file, error_file, series_directory, tmp_file):
        # get information of interest
        image_uid = self.processDicomField(dcm_info, "SOPInstanceUID")
        image_instance_number = self.processDicomField(dcm_info, "InstanceNumber")

        # log it
        log_file.write('          SOPInstanceUID: ' + image_uid + '\n')
        log_file.write('          InstanceNumber: ' + image_instance_number + '\n')

        image_path = pypx.utils.dataPath(series_directory, image_instance_number, image_uid)

        if not os.path.exists(image_path):
            try:
                shutil.copy2(tmp_file, image_path)
            except OSError as e:
                errorfile = open(error_file, 'w')
                errorfile.write('Copy ' + tmp_file + ' to ' + image_path + '\n')
                errorfile.write('Error number: ' + str(e.errno) + '\n')
                errorfile.write('File name: ' + e.filename + '\n')
                errorfile.write('Error message: ' + e.strerror + '\n')
                errorfile.close()

        if not os.path.exists(image_path):
            errorfile = open(error_file, 'w')
            errorfile.write('File doesn\'t exist:' + image_path + '\n')
            errorfile.close()