def process_cnn_data(self, images, aux_data, num_unique_stock_ids, num_unique_image_types, num_unique_time_days, image_size, keras_model_type, data_augmentation, data_augmentation_test, montage_image_number, full_montage_image_size, output_autoencoder_model_file_path, log_file_path):
    if (log_file_path is not None):
        sys.stderr = open(log_file_path, 'a')

    def eprint(*args, **kwargs):
        print(*args, file=sys.stderr, **kwargs)
    trainX = []
    testX = []
    trainY = []
    testY = []
    datagen = self.get_imagedatagenerator()
    datagen.fit(images)
    images = datagen.standardize(images)
    aux_data['value'] = aux_data['value'].astype(float)
    output_image_file = aux_data['output_image_file'].tolist()
    if (keras_model_type == 'densenet121_lstm_imagenet'):
        images = images.reshape((num_unique_stock_ids * num_unique_image_types), num_unique_time_days, input_image_size, input_image_size, 3)
        (train_aux_data, test_aux_data, train_images, test_images) = train_test_split(aux_data, images, test_size=0.2)
        trainX_length = len(train_images)
        testX_length = len(test_images)
        train_images = train_images.reshape((trainX_length * num_unique_time_days), input_image_size, input_image_size, 3)
        test_images = test_images.reshape((testX_length * num_unique_time_days), input_image_size, input_image_size, 3)
        trainX_length_flat = len(train_images)
        test_images = datagen.standardize(test_images)
        testX_resized = []
        for img in test_images:
            testX_resized.append(cv2.resize(img, (image_size, image_size)))
        test_images = np.array(testX_resized)
        test_images = test_images.reshape((data_augmentation_test * testX_length), num_unique_time_days, image_size, image_size, 3)
        trainX_resized = []
        for img in train_images:
            trainX_resized.append(cv2.resize(img, (image_size, image_size)))
        train_images = np.array(trainX_resized)
        train_images = train_images.reshape((data_augmentation * trainX_length), num_unique_time_days, image_size, image_size, 3)
    else:
        images = self.create_montages(images, montage_image_number, image_size, full_montage_image_size)
        (encoder, decoder, autoencoder) = self.build_autoencoder(full_montage_image_size, full_montage_image_size, 3)
        opt = Adam(lr=0.001)
        autoencoder.compile(loss='mse', optimizer=opt)
        (train_aux_data, test_aux_data, train_images, test_images) = train_test_split(aux_data, images, test_size=0.2)
        checkpoint = ModelCheckpoint(filepath=output_autoencoder_model_file_path, monitor='loss', verbose=1, save_best_only=True, mode='min', save_frequency=1, save_weights_only=False)
        callbacks_list = [checkpoint]
        H = autoencoder.fit(train_images, train_images, validation_data=(test_images, test_images), epochs=25, batch_size=32, callbacks=callbacks_list)
        decoded = autoencoder.predict(images)
        output_image_counter = 0
        for image in decoded:
            cv2.imwrite(output_image_file[output_image_counter], (image * 255))
            output_image_counter += 1
        (train_aux_data, test_aux_data, train_images, test_images) = train_test_split(aux_data, decoded, test_size=0.2)
    stock_id_binarizer = LabelBinarizer().fit(aux_data['stock_id'])
    train_stock_id_categorical = stock_id_binarizer.transform(train_aux_data['stock_id'])
    test_stock_id_categorical = stock_id_binarizer.transform(test_aux_data['stock_id'])
    accession_id_binarizer = LabelBinarizer().fit(aux_data['accession_id'])
    train_accession_id_categorical = accession_id_binarizer.transform(train_aux_data['accession_id'])
    test_accession_id_categorical = accession_id_binarizer.transform(test_aux_data['accession_id'])
    female_id_binarizer = LabelBinarizer().fit(aux_data['female_id'])
    train_female_id_categorical = female_id_binarizer.transform(train_aux_data['female_id'])
    test_female_id_categorical = female_id_binarizer.transform(test_aux_data['female_id'])
    male_id_binarizer = LabelBinarizer().fit(aux_data['male_id'])
    train_male_id_categorical = male_id_binarizer.transform(train_aux_data['male_id'])
    test_male_id_categorical = male_id_binarizer.transform(test_aux_data['male_id'])
    continuous = [col for col in aux_data.columns if ('aux_trait_' in col)]
    cs = MinMaxScaler()
    if (len(continuous) > 0):
        trainContinuous = cs.fit_transform(train_aux_data[continuous])
        testContinuous = cs.transform(test_aux_data[continuous])
        trainX = trainContinuous
        testX = testContinuous
    else:
        trainX = []
        testX = []
    trainx = np.array(trainX)
    testx = np.array(testX)
    max_label = aux_data['value'].max()
    trainY = (train_aux_data['value'] / max_label)
    testY = (test_aux_data['value'] / max_label)
    train_genotype_files = train_aux_data['genotype_file'].tolist()
    test_genotype_files = test_aux_data['genotype_file'].tolist()
    train_genotype_data = []
    for f in train_genotype_files:
        if (log_file_path is not None):
            eprint(f)
        else:
            print(f)
        if (pd.isna(f) is False):
            geno_data = pd.read_csv(f, sep='\t', header=None, na_values='NA')
            train_genotype_data.append(np.array(geno_data.iloc[:, 0]))
    test_genotype_data = []
    for f in test_genotype_files:
        if (log_file_path is not None):
            eprint(f)
        else:
            print(f)
        if (pd.isna(f) is False):
            geno_data = pd.read_csv(f, sep='\t', header=None, na_values='NA')
            test_genotype_data.append(np.array(geno_data.iloc[:, 0]))
    train_genotype_data = np.array(train_genotype_data)
    test_genotype_data = np.array(test_genotype_data)
    eprint(train_genotype_data)
    eprint(testX)
    eprint(trainX)
    return (test_images, np.array(testX), testY.to_numpy(), test_genotype_data, train_images, np.array(trainX), trainY.to_numpy(), train_genotype_data)
def process_cnn_data(self, images, aux_data, num_unique_stock_ids, num_unique_image_types, num_unique_time_days, image_size, keras_model_type, data_augmentation, data_augmentation_test, montage_image_number, full_montage_image_size, output_autoencoder_model_file_path, log_file_path):
    if (log_file_path is not None):
        sys.stderr = open(log_file_path, 'a')

    def eprint(*args, **kwargs):
        print(*args, file=sys.stderr, **kwargs)
    trainX = []
    testX = []
    trainY = []
    testY = []
    datagen = self.get_imagedatagenerator()
    datagen.fit(images)
    images = datagen.standardize(images)
    aux_data['value'] = aux_data['value'].astype(float)
    output_image_file = aux_data['output_image_file'].tolist()
    if (keras_model_type == 'densenet121_lstm_imagenet'):
        images = images.reshape((num_unique_stock_ids * num_unique_image_types), num_unique_time_days, input_image_size, input_image_size, 3)
        (train_aux_data, test_aux_data, train_images, test_images) = train_test_split(aux_data, images, test_size=0.2)
        trainX_length = len(train_images)
        testX_length = len(test_images)
        train_images = train_images.reshape((trainX_length * num_unique_time_days), input_image_size, input_image_size, 3)
        test_images = test_images.reshape((testX_length * num_unique_time_days), input_image_size, input_image_size, 3)
        trainX_length_flat = len(train_images)
        test_images = datagen.standardize(test_images)
        testX_resized = []
        for img in test_images:
            testX_resized.append(cv2.resize(img, (image_size, image_size)))
        test_images = np.array(testX_resized)
        test_images = test_images.reshape((data_augmentation_test * testX_length), num_unique_time_days, image_size, image_size, 3)
        trainX_resized = []
        for img in train_images:
            trainX_resized.append(cv2.resize(img, (image_size, image_size)))
        train_images = np.array(trainX_resized)
        train_images = train_images.reshape((data_augmentation * trainX_length), num_unique_time_days, image_size, image_size, 3)
    else:
        images = self.create_montages(images, montage_image_number, image_size, full_montage_image_size)
        (encoder, decoder, autoencoder) = self.build_autoencoder(full_montage_image_size, full_montage_image_size, 3)
        opt = Adam(lr=0.001)
        autoencoder.compile(loss='mse', optimizer=opt)
        (train_aux_data, test_aux_data, train_images, test_images) = train_test_split(aux_data, images, test_size=0.2)
        checkpoint = ModelCheckpoint(filepath=output_autoencoder_model_file_path, monitor='loss', verbose=1, save_best_only=True, mode='min', save_frequency=1, save_weights_only=False)
        callbacks_list = [checkpoint]
        H = autoencoder.fit(train_images, train_images, validation_data=(test_images, test_images), epochs=25, batch_size=32, callbacks=callbacks_list)
        decoded = autoencoder.predict(images)
        output_image_counter = 0
        for image in decoded:
            cv2.imwrite(output_image_file[output_image_counter], (image * 255))
            output_image_counter += 1
        (train_aux_data, test_aux_data, train_images, test_images) = train_test_split(aux_data, decoded, test_size=0.2)
    stock_id_binarizer = LabelBinarizer().fit(aux_data['stock_id'])
    train_stock_id_categorical = stock_id_binarizer.transform(train_aux_data['stock_id'])
    test_stock_id_categorical = stock_id_binarizer.transform(test_aux_data['stock_id'])
    accession_id_binarizer = LabelBinarizer().fit(aux_data['accession_id'])
    train_accession_id_categorical = accession_id_binarizer.transform(train_aux_data['accession_id'])
    test_accession_id_categorical = accession_id_binarizer.transform(test_aux_data['accession_id'])
    female_id_binarizer = LabelBinarizer().fit(aux_data['female_id'])
    train_female_id_categorical = female_id_binarizer.transform(train_aux_data['female_id'])
    test_female_id_categorical = female_id_binarizer.transform(test_aux_data['female_id'])
    male_id_binarizer = LabelBinarizer().fit(aux_data['male_id'])
    train_male_id_categorical = male_id_binarizer.transform(train_aux_data['male_id'])
    test_male_id_categorical = male_id_binarizer.transform(test_aux_data['male_id'])
    continuous = [col for col in aux_data.columns if ('aux_trait_' in col)]
    cs = MinMaxScaler()
    if (len(continuous) > 0):
        trainContinuous = cs.fit_transform(train_aux_data[continuous])
        testContinuous = cs.transform(test_aux_data[continuous])
        trainX = trainContinuous
        testX = testContinuous
    else:
        trainX = []
        testX = []
    trainx = np.array(trainX)
    testx = np.array(testX)
    max_label = aux_data['value'].max()
    trainY = (train_aux_data['value'] / max_label)
    testY = (test_aux_data['value'] / max_label)
    train_genotype_files = train_aux_data['genotype_file'].tolist()
    test_genotype_files = test_aux_data['genotype_file'].tolist()
    train_genotype_data = []
    for f in train_genotype_files:
        if (log_file_path is not None):
            eprint(f)
        else:
            print(f)
        if (pd.isna(f) is False):
            geno_data = pd.read_csv(f, sep='\t', header=None, na_values='NA')
            train_genotype_data.append(np.array(geno_data.iloc[:, 0]))
    test_genotype_data = []
    for f in test_genotype_files:
        if (log_file_path is not None):
            eprint(f)
        else:
            print(f)
        if (pd.isna(f) is False):
            geno_data = pd.read_csv(f, sep='\t', header=None, na_values='NA')
            test_genotype_data.append(np.array(geno_data.iloc[:, 0]))
    train_genotype_data = np.array(train_genotype_data)
    test_genotype_data = np.array(test_genotype_data)
    eprint(train_genotype_data)
    eprint(testX)
    eprint(trainX)
    return (test_images, np.array(testX), testY.to_numpy(), test_genotype_data, train_images, np.array(trainX), trainY.to_numpy(), train_genotype_data)