chore: Ignore cache files in .gitignore and update A-Scan filters page

This commit is contained in:
2024-05-27 15:40:08 +02:00
parent 560c6fad0e
commit a69c0f4c64
14 changed files with 217 additions and 136 deletions

4
.gitignore vendored
View File

@ -2,4 +2,6 @@
/electron-3d-app/
/express-app/
/react-app/
/.vscode/
/.vscode/
/3D_app/__pycache__/
/3D_app/pages/__pycache__/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

42
3D_app/import_sqlite.py Normal file
View File

@ -0,0 +1,42 @@
import sqlite3
from util import *
import numpy as np
import datetime
timestamp_start = datetime.datetime.now()
db = sqlite3.connect('data.sqlite')
cursor = db.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS volume (x INTEGER, y INTEGER, z INTEGER, value REAL)')
# on définit le dossier et les fichiers à lire
dossier = "Dataset/Shear_transform"
fichiers_selectionnes = [
"Shear_x001-x101_y{:03d}_Rot00_transform.csv".format(i) for i in range(10, 62)
]
# dossier = "Dataset/Shear_Wave_Rot00_CSV_Data"
# fichiers_selectionnes = ['Shear_x001-x101_y{:03d}_Rot00.csv'.format(i) for i in range(10, 62)]
# on lit les fichiers et on les met dans un tableau
pre_volume = np.array(lire_fichier_csv(dossier, fichiers_selectionnes))
volume = pre_volume[:, ::32, :]
dim_x, dim_y, dim_z = volume.shape
X, Y, Z = np.mgrid[0:dim_x, 0:dim_y, 0:dim_z]
cursor.execute('DELETE FROM volume')
for x in range(dim_x):
for y in range(dim_y):
for z in range(dim_z):
cursor.execute('INSERT INTO volume (x, y, z, value) VALUES (?, ?, ?, ?)', (x, y, z, volume[x, y, z]))
db.commit()
db.close()
timestamp_end = datetime.datetime.now()
totaltime = timestamp_end - timestamp_start
print('Done in', totaltime.microseconds / 1000, 'ms!')

View File

@ -7,24 +7,29 @@ import plotly.express as px
import plotly.io as pio
from util import *
dash.register_page(__name__, path="/ascan", title='A-Scan filters', name='A-Scan filters')
dash.register_page(
__name__, path="/ascan", title="A-Scan filters", name="A-Scan filters"
)
# on définit le dossier et les fichiers à lire
dossier = "Dataset/Shear_transform"
fichiers_selectionnes = [
"Shear_x001-x101_y{:03d}_Rot00_transform.csv".format(i) for i in range(10, 14)
]
# dossier = "Dataset/Shear_transform"
# fichiers_selectionnes = [
# "Shear_x001-x101_y{:03d}_Rot00_transform.csv".format(i) for i in range(10, 14)
# ]
# dossier = "Dataset/Shear_Wave_Rot00_CSV_Data"
# fichiers_selectionnes = ['Shear_x001-x101_y{:03d}_Rot00.csv'.format(i) for i in range(10, 62)]
# on charge le fichier numpy
fichiers = np.load("Dataset/npy/3D_Dataset_Long_Wave_Rot00.npy")
# on lit les fichiers et on les met dans un tableau
pre_volume = np.array(lire_fichier_csv(dossier, fichiers_selectionnes))
pre_volume = np.array(fichiers)
volume = pre_volume[:, ::32, :]
dim_x, dim_y, dim_z = volume.shape
dim_z, dim_x, dim_y = volume.shape
X, Y, Z = np.mgrid[0:dim_x, 0:dim_y, 0:dim_z]
# on définit le thème de l'application
pio.templates.default = "plotly_dark"
configAScan = {
"toImageButtonOptions": {
"format": "svg", # one of png, svg, jpeg, webp
@ -46,6 +51,13 @@ layout = html.Div(
],
style={"margin-bottom": "15px"},
),
dbc.Checklist(
options=[
{"label": "Valeurs absolues", "value": 1},
],
value=[1],
id="absolute-values-ascan",
),
dcc.Graph(
id="heatmap-ascan-solo",
config=configAScan,
@ -69,10 +81,10 @@ layout = html.Div(
# callback to update the heatmap
@callback(
Output("heatmap-ascan-solo", "figure"),
[Input("select-ascan-filter", "value"), Input("layer-slider-ascan-solo", "value")],
[Input("select-ascan-filter", "value"), Input("layer-slider-ascan-solo", "value"), Input("absolute-values-ascan", "value")],
)
def update_heatmap_ascan(value, layer):
def update_heatmap_ascan(value, layer, absolute_values):
# TODO: implement the filter
fig = px.line(y=volume[layer - 1, :, 5], title="A-scan")
return fig

View File

@ -10,20 +10,31 @@ from util import *
dash.register_page(__name__, path="/")
# on définit le dossier et les fichiers à lire
dossier = "Dataset/Shear_transform"
fichiers_selectionnes = [
"Shear_x001-x101_y{:03d}_Rot00_transform.csv".format(i) for i in range(10, 14)
]
# dossier = "Dataset/Shear_transform"
# fichiers_selectionnes = [
# "Shear_x001-x101_y{:03d}_Rot00_transform.csv".format(i) for i in range(10, 14)
# ]
# dossier = "Dataset/Shear_Wave_Rot00_CSV_Data"
# fichiers_selectionnes = ['Shear_x001-x101_y{:03d}_Rot00.csv'.format(i) for i in range(10, 62)]
# on charge le fichier numpy
fichiers = np.load("Dataset/npy/3D_Dataset_Shear_Wave_Rot00.npy")
# valeurs d'échantillonage
echantillonage_x = 4
echantillonage_y = 1
echantillonage_z = 32
# on lit les fichiers et on les met dans un tableau
pre_volume = np.array(lire_fichier_csv(dossier, fichiers_selectionnes))
volume = pre_volume[:, ::32, :]
pre_volume = np.array(fichiers)
volume = pre_volume[::echantillonage_x, ::echantillonage_y, ::echantillonage_z]
dim_x, dim_y, dim_z = volume.shape
X, Y, Z = np.mgrid[0:dim_x, 0:dim_y, 0:dim_z]
print(volume.shape)
X = np.array(np.load("Dataset/npy/x-values.npy"))[::echantillonage_x]
Y = np.array(np.load("Dataset/npy/y-values.npy"))[::echantillonage_y]
Z = np.array(np.load("Dataset/npy/z-values.npy"))[::echantillonage_z]
print(len(X), len(Y), len(Z))
# on défini le thème de l'application
pio.templates.default = "plotly_dark"
@ -169,7 +180,7 @@ mesh_card = dbc.Card(
for i in range(
int(volume.min()),
int(volume.max() / 2) + 1,
int((volume.max() / 2 - volume.min()) / 10),
int((volume.max() / 2 - volume.min()) / 20),
)
},
step=1,
@ -182,7 +193,7 @@ mesh_card = dbc.Card(
marks={
str(i): str(i)
for i in range(
0, int(dim_y) + 1, max(1, int(dim_y / 20))
0, int(dim_y) + 1, max(1, int(dim_y / 50))
)
},
step=1,
@ -259,7 +270,7 @@ Ascan_card = dbc.Card(
marks={
str(i): str(i)
for i in range(
1, dim_x + 1, max(1, int(dim_x / 20))
1, dim_x + 1, max(1, int(dim_x / 50))
)
},
),
@ -274,84 +285,8 @@ Ascan_card = dbc.Card(
]
)
# carte pour le B-scan XY
Bscan_card_xy = dbc.Card(
[
dbc.CardBody(
[
dbc.Row(
[
dbc.Col(
html.H2(
"B-scan XY",
className="card-title",
style={"textAlign": "left"},
),
width="4",
),
dbc.Col(
dbc.Button(
html.I(className="bi bi-arrows-fullscreen"),
id="fullscreen-button-bscan-xy",
className="mb-3",
color="primary",
style={"marginBottom": "15px"},
),
),
],
),
dcc.Graph(
id="heatmap-bscan-xy",
config=configBScanXY,
style={"marginBottom": "15px"},
), # 'fig' is your 2D plotly figure
dcc.Slider(
id="layer-slider-bscan-xy",
min=1,
max=dim_x,
value=1,
step=1,
marks={
str(i): str(i)
for i in range(1, dim_x + 1, max(1, int(dim_x / 20)))
},
),
dbc.Modal(
[
dbc.ModalHeader(dbc.ModalTitle("B-Scan XY")),
dbc.ModalBody(
[
dcc.Graph(
id="heatmap-bscan-xy-fullscreen",
config=configBScanXY,
style={"marginBottom": "15px"},
), # 'fig' is your 2D plotly figure
dcc.Slider(
id="layer-slider-bscan-xy-fullscreen",
min=1,
max=dim_x,
value=1,
step=1,
marks={
str(i): str(i)
for i in range(
1, dim_x + 1, max(1, int(dim_x / 20))
)
},
),
]
),
],
id="modal-bscan-xy",
fullscreen=True,
),
]
)
]
)
# carte pour le B-scan ZX
Bscan_card_zx = dbc.Card(
Bscan_card_xy = dbc.Card(
[
dbc.CardBody(
[
@ -384,6 +319,82 @@ Bscan_card_zx = dbc.Card(
dcc.Slider(
id="layer-slider-bscan-zx",
min=1,
max=dim_x,
value=1,
step=1,
marks={
str(i): str(i)
for i in range(1, dim_x + 1, max(1, int(dim_x / 20)))
},
),
dbc.Modal(
[
dbc.ModalHeader(dbc.ModalTitle("B-Scan ZX")),
dbc.ModalBody(
[
dcc.Graph(
id="heatmap-bscan-zx-fullscreen",
config=configBScanXY,
style={"marginBottom": "15px"},
), # 'fig' is your 2D plotly figure
dcc.Slider(
id="layer-slider-bscan-zx-fullscreen",
min=1,
max=dim_x,
value=1,
step=1,
marks={
str(i): str(i)
for i in range(
1, dim_x + 1, max(1, int(dim_x / 50))
)
},
),
]
),
],
id="modal-bscan-zx",
fullscreen=True,
),
]
)
]
)
# carte pour le B-scan ZX
Bscan_card_zx = dbc.Card(
[
dbc.CardBody(
[
dbc.Row(
[
dbc.Col(
html.H2(
"B-scan XY",
className="card-title",
style={"textAlign": "left"},
),
width="4",
),
dbc.Col(
dbc.Button(
html.I(className="bi bi-arrows-fullscreen"),
id="fullscreen-button-bscan-xy",
className="mb-3",
color="primary",
style={"marginBottom": "15px"},
),
),
],
),
dcc.Graph(
id="heatmap-bscan-xy",
config=configBScanXY,
style={"marginBottom": "15px"},
), # 'fig' is your 2D plotly figure
dcc.Slider(
id="layer-slider-bscan-xy",
min=1,
max=dim_z - 1,
value=1,
step=1,
@ -398,12 +409,12 @@ Bscan_card_zx = dbc.Card(
dbc.ModalBody(
[
dcc.Graph(
id="heatmap-bscan-zx-fullscreen",
config=configBScanZX,
id="heatmap-bscan-xy-fullscreen",
config=configBScanXY,
style={"marginBottom": "15px"},
), # 'fig' is your 2D plotly figure
dcc.Slider(
id="layer-slider-bscan-zx-fullscreen",
id="layer-slider-bscan-xy-fullscreen",
min=1,
max=dim_z - 1,
value=1,
@ -411,7 +422,7 @@ Bscan_card_zx = dbc.Card(
marks={
str(i): str(i)
for i in range(
1, dim_z + 1, max(1, int(dim_z / 20))
1, dim_z + 1, max(1, int(dim_z / 50))
)
},
),
@ -524,38 +535,14 @@ def update_heatmap_ascan_fullscreen(layer):
# callback pour les B-scan XY
@callback(Output("heatmap-bscan-xy", "figure"), Input("layer-slider-bscan-xy", "value"))
def update_heatmap_bscan_xy(layer):
fig = px.imshow(
volume[layer - 1, :, :],
color_continuous_scale="Jet",
aspect="auto",
title="B-scan XY",
)
return fig
# callback pour les B-scan XY en plein écran
@callback(
Output("heatmap-bscan-xy-fullscreen", "figure"),
Input("layer-slider-bscan-xy-fullscreen", "value"),
)
def update_heatmap_bscan_xy_fullscreen(layer):
fig = px.imshow(
volume[layer - 1, :, :],
color_continuous_scale="Jet",
aspect="auto",
title="B-scan XY",
)
return fig
# callback pour les B-scan ZX
@callback(Output("heatmap-bscan-zx", "figure"), Input("layer-slider-bscan-zx", "value"))
def update_heatmap_bscan_zx(layer):
fig = go.Figure(data=go.Heatmap(z=volume[:, :, layer], colorscale="Jet"))
fig = px.imshow(
volume[layer - 1, :, :],
color_continuous_scale="Jet",
aspect="auto",
title="B-scan XY",
)
return fig
@ -566,6 +553,30 @@ def update_heatmap_bscan_zx(layer):
Input("layer-slider-bscan-zx-fullscreen", "value"),
)
def update_heatmap_bscan_zx_fullscreen(layer):
fig = px.imshow(
volume[layer - 1, :, :],
color_continuous_scale="Jet",
aspect="auto",
title="B-scan ZX",
)
return fig
# callback pour les B-scan ZX
@callback(Output("heatmap-bscan-xy", "figure"), Input("layer-slider-bscan-xy", "value"))
def update_heatmap_bscan_xy(layer):
fig = go.Figure(data=go.Heatmap(z=volume[:, :, layer], colorscale="Jet"))
return fig
# callback pour les B-scan ZX en plein écran
@callback(
Output("heatmap-bscan-xy-fullscreen", "figure"),
Input("layer-slider-bscan-xy-fullscreen", "value"),
)
def update_heatmap_bscan_xy_fullscreen(layer):
fig = go.Figure(data=go.Heatmap(z=volume[:, :, layer], colorscale="Jet"))
return fig

14
3D_app/transform_numpy.py Normal file
View File

@ -0,0 +1,14 @@
import numpy as np
from util import *
dossier = "Dataset/Shear_transform"
fichiers_selectionnes = [
"Shear_x001-x101_y{:03d}_Rot00_transform.csv".format(i) for i in range(10, 62)
]
pre_volume = np.array(lire_fichier_csv(dossier, fichiers_selectionnes))
volume = pre_volume[:, ::32, :]
dim_z, dim_x, dim_y = volume.shape
np.save("Dataset/npy/export.npy", pre_volume)
print("Done!")