import os
import pickle
from PIL import Image


class PatientToImageFolder:

    def __init__(self, sourceFolder):
        self.sourceFolder = sourceFolder
        # How many patient with contrast SA for each pathology (used for classification)
        self.contrastSApathologyDict = {}
        # How many patient with contrast LA for each pathology (used for classification)
        self.contrastCH2pathologyDict = {}
        self.contrastCH3pathologyDict = {}
        self.contrastCH4pathologyDict = {}
        # How many patient with SA image (used for autoencoder training)
        self.totalSaImagePatientNum = 0
        self.curSaImagePatientNum = 0
        # How many patient with LA image (used for autoencoder training)
        self.totalCH2ImagePatientNum = 0
        self.curCH2ImagePatientNum = 0
        self.totalCH3ImagePatientNum = 0
        self.curCH3ImagePatientNum = 0
        self.totalCH4ImagePatientNum = 0
        self.curCH4ImagePatientNum = 0

        self.curContrastSaImagePatientNum = {}
        self.curContrastCH2ImagePatientNum = {}
        self.curContrastCH3ImagePatientNum = {}
        self.curContrastCH4ImagePatientNum = {}

        self.collectInfo()

    def collectInfo(self):
        for file in os.listdir(self.sourceFolder):
            if ".p" in file:
                tmpPat = pickle.load(open(os.path.join(self.sourceFolder, file), 'rb'))
                patho = tmpPat.pathology.strip()
                if "U18" in patho or "sport" in patho or "Normal" in patho:
                    continue
                # elif "sport" in patho:
                #     patho = "Sport"
                # elif "Normal" not in patho and "HCM" not in patho:
                #     patho = "Other"
                if tmpPat.normalSaImages is not None:
                    self.totalSaImagePatientNum += 1
                if (tmpPat.contrastSaImages is not None and tmpPat.contrastLaImages.ch2Images is not None and
                        tmpPat.contrastLaImages.ch3Images is not None and tmpPat.contrastLaImages.ch4Images is not None):
                    if patho in self.contrastSApathologyDict:
                        self.contrastSApathologyDict[patho] += 1
                    else:
                        self.contrastSApathologyDict[patho] = 1
                    if patho in self.contrastCH2pathologyDict:
                        self.contrastCH2pathologyDict[patho] += 1
                    else:
                        self.contrastCH2pathologyDict[patho] = 1
                    if patho in self.contrastCH3pathologyDict:
                        self.contrastCH3pathologyDict[patho] += 1
                    else:
                        self.contrastCH3pathologyDict[patho] = 1
                    if patho in self.contrastCH4pathologyDict:
                        self.contrastCH4pathologyDict[patho] += 1
                    else:
                        self.contrastCH4pathologyDict[patho] = 1
                if tmpPat.normalLaImages.ch2Images is not None:
                    self.totalCH2ImagePatientNum += 1
                if tmpPat.normalLaImages.ch3Images is not None:
                    self.totalCH3ImagePatientNum += 1
                if tmpPat.normalLaImages.ch4Images is not None:
                    self.totalCH4ImagePatientNum += 1

        for key in self.contrastSApathologyDict:
            self.curContrastSaImagePatientNum[key] = 0
        for key in self.contrastCH2pathologyDict:
            self.curContrastCH2ImagePatientNum[key] = 0
        for key in self.contrastCH3pathologyDict:
            self.curContrastCH3ImagePatientNum[key] = 0
        for key in self.contrastCH4pathologyDict:
            self.curContrastCH4ImagePatientNum[key] = 0

    def convertImage(self, image_2d):
        # if image_2d.min() > 254:
        #     return None
        # Converting image from numpy array to PIL.
        pil_img = Image.fromarray(image_2d)
        if pil_img.getbbox() is None:
            return None
        return pil_img

    def createAutoEncoderImageFolderStructure(self, folderName):
        autoFolder = os.path.join(os.path.dirname(self.sourceFolder), folderName)
        autoTrainingFolder = os.path.join(autoFolder, "training")
        autoTestFolder = os.path.join(autoFolder, "test")

        os.makedirs(autoTrainingFolder)
        os.makedirs(autoTestFolder)

        return autoFolder, autoTrainingFolder, autoTestFolder

    def createClassificationImageFolderStructure(self, folderName):
        classFolder = os.path.join(os.path.dirname(self.sourceFolder), folderName)
        classTrainingFolder = os.path.join(classFolder, "training")
        classValidationFolder = os.path.join(classFolder, "validation")
        classTestFolder = os.path.join(classFolder, "test")
        classAllFolder = os.path.join(classFolder, 'all')

        os.makedirs(classTrainingFolder)
        os.makedirs(classValidationFolder)
        os.makedirs(classTestFolder)
        os.makedirs(classAllFolder)

        return classFolder, classTrainingFolder, classValidationFolder, classTestFolder, classAllFolder

    def saveImageForClassification(self, image, patientId, patho, testFolder, validationFolder, trainingFolder,
                                   axis, imPatho, curPatientNum, allFolder, pathologyDict):
        pil_img = self.convertImage(image[:, :])
        if pil_img is not None:
            if (curPatientNum[patho] <= pathologyDict[patho] * 0.075 or
                    (pathologyDict[patho] * 0.85 <= curPatientNum[patho] <= pathologyDict[patho] * 0.925)):
                imFolder = os.path.join(testFolder, imPatho)
                os.makedirs(imFolder, exist_ok=True)
                patientFolder = os.path.join(self.patientSeperatedTestFolder, imPatho + '_' + patientId)
                os.makedirs(patientFolder, exist_ok=True)
            elif ((pathologyDict[patho] * 0.075 <= curPatientNum[patho] <= pathologyDict[patho] * 0.15) or
                  curPatientNum[patho] >= int(pathologyDict[patho] * 0.925)):
                imFolder = os.path.join(validationFolder, imPatho)
                os.makedirs(imFolder, exist_ok=True)
                patientFolder = os.path.join(self.patientSeperatedValidationFolder, imPatho + '_' + patientId)
                os.makedirs(patientFolder, exist_ok=True)
            else:
                imFolder = os.path.join(trainingFolder, imPatho)
                os.makedirs(imFolder, exist_ok=True)
                patientFolder = os.path.join(self.patientSeperatedTrainingFolder, imPatho + '_' + patientId)
                os.makedirs(patientFolder, exist_ok=True)
            axisFolder = os.path.join(patientFolder, axis)
            os.makedirs(axisFolder, exist_ok=True)
            pil_img.save(os.path.join(imFolder, "{}.png".format(patientId)))
            # pil_img.save(os.path.join(allFolder, "{}.png".format(patientId)))
            pil_img.save(os.path.join(axisFolder, "{}.png".format(patientId)))
            file = open(os.path.join(patientFolder, "pathology.txt"), "w")
            file.write("{}\n".format(patho))
            file.close()

    def saveImageForAutoEncoder(self, images, patientId, testFolder, trainingFolder,
                                curPatientNum, totalPatientNum, sliceIdx, frameIdx):
        if sliceIdx is not None:
            pil_img = self.convertImage(images[sliceIdx, frameIdx, :, :])
        else:
            pil_img = self.convertImage(images[frameIdx, :, :])
        if pil_img is not None:
            if (curPatientNum <= totalPatientNum * 0.1
                    or curPatientNum >= int(totalPatientNum * 0.9)):
                if sliceIdx is not None:
                    pil_img.save(os.path.join(testFolder, "{}_{}_{}.png".format(patientId, sliceIdx, frameIdx)))
                else:
                    pil_img.save(os.path.join(testFolder, "{}_{}.png".format(patientId, frameIdx)))
            else:
                if sliceIdx is not None:
                    pil_img.save(os.path.join(trainingFolder, "{}_{}_{}.png".format(patientId, sliceIdx, frameIdx)))
                else:
                    pil_img.save(os.path.join(trainingFolder, "{}_{}.png".format(patientId, frameIdx)))

    def createImageFolderDatasets(self):
        subfol = "only_abnormal"
        # autoSaFolder, autoSaTrainingFolder, autoSaTestFolder = self.createAutoEncoderImageFolderStructure(
        #     "SaAutoEncoder")

        (contrastSaFolder, contrastSaTrainingFolder,
         contrastSaValidationFolder, contrastSaTestFolder,
         contrastSaAllFolder) = self.createClassificationImageFolderStructure(
            "{}/SaClassification".format(subfol))

        # autoCH2Folder, autoCH2TrainingFolder, autoCH2TestFolder = self.createAutoEncoderImageFolderStructure(
        #     "CH2AutoEncoder")

        (contrastCH2Folder, contrastCH2TrainingFolder,
         contrastCH2ValidationFolder, contrastCH2TestFolder,
         contrastCH2AllFolder) = self.createClassificationImageFolderStructure(
            "{}/CH2Classification".format(subfol))

        # autoCH3Folder, autoCH3TrainingFolder, autoCH3TestFolder = self.createAutoEncoderImageFolderStructure(
        #     "CH3AutoEncoder")

        (contrastCH3Folder, contrastCH3TrainingFolder,
         contrastCH3ValidationFolder, contrastCH3TestFolder,
         contrastCH3AllFolder) = self.createClassificationImageFolderStructure(
            "{}/CH3Classification".format(subfol))

        # autoCH4Folder, autoCH4TrainingFolder, autoCH4TestFolder = self.createAutoEncoderImageFolderStructure(
        #     "CH4AutoEncoder")

        (contrastCH4Folder, contrastCH4TrainingFolder,
         contrastCH4ValidationFolder, contrastCH4TestFolder,
         contrastCH4AllFolder) = self.createClassificationImageFolderStructure(
            "{}/CH4Classification".format(subfol))

        self.patientSeperatedFolder = os.path.join(os.path.dirname(self.sourceFolder), '{}/patients'.format(subfol))
        os.makedirs(self.patientSeperatedFolder)
        self.patientSeperatedTrainingFolder = os.path.join(self.patientSeperatedFolder, 'training')
        self.patientSeperatedValidationFolder = os.path.join(self.patientSeperatedFolder, 'validation')
        self.patientSeperatedTestFolder = os.path.join(self.patientSeperatedFolder, 'test')
        os.makedirs(self.patientSeperatedTrainingFolder)
        os.makedirs(self.patientSeperatedValidationFolder)
        os.makedirs(self.patientSeperatedTestFolder)

        for file in os.listdir(self.sourceFolder):
            if ".p" in file:
                tmpPat = pickle.load(open(os.path.join(self.sourceFolder, file), 'rb'))
                patho = tmpPat.pathology.strip()
                if "U18" in patho or "sport" in patho or "Normal" in patho:
                    continue
                # elif "sport" in patho:
                #     patho = "Sport"
                # elif "Normal" not in patho and "HCM" not in patho:
                #     patho = "Other"

                imPatho = patho
                # if "sport" in patho:
                #     imPatho = "Sport"
                # if "Normal" not in patho:
                #     imPatho = "Hypertrophic"

                classificationReady = False
                if (tmpPat.contrastSaImages is not None and tmpPat.contrastLaImages.ch2Images is not None and
                        tmpPat.contrastLaImages.ch3Images is not None and tmpPat.contrastLaImages.ch4Images is not None):
                    classificationReady = True

                # if tmpPat.normalSaImages is not None:
                #     for i in range(tmpPat.normalSaImages.shape[0]):
                #         for j in range(tmpPat.normalSaImages.shape[1]):
                #             self.saveImageForAutoEncoder(tmpPat.normalSaImages, tmpPat.patientID, autoSaTestFolder,
                #                                          autoSaTrainingFolder, self.curSaImagePatientNum,
                #                                          self.totalSaImagePatientNum, i, j)
                #     self.curSaImagePatientNum += 1

                if classificationReady:
                    self.saveImageForClassification(tmpPat.contrastSaImages, tmpPat.patientID, patho,
                                                    contrastSaTestFolder, contrastSaValidationFolder,
                                                    contrastSaTrainingFolder, 'SA', imPatho,
                                                    self.curContrastSaImagePatientNum, contrastSaAllFolder,
                                                    self.contrastSApathologyDict)
                    self.curContrastSaImagePatientNum[patho] += 1

                # if tmpPat.normalLaImages.ch2Images is not None:
                #     for i in range(tmpPat.normalLaImages.ch2Images.shape[0]):
                #         self.saveImageForAutoEncoder(tmpPat.normalLaImages.ch2Images, tmpPat.patientID,
                #                                      autoCH2TestFolder,
                #                                      autoCH2TrainingFolder, self.curCH2ImagePatientNum,
                #                                      self.totalCH2ImagePatientNum, None, i)
                #     self.curCH2ImagePatientNum += 1

                if classificationReady:
                    self.saveImageForClassification(tmpPat.contrastLaImages.ch2Images, tmpPat.patientID, patho,
                                                    contrastCH2TestFolder, contrastCH2ValidationFolder,
                                                    contrastCH2TrainingFolder, 'CH2', imPatho,
                                                    self.curContrastCH2ImagePatientNum, contrastCH2AllFolder,
                                                    self.contrastCH2pathologyDict)
                    self.curContrastCH2ImagePatientNum[patho] += 1

                # if tmpPat.normalLaImages.ch3Images is not None:
                #     for i in range(tmpPat.normalLaImages.ch3Images.shape[0]):
                #         self.saveImageForAutoEncoder(tmpPat.normalLaImages.ch3Images, tmpPat.patientID,
                #                                      autoCH3TestFolder,
                #                                      autoCH3TrainingFolder, self.curCH3ImagePatientNum,
                #                                      self.totalCH3ImagePatientNum, None, i)
                #     self.curCH3ImagePatientNum += 1

                if classificationReady:
                    self.saveImageForClassification(tmpPat.contrastLaImages.ch3Images, tmpPat.patientID, patho,
                                                    contrastCH3TestFolder, contrastCH3ValidationFolder,
                                                    contrastCH3TrainingFolder, 'CH3', imPatho,
                                                    self.curContrastCH3ImagePatientNum, contrastCH3AllFolder,
                                                    self.contrastCH3pathologyDict)
                    self.curContrastCH3ImagePatientNum[patho] += 1

                # if tmpPat.normalLaImages.ch4Images is not None:
                #     for i in range(tmpPat.normalLaImages.ch4Images.shape[0]):
                #         self.saveImageForAutoEncoder(tmpPat.normalLaImages.ch4Images, tmpPat.patientID,
                #                                      autoCH4TestFolder,
                #                                      autoCH4TrainingFolder, self.curCH4ImagePatientNum,
                #                                      self.totalCH4ImagePatientNum, None, i)
                #     self.curCH4ImagePatientNum += 1

                if classificationReady:
                    self.saveImageForClassification(tmpPat.contrastLaImages.ch4Images, tmpPat.patientID, patho,
                                                    contrastCH4TestFolder, contrastCH4ValidationFolder,
                                                    contrastCH4TrainingFolder, 'CH4', imPatho,
                                                    self.curContrastCH4ImagePatientNum, contrastCH4AllFolder,
                                                    self.contrastCH4pathologyDict)
                    self.curContrastCH4ImagePatientNum[patho] += 1

        self.createLabelFileFromPathoDict(contrastSaFolder, self.contrastSApathologyDict)
        self.createLabelFileFromPathoDict(contrastCH2Folder, self.contrastCH2pathologyDict)
        self.createLabelFileFromPathoDict(contrastCH3Folder, self.contrastCH3pathologyDict)
        self.createLabelFileFromPathoDict(contrastCH4Folder, self.contrastCH4pathologyDict)

    def createLabelFileFromPathoDict(self, destination, pathoDict):
        file = open(os.path.join(destination, "pathologies.txt"), "w")
        for key in pathoDict:
            file.write("{}\n".format(key))
        file.close()


if __name__ == "__main__":
    sourceFolder = 'D:/BME/7felev/Szakdolgozat/whole_dataset/filtered_data'
    imageFolderArranger = PatientToImageFolder(sourceFolder)
    imageFolderArranger.createImageFolderDatasets()

[((35, 20, 35, 49), 'os.listdir', 'os.listdir', ({(35, 31, 35, 48): 'self.sourceFolder'}, {}), '(self.sourceFolder)', False, 'import os\n'), ((85, 18, 85, 43), 'PIL.Image.fromarray', 'Image.fromarray', ({(85, 34, 85, 42): 'image_2d'}, {}), '(image_2d)', False, 'from PIL import Image\n'), ((92, 29, 92, 65), 'os.path.join', 'os.path.join', ({(92, 42, 92, 52): 'autoFolder', (92, 54, 92, 64): '"""training"""'}, {}), "(autoFolder, 'training')", False, 'import os\n'), ((93, 25, 93, 57), 'os.path.join', 'os.path.join', ({(93, 38, 93, 48): 'autoFolder', (93, 50, 93, 56): '"""test"""'}, {}), "(autoFolder, 'test')", False, 'import os\n'), ((95, 8, 95, 39), 'os.makedirs', 'os.makedirs', ({(95, 20, 95, 38): 'autoTrainingFolder'}, {}), '(autoTrainingFolder)', False, 'import os\n'), ((96, 8, 96, 35), 'os.makedirs', 'os.makedirs', ({(96, 20, 96, 34): 'autoTestFolder'}, {}), '(autoTestFolder)', False, 'import os\n'), ((102, 30, 102, 67), 'os.path.join', 'os.path.join', ({(102, 43, 102, 54): 'classFolder', (102, 56, 102, 66): '"""training"""'}, {}), "(classFolder, 'training')", False, 'import os\n'), ((103, 32, 103, 71), 'os.path.join', 'os.path.join', ({(103, 45, 103, 56): 'classFolder', (103, 58, 103, 70): '"""validation"""'}, {}), "(classFolder, 'validation')", False, 'import os\n'), ((104, 26, 104, 59), 'os.path.join', 'os.path.join', ({(104, 39, 104, 50): 'classFolder', (104, 52, 104, 58): '"""test"""'}, {}), "(classFolder, 'test')", False, 'import os\n'), ((105, 25, 105, 57), 'os.path.join', 'os.path.join', ({(105, 38, 105, 49): 'classFolder', (105, 51, 105, 56): '"""all"""'}, {}), "(classFolder, 'all')", False, 'import os\n'), ((107, 8, 107, 40), 'os.makedirs', 'os.makedirs', ({(107, 20, 107, 39): 'classTrainingFolder'}, {}), '(classTrainingFolder)', False, 'import os\n'), ((108, 8, 108, 42), 'os.makedirs', 'os.makedirs', ({(108, 20, 108, 41): 'classValidationFolder'}, {}), '(classValidationFolder)', False, 'import os\n'), ((109, 8, 109, 36), 'os.makedirs', 'os.makedirs', ({(109, 20, 109, 35): 'classTestFolder'}, {}), '(classTestFolder)', False, 'import os\n'), ((110, 8, 110, 35), 'os.makedirs', 'os.makedirs', ({(110, 20, 110, 34): 'classAllFolder'}, {}), '(classAllFolder)', False, 'import os\n'), ((198, 8, 198, 48), 'os.makedirs', 'os.makedirs', ({(198, 20, 198, 47): 'self.patientSeperatedFolder'}, {}), '(self.patientSeperatedFolder)', False, 'import os\n'), ((199, 46, 199, 99), 'os.path.join', 'os.path.join', ({(199, 59, 199, 86): 'self.patientSeperatedFolder', (199, 88, 199, 98): '"""training"""'}, {}), "(self.patientSeperatedFolder, 'training')", False, 'import os\n'), ((200, 48, 200, 103), 'os.path.join', 'os.path.join', ({(200, 61, 200, 88): 'self.patientSeperatedFolder', (200, 90, 200, 102): '"""validation"""'}, {}), "(self.patientSeperatedFolder, 'validation')", False, 'import os\n'), ((201, 42, 201, 91), 'os.path.join', 'os.path.join', ({(201, 55, 201, 82): 'self.patientSeperatedFolder', (201, 84, 201, 90): '"""test"""'}, {}), "(self.patientSeperatedFolder, 'test')", False, 'import os\n'), ((202, 8, 202, 56), 'os.makedirs', 'os.makedirs', ({(202, 20, 202, 55): 'self.patientSeperatedTrainingFolder'}, {}), '(self.patientSeperatedTrainingFolder)', False, 'import os\n'), ((203, 8, 203, 58), 'os.makedirs', 'os.makedirs', ({(203, 20, 203, 57): 'self.patientSeperatedValidationFolder'}, {}), '(self.patientSeperatedValidationFolder)', False, 'import os\n'), ((204, 8, 204, 52), 'os.makedirs', 'os.makedirs', ({(204, 20, 204, 51): 'self.patientSeperatedTestFolder'}, {}), '(self.patientSeperatedTestFolder)', False, 'import os\n'), ((206, 20, 206, 49), 'os.listdir', 'os.listdir', ({(206, 31, 206, 48): 'self.sourceFolder'}, {}), '(self.sourceFolder)', False, 'import os\n'), ((91, 34, 91, 68), 'os.path.dirname', 'os.path.dirname', ({(91, 50, 91, 67): 'self.sourceFolder'}, {}), '(self.sourceFolder)', False, 'import os\n'), ((101, 35, 101, 69), 'os.path.dirname', 'os.path.dirname', ({(101, 51, 101, 68): 'self.sourceFolder'}, {}), '(self.sourceFolder)', False, 'import os\n'), ((135, 25, 135, 58), 'os.path.join', 'os.path.join', ({(135, 38, 135, 51): 'patientFolder', (135, 53, 135, 57): 'axis'}, {}), '(patientFolder, axis)', False, 'import os\n'), ((136, 12, 136, 50), 'os.makedirs', 'os.makedirs', (), '', False, 'import os\n'), ((197, 51, 197, 85), 'os.path.dirname', 'os.path.dirname', ({(197, 67, 197, 84): 'self.sourceFolder'}, {}), '(self.sourceFolder)', False, 'import os\n'), ((298, 20, 298, 64), 'os.path.join', 'os.path.join', ({(298, 33, 298, 44): 'destination', (298, 46, 298, 63): '"""pathologies.txt"""'}, {}), "(destination, 'pathologies.txt')", False, 'import os\n'), ((120, 27, 120, 60), 'os.path.join', 'os.path.join', ({(120, 40, 120, 50): 'testFolder', (120, 52, 120, 59): 'imPatho'}, {}), '(testFolder, imPatho)', False, 'import os\n'), ((121, 16, 121, 52), 'os.makedirs', 'os.makedirs', (), '', False, 'import os\n'), ((122, 32, 122, 104), 'os.path.join', 'os.path.join', ({(122, 45, 122, 76): 'self.patientSeperatedTestFolder', (122, 78, 122, 103): "imPatho + '_' + patientId"}, {}), "(self.patientSeperatedTestFolder, imPatho + '_' + patientId)", False, 'import os\n'), ((123, 16, 123, 57), 'os.makedirs', 'os.makedirs', (), '', False, 'import os\n'), ((140, 24, 140, 68), 'os.path.join', 'os.path.join', ({(140, 37, 140, 50): 'patientFolder', (140, 52, 140, 67): '"""pathology.txt"""'}, {}), "(patientFolder, 'pathology.txt')", False, 'import os\n'), ((126, 27, 126, 66), 'os.path.join', 'os.path.join', ({(126, 40, 126, 56): 'validationFolder', (126, 58, 126, 65): 'imPatho'}, {}), '(validationFolder, imPatho)', False, 'import os\n'), ((127, 16, 127, 52), 'os.makedirs', 'os.makedirs', (), '', False, 'import os\n'), ((128, 32, 128, 110), 'os.path.join', 'os.path.join', ({(128, 45, 128, 82): 'self.patientSeperatedValidationFolder', (128, 84, 128, 109): "imPatho + '_' + patientId"}, {}), "(self.patientSeperatedValidationFolder, imPatho + '_' + patientId)", False, 'import os\n'), ((129, 16, 129, 57), 'os.makedirs', 'os.makedirs', (), '', False, 'import os\n'), ((131, 27, 131, 64), 'os.path.join', 'os.path.join', ({(131, 40, 131, 54): 'trainingFolder', (131, 56, 131, 63): 'imPatho'}, {}), '(trainingFolder, imPatho)', False, 'import os\n'), ((132, 16, 132, 52), 'os.makedirs', 'os.makedirs', (), '', False, 'import os\n'), ((133, 32, 133, 108), 'os.path.join', 'os.path.join', ({(133, 45, 133, 80): 'self.patientSeperatedTrainingFolder', (133, 82, 133, 107): "imPatho + '_' + patientId"}, {}), "(self.patientSeperatedTrainingFolder, imPatho + '_' + patientId)", False, 'import os\n'), ((134, 16, 134, 57), 'os.makedirs', 'os.makedirs', (), '', False, 'import os\n'), ((37, 42, 37, 79), 'os.path.join', 'os.path.join', ({(37, 55, 37, 72): 'self.sourceFolder', (37, 74, 37, 78): 'file'}, {}), '(self.sourceFolder, file)', False, 'import os\n'), ((208, 42, 208, 79), 'os.path.join', 'os.path.join', ({(208, 55, 208, 72): 'self.sourceFolder', (208, 74, 208, 78): 'file'}, {}), '(self.sourceFolder, file)', False, 'import os\n')]