Exemplo n.º 1
0
	def test_blandAtlman_axis_handle(self):

		import matplotlib

		with self.subTest(msg='Single axis'):

			fig, ax = matplotlib.pyplot.subplots()

			ax = pyCompare.blandAltman(numpy.random.rand(self.noSamp)*100+100,
									  numpy.random.rand(self.noSamp)*50+100,
									  confidenceIntervalMethod='approximate',
									  savePath=None,
									  ax=ax)

			self.assertTrue(isinstance(ax, matplotlib.axes._subplots.Axes))

		with self.subTest(msg='Multiple axes'):

			fig, ax = matplotlib.pyplot.subplots(2,2)

			ax1 = pyCompare.blandAltman(numpy.random.rand(self.noSamp)*100+100,
									   numpy.random.rand(self.noSamp)*50+100,
									   confidenceIntervalMethod='approximate',
									   savePath=None,
									   ax=ax[1,1])

			ax2 = pyCompare.blandAltman(numpy.random.rand(self.noSamp)*100+100,
									   numpy.random.rand(self.noSamp)*50+100,
									   confidenceIntervalMethod='approximate',
									   savePath=None,
									   ax=ax[0,0])

			self.assertTrue(isinstance(ax1, matplotlib.axes._subplots.Axes))
			self.assertTrue(isinstance(ax2, matplotlib.axes._subplots.Axes))
Exemplo n.º 2
0
    def test_blandAtlman_screen(self):

        noSamp = numpy.random.randint(100, high=500, size=None)

        pyCompare.blandAltman(numpy.random.rand(noSamp) * 100 + 100,
                              numpy.random.rand(noSamp) * 50 + 100,
                              confidenceIntervalMethod='approximate',
                              savePath=None)
Exemplo n.º 3
0
	def test_blandAtlman_saves(self):

		with tempfile.TemporaryDirectory() as tmpdirname:
			with self.subTest(msg='Default Parameters'):
				outputPath = os.path.join(tmpdirname, 'plot')
				pyCompare.blandAltman(numpy.random.rand(self.noSamp)*100+100,
										  numpy.random.rand(self.noSamp)*50+100,
										  confidenceIntervalMethod='approximate',
										  savePath=outputPath)

				self.assertTrue(os.path.exists(outputPath))

			with self.subTest(msg='No CIs'):
				outputPath = os.path.join(tmpdirname, 'noCIplot')
				pyCompare.blandAltman(numpy.random.rand(self.noSamp)*100+100,
										  numpy.random.rand(self.noSamp)*50+100,
										  confidenceInterval=None,
										  savePath=outputPath)

				self.assertTrue(os.path.exists(outputPath))

			with self.subTest(msg='Percentage'):
				outputPath = os.path.join(tmpdirname, 'plot_percentage')
				pyCompare.blandAltman(numpy.random.rand(self.noSamp)*100+100,
										  numpy.random.rand(self.noSamp)*50+100,
										  confidenceIntervalMethod='approximate',
										  percentage=True,
										  savePath=outputPath)

				self.assertTrue(os.path.exists(outputPath))
Exemplo n.º 4
0
	def test_blandAtlman_screen(self):

		pyCompare.blandAltman(numpy.random.rand(self.noSamp)*100+100,
								  numpy.random.rand(self.noSamp)*50+100,
								  confidenceIntervalMethod='approximate',
								  savePath=None)
Exemplo n.º 5
0
tempt_pulsatile = pulsatile.iloc[test_list.iloc[0].values.squeeze().tolist()]
tempt_pulsatile = (tempt_pulsatile-tempt_pulsatile.mean())/tempt_pulsatile.std()
tempt_pulsatile.iloc[0].to_numpy()

test_predict[0][0]

test_pred_df = []
test_true_df = []
for item in range(10):
  for idx in range(19):
    test_pred_df.extend(test_predict[item][idx])
    tempt_pulsatile = pulsatile.iloc[test_list.iloc[item].values.squeeze().tolist()]
    tempt_pulsatile = (tempt_pulsatile-tempt_pulsatile.mean())/tempt_pulsatile.std()
    test_true_df.extend(tempt_pulsatile.iloc[idx].to_numpy())
blandAltman(test_pred_df, test_true_df,savePath=os.path.join(run_name, 'BA_model1.png'),figureFormat='png')

test_predict[0]

def dice(im1, im2):
    """
    Computes the Dice coefficient, a measure of set similarity.
    Parameters
    ----------
    im1 : array-like, bool
        Any array of arbitrary size. If not boolean, will be converted.
    im2 : array-like, bool
        Any other array of identical size. If not boolean, will be converted.
    Returns
    -------
    dice : float
Exemplo n.º 6
0
#                      verbose=0)

out = model.predict(X_train2, batch_size=batch_size)
predicted2 = out.ravel()

out = model.predict(X_test, batch_size=batch_size)
predicted = out.ravel()

# sns.set(color_codes=True)
# ax = sns.regplot(x=Y_test2, y=predicted2, color="g")

r1 = r2_score(Y_train2, predicted2)
r2 = r2_score(Y_test, predicted)
print("New Signal R2:{0}".format(r1))
print("Same Signal R2:{0}".format(r2))
plt.plot(Y_train2)
plt.plot(predicted2)
plt.legend(['Target', 'Estimated'], loc='upper left')
plt.show()

blandAltman(Y_test,
            predicted,
            savePath='SavedFigureAltman.svg',
            figureFormat='svg')

df = pd.DataFrame(columns=["target", "predicted"])
df["predicted"] = predicted2
df["target"] = Y_train2
df.to_excel("result.xlsx")
pass
Exemplo n.º 7
0
import urllib.request, json
import pyCompare

url = "https://cvdhd-ef484.firebaseio.com/.json"
data = urllib.request.urlopen(url).read().decode()
obj = json.loads(data)
print(obj)
bmp = []
dht = []

for key in obj:
    bmp.append(obj[key]["bmp"]["temp"])
    dht.append(obj[key]["dht"]["temp"])
print(bmp)
print(dht)
pyCompare.blandAltman(bmp,dht)
Exemplo n.º 8
0
"""

Myocardial Mass ED

"""

auto_ED_Myo_Mass = np.array([
    183349.609375, 181792.96875, 182976.822669983, 60789.55078125,
    156115.72265625, 157034.118652344, 95858.3605499268, 125610.3515625,
    146155.725517273, 66088.8671875, 105493.1640625, 95166.015625,
    102083.472846985, 94833.6481323242, 73320.6992340088
])

manual_ED_Myo_Mass = np.array([
    164257.8125, 183691.40625, 188135.83820343, 70459.716796875,
    176676.940917969, 187925.354003906, 92289.4210891724, 137386.322021484,
    132912.886299133, 65502.9296875, 98706.0546875, 106298.828125,
    97772.5845108032, 93511.6177215576, 68698.119140625
])

pyCompare.blandAltman(auto_ED_Myo_Mass,
                      manual_ED_Myo_Mass,
                      limitOfAgreement=1.96,
                      confidenceInterval=95,
                      title='Myo Mass ED (g)   rho=0.96',
                      meanColour='c',
                      loaColour='gray',
                      pointColour='red',
                      dpi=1000,
                      savePath='bland_MyoMassED.png')