-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_mtf.py
More file actions
60 lines (48 loc) · 1.98 KB
/
Copy pathplot_mtf.py
File metadata and controls
60 lines (48 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
""""
# Gramian Angular Field
A Gramian Angular Field is an image obtained from a time series, representing
some temporal correlation between each time point. Two methods are
available: Gramian Angular Summation Field and Gramian Angular Difference
Field. This example illustrates the transformation on the first sample of
the *GunPoint* dataset. Both images are plotted side by side to illustrate
the differences.
It is implemented as :class:`pyts.image.GramianAngularField`.
"""
# Author: Johann Faouzi <johann.faouzi@gmail.com>
# License: BSD-3-Clause
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
from pyts.datasets import load_gunpoint
from numpy import genfromtxt
from pathlib import Path, PureWindowsPath
import os
import numpy as np
import matplotlib.pyplot as plt
from pyts.image import MarkovTransitionField
# Parameters
file_path = 'D:\dev\Mestrado\Onlydata-features-1.csv'
savepathMTF = 'D:\\TCC\\ImagemTeste\\Normalizadas\\ROIs_normalizadas\\normal\\Método proposto\\normal\\MTF\\teste'
#Make save dir if not exists
if not os.path.exists(savepathMTF):
os.makedirs(savepathMTF)
if not os.path.exists(savepathMTF):
os.makedirs(savepathMTF)
# Get data from csv
X = genfromtxt(file_path, delimiter=',')
n_img = len(X)
#Define data range
a = X[0:n_img, 0:300]
for i in range (n_img):
b = a[i, 0:300]
X = b
X = X.reshape(3, 100)
# Transform the time series into Marcov Transition Fields
mtf = MarkovTransitionField(n_bins=10)
X_mtf = mtf.fit_transform(X)
plt.imsave(savepathMTF+'GRAYMTFMink'+str(i+1)+'.png', X_mtf[0], cmap='gray', origin='lower')
plt.imsave(savepathMTF+'GRAYMTFEucl'+str(i+1)+'.png', X_mtf[1], cmap='gray', origin='lower')
plt.imsave(savepathMTF+'GRAYMTFManh'+str(i+1)+'.png', X_mtf[2], cmap='gray', origin='lower')
imagem = np.reshape(X_mtf, (100, 100,3))
imagem = (255*(imagem - np.min(imagem))/np.ptp(imagem)).astype(int)
imagem = np.uint8(imagem)
plt.imsave(savepathMTF+'MTF'+str(i+1)+'.png', imagem, origin='lower')