diff --git a/3D_app/pages/ascan.py b/3D_app/pages/ascan.py index 9697fc3..3e91ddd 100644 --- a/3D_app/pages/ascan.py +++ b/3D_app/pages/ascan.py @@ -6,27 +6,24 @@ import numpy as np import plotly.express as px import plotly.io as pio from util import * +from filtrage import * +from selection_filtre 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" +dossier = "Dataset/Shear_Wave_Rot00_CSV_Data" fichiers_selectionnes = [ - "Shear_x001-x101_y{:03d}_Rot00_transform.csv".format(i) for i in range(10, 14) + "Shear_x001-x101_y{:03d}_Rot00.csv".format(i) for i in range(10, 11) ] -# 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)) -volume = pre_volume[:, ::32, :] -dim_z, dim_x, dim_y = volume.shape +volume = pre_volume[:, :, :] +dim_x, dim_y, dim_z = 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" @@ -40,7 +37,6 @@ configAScan = { }, "displaylogo": False, } - layout = html.Div( [ dbc.Row( @@ -48,13 +44,46 @@ layout = html.Div( dbc.Col( [ dbc.Select( - id="select-ascan-filter", + id="select-ascan-filter1", options=[ - {"label": "Option 1", "value": "1"}, - {"label": "Option 2", "value": "2"}, + {"label": "transformer du Hilbert", "value": "1"}, ], - style={"margin-bottom": "15px"}, value=1, + style={"margin-bottom": "15px"}, + ), + ] + ), + dbc.Col( + [ + dbc.Select( + id="select-ascan-filter2", + options=[ + {"label": "sans filtre ", "value": "2"}, + {"label": "filtre passe bas ", "value": "3"}, + {"label": "filtre de moyenne mobile", "value": "4"}, + {"label": "filtre adaptatif (wiener)", "value": "5"}, + {"label": "filtre à réponse impulsionnelle infinie", "value": "6"}, + {"label": "filtre à réponse impulsionnelle finie", "value": "7"}, + ], + value=2, + style={"margin-bottom": "15px"}, + ), + ] + ), + dbc.Col( + [ + dbc.Select( + id="select-ascan-filter3", + options=[ + {"label": "sans filtre ", "value": "2"}, + {"label": "filtre passe bas ", "value": "3"}, + {"label": "filtre de moyenne mobile", "value": "4"}, + {"label": "filtre adaptatif (wiener)", "value": "5"}, + {"label": "filtre à réponse impulsionnelle infinie", "value": "6"}, + {"label": "filtre à réponse impulsionnelle finie", "value": "7"}, + ], + value=2, + style={"margin-bottom": "15px"}, ), ] ), @@ -70,13 +99,6 @@ layout = html.Div( ), ] ), - dbc.Checklist( - options=[ - {"label": "Valeurs absolues", "value": 1}, - ], - value=[1], - id="absolute-values-ascan", - ), dcc.Graph( id="heatmap-ascan-solo", config=configAScan, @@ -92,12 +114,53 @@ layout = html.Div( str(i): str(i) for i in range(1, dim_x + 1, max(1, int(dim_x / 20))) }, ), - dbc.Input( - id="input-ascan-solo", - type="number", - placeholder="Valeurs", - step=0.1, - style={"marginTop": "15px"}, + dbc.Col( + [ + dbc.Input( + id="input-ascan-solo-fs", + type="number", + placeholder="Fs", + step=0.1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + dbc.Col( + [ + dbc.Input( + id="input-ascan-solo-cutoff", + type="number", + placeholder="cut_off", + step=0.1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + dbc.Col( + [ + dbc.Input( + id="input-ascan-solo-order", + type="number", + placeholder="order", + step=0.1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + dbc.Col( + [ + dbc.Input( + id="input-ascan-solo-windowsize", + type="number", + placeholder="window_size", + step=1, + style={"marginTop": "15px"}, + ), + ], + width=3, ), ], style={"padding": "20px"}, @@ -108,15 +171,32 @@ layout = html.Div( @callback( Output("heatmap-ascan-solo", "figure"), [ - Input("select-ascan-filter", "value"), + Input("select-ascan-filter1", "value"), + Input("select-ascan-filter2", "value"), + Input("select-ascan-filter3", "value"), Input("layer-slider-ascan-solo", "value"), - Input("absolute-values-ascan", "value"), Input("button-validate-filter", "n_clicks"), - Input("input-ascan-solo", "value"), + Input("input-ascan-solo-fs", "value"), + Input("input-ascan-solo-cutoff", "value"), + Input("input-ascan-solo-order", "value"), + Input("input-ascan-solo-windowsize", "value"), ], ) -def update_heatmap_ascan(filter, layer, absolute_values, n_clicks, input_value): - # TODO: implement the filter - fig = px.line(y=volume[layer - 1, :, 5], title="A-scan") - return fig +def update_heatmap_ascan(value1,value2,value3,value,n_clicks,fs,cutoff,order,windowsize): + # TODO: implement the filter + + if(n_clicks!=None and n_clicks>=1): + print("L12") + data_avec_traitement=volume[0,:,1] + data_sans_traitement=volume[0,:,1] + data_avec_traitement=switch_case(data_avec_traitement,value1) + data_sans_traitement=switch_case(data_sans_traitement,value1) + data_avec_traitement=switch_case(data_avec_traitement,value2,fs,cutoff,order,windowsize) + data_avec_traitement=switch_case(data_avec_traitement,value3,fs,cutoff,order,windowsize) + fig = px.line( title="A-scan") + new_trace = go.Scatter(y=data_avec_traitement, mode='lines', name=' Ascan traits ') + fig.add_trace(new_trace) + new_trace = go.Scatter(y=data_sans_traitement, mode='lines', name=' Ascan (hilbert) ') + fig.add_trace(new_trace) + return fig \ No newline at end of file