currentString = 'SEN'+str(i)+'_'+str(currentSNR)+'_'+noiseType allStrings.append(currentString) if (i == 10): SNRIndex = 1 print("LOADING DATA") resultsHIT = list() resultsFA = list() resultsHIT_FA = list() #GENERATE FILE OUTPUTS for j in allStrings: inputTest = io.loadmat(imagesFolder + j + '.mat') inputTest = np.array(inputTest['AIMImages']) inputTest = np.swapaxes(inputTest,2,1) inputTest = np.swapaxes(inputTest,0,1) inputTest = inputTest.astype("float32") inputTest = np.expand_dims(inputTest,1) target = io.loadmat(targetsFolder + j + '.mat') target = np.transpose(target['target']) prediction = model.predict(inputTest) HIT,FA,HIT_FA = computeHIT_FA(target,prediction,threshold) resultsHIT.append(HIT) resultsFA.append(FA) resultsHIT_FA.append(HIT_FA) resultsHIT = np.mean(resultsHIT) resultsFA = np.mean(resultsFA) resultsHIT_FA = np.mean(resultsHIT_FA) print('HIT : ' + str(resultsHIT)) print('FA : ' + str(resultsFA)) print('HIT_FA : ' + str(resultsHIT_FA))
SNRs = [-5,-2] threshold = 0.5 filesForTesting = list() SNRs = [-5,-2] for i in SNRs: for x in range(1,11): filesForTesting.append('Testing' + str(x) + 'SNR' + str(i)) resultsHIT = list() resultsFA = list() resultsHIT_FA = list() #GENERATE FILE OUTPUTS for j in filesForTesting: fileToRead = sio.loadmat(readFolder + j + '.mat') inputTest = np.transpose(fileToRead.get('input_tst_data')) prediction = model.predict(inputTest) trueMask = np.transpose(fileToRead.get('target_tst_data')) HIT,FA,HIT_FA = computeHIT_FA(trueMask,prediction,threshold) resultsHIT.append(HIT) resultsFA.append(FA) resultsHIT_FA.append(HIT_FA) resultsHIT = np.mean(resultsHIT) resultsFA = np.mean(resultsFA) resultsHIT_FA = np.mean(resultsHIT_FA) print("OVERALL HIT : " + np.array_str(resultsHIT)) print("OVERALL FA : " + np.array_str(resultsFA)) print("OVERALL HIT_FA : " + np.array_str(resultsHIT_FA))
import numpy as np from usefulMethodsSE import computeHIT_FA import scipy.io as sio loadingFile = "./TestHIT_FAMethod/sen1.mat" loadingFile = sio.loadmat(loadingFile) estimation = np.transpose(loadingFile.get("estimation")) trueMask = np.transpose(loadingFile.get("realTarget")) HIT_FA = computeHIT_FA(trueMask, estimation, 0.5) print "HIT-FA: {}".format(HIT_FA)