From d3f21e2aec10d854e13a73da5ae295c77653a1e6 Mon Sep 17 00:00:00 2001 From: yalmansour1998 <120363766+yalmansour1998@users.noreply.github.com> Date: Thu, 30 May 2024 12:58:20 +0200 Subject: [PATCH] Add files via upload --- 3D_app/pages/ascan.py | 402 +++++++++++++++++++----------------------- 1 file changed, 184 insertions(+), 218 deletions(-) diff --git a/3D_app/pages/ascan.py b/3D_app/pages/ascan.py index c3d5919..8772fba 100644 --- a/3D_app/pages/ascan.py +++ b/3D_app/pages/ascan.py @@ -10,20 +10,18 @@ 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_Wave_Rot00_CSV_Data" fichiers_selectionnes = [ - "Shear_x001-x101_y{:03d}_Rot00.csv".format(i) for i in range(10, 13) + "Shear_x001-x101_y{:03d}_Rot00.csv".format(i) for i in range(10,13) ] # on lit les fichiers et on les met dans un tableau pre_volume = np.array(lire_fichier_csv(dossier, fichiers_selectionnes)) volume = pre_volume[:, :, :] -data_traits = volume +data_traits=volume dim_x, dim_y, dim_z = volume.shape X, Y, Z = np.mgrid[0:dim_x, 0:dim_y, 0:dim_z] @@ -66,14 +64,8 @@ layout = html.Div( {"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", - }, + {"label": "filtre à réponse impulsionnelle infinie", "value": "6"}, + {"label": "filtre à réponse impulsionnelle finie", "value": "7"}, ], value=2, style={"margin-bottom": "15px"}, @@ -90,18 +82,13 @@ layout = html.Div( {"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", - }, + {"label": "filtre à réponse impulsionnelle infinie", "value": "6"}, + {"label": "filtre à réponse impulsionnelle finie", "value": "7"}, ], value=2, style={"margin-bottom": "15px"}, ), + ], width=3, ), @@ -114,9 +101,11 @@ layout = html.Div( color="primary", style={"marginBottom": "15px"}, ), + ], width=3, ), + ] ), dbc.Row( @@ -143,147 +132,156 @@ layout = html.Div( dcc.Slider( id="layer-slider-ascan-solo-x", min=1, - max=dim_z - 1, + max=dim_z, value=1, step=1, - marks={str(i): str(i) for i in range(1, dim_z + 1, max(1, int(dim_z / 20)))}, + marks={ + str(i): str(i) for i in range(1, dim_z+1,1) + }, ), dbc.Label("y"), dcc.Slider( id="layer-slider-ascan-solo-y", - min=0, - max=dim_x - 1, - value=0, + min=1, + max=dim_x, + value=1, step=1, - marks={str(i): str(i) for i in range(0, dim_x + 1, max(1, int(dim_x / 20)))}, + marks={ + str(i): str(i) for i in range(1, dim_x+1,1) + }, + ), + dbc.Label("z"), + dcc.RangeSlider( + id="layer-slider-ascan-solo-z", + min=1, + max=dim_y, + value=[dim_y/dim_y,dim_y], + step=1, + marks={ + str(i): str(i) for i in range(1, dim_y+1,1) + }, ), dbc.Row( [ - dbc.Row( - [ - dbc.Label(" paramètre du 1er filtre ", html_for="Fs "), - dbc.Col( - [ - dbc.Label("Fs ", html_for="Fs "), - dbc.Input( - id="input-ascan-solo-fs", - type="number", - placeholder="Fs", - value=1, - step=0.1, - style={"marginTop": "15px"}, - ), - ], - width=3, - ), - dbc.Col( - [ - dbc.Label("cut off ", html_for="cut off"), - dbc.Input( - id="input-ascan-solo-cutoff", - type="number", - placeholder="cut_off", - value=1, - step=0.1, - style={"marginTop": "15px"}, - ), - ], - width=3, - ), - dbc.Col( - [ - dbc.Label("order ", html_for="order"), - dbc.Input( - id="input-ascan-solo-order", - type="number", - placeholder="order", - value=1, - step=1, - style={"marginTop": "15px"}, - ), - ], - width=3, - ), - dbc.Col( - [ - dbc.Label("window size ", html_for="window size"), - dbc.Input( - id="input-ascan-solo-windowsize", - type="number", - placeholder="window_size", - value=1, - step=1, - style={"marginTop": "15px"}, - ), - ], - width=3, - ), - ] + dbc.Label(" paramètre du 1er filtre ", html_for="Fs "), + dbc.Col( + [ + dbc.Label("Fs ", html_for="Fs "), + dbc.Input( + id="input-ascan-solo-fs", + type="number", + placeholder="Fs", + value=1, + step=0.1, + style={"marginTop": "15px"}, ), - dbc.Row( - [ - dbc.Label("paramètre de 2eme filtre ", html_for="Fs "), - dbc.Col( - [ - dbc.Label("Fs ", html_for="Fs "), - dbc.Input( - id="input-ascan-solo-fs-2", - type="number", - placeholder="Fs", - value=1, - step=0.1, - style={"marginTop": "15px"}, - ), - ], - width=3, - ), - dbc.Col( - [ - dbc.Label("cut off ", html_for="cut off"), - dbc.Input( - id="input-ascan-solo-cutoff-2", - type="number", - placeholder="cut_off", - value=1, - step=0.1, - style={"marginTop": "15px"}, - ), - ], - width=3, - ), - dbc.Col( - [ - dbc.Label("order ", html_for="order"), - dbc.Input( - id="input-ascan-solo-order-2", - type="number", - placeholder="order", - value=1, - step=1, - style={"marginTop": "15px"}, - ), - ], - width=3, - ), - dbc.Col( - [ - dbc.Label("window size ", html_for="window size"), - dbc.Input( - id="input-ascan-solo-windowsize-2", - type="number", - placeholder="window_size", - value=1, - step=1, - style={"marginTop": "15px"}, - ), - ], - width=3, - ), - ] - ), - ] + ], + width=3, ), + dbc.Col( + [ + dbc.Label("cut off ", html_for="cut off"), + dbc.Input( + id="input-ascan-solo-cutoff", + type="number", + placeholder="cut_off", + value=1, + step=0.1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + dbc.Col( + [ + dbc.Label("order ", html_for="order"), + dbc.Input( + id="input-ascan-solo-order", + type="number", + placeholder="order", + value=1, + step=1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + dbc.Col( + [ + dbc.Label("window size ", html_for="window size"), + dbc.Input( + id="input-ascan-solo-windowsize", + type="number", + placeholder="window_size", + value=1, + step=1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ),]), + dbc.Row( + [ + dbc.Label("paramètre de 2eme filtre ", html_for="Fs "), + dbc.Col( + [ + dbc.Label("Fs ", html_for="Fs "), + dbc.Input( + id="input-ascan-solo-fs-2", + type="number", + placeholder="Fs", + value=1, + step=0.1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + dbc.Col( + [ + dbc.Label("cut off ", html_for="cut off"), + dbc.Input( + id="input-ascan-solo-cutoff-2", + type="number", + placeholder="cut_off", + value=1, + step=0.1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + dbc.Col( + [ + dbc.Label("order ", html_for="order"), + dbc.Input( + id="input-ascan-solo-order-2", + type="number", + placeholder="order", + value=1, + step=1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + dbc.Col( + [ + dbc.Label("window size ", html_for="window size"), + dbc.Input( + id="input-ascan-solo-windowsize-2", + type="number", + placeholder="window_size", + value=1, + step=1, + style={"marginTop": "15px"}, + ), + ], + width=3, + ), + ]), ], + style={"padding": "20px"}, ) @@ -305,7 +303,19 @@ layout = html.Div( ], ) def update_filter_values(select_filtre_1, select_filtre_2): - return [select_filtre_1 == 2, select_filtre_1 == 2, select_filtre_1 == 2, select_filtre_1 == 2, select_filtre_2 == 2, select_filtre_2 == 2, select_filtre_2 == 2, select_filtre_2 == 2] + fs_1=True;cutoff_1=True;ordre_1=True;windowsize_1=True + fs_2=True;cutoff_2=True;ordre_2=True;windowsize_2=True + if (int(select_filtre_1)==3): + fs_1=False;cutoff_1=False;ordre_1=False + if(int(select_filtre_2)==3): + fs_2=False;cutoff_2=False;ordre_2=False + if(int(select_filtre_1) in (4, 5, 6, 7)): + windowsize_1=False + if(int(select_filtre_2) in (4, 5, 6, 7)): + windowsize_2=False + return [fs_1, cutoff_1, ordre_1, windowsize_1, fs_2, cutoff_2, ordre_2, windowsize_2] + + # callback to update the heatmap @@ -317,6 +327,7 @@ def update_filter_values(select_filtre_1, select_filtre_2): Input("select-ascan-filter3", "value"), Input("layer-slider-ascan-solo-x", "value"), Input("layer-slider-ascan-solo-y", "value"), + Input("layer-slider-ascan-solo-z", "value"), Input("button-validate-filter", "n_clicks"), Input("input-ascan-solo-fs", "value"), Input("input-ascan-solo-cutoff", "value"), @@ -328,81 +339,36 @@ def update_filter_values(select_filtre_1, select_filtre_2): Input("input-ascan-solo-windowsize-2", "value"), ], ) -def update_heatmap_ascan( - selec_transforme_hilbert, - select_filtre_1, - select_filtre_2, - select_ascan_x, - select_ascan_y, - n_clicks, - fs_filtre_1, - cutoff_filtre_1, - order_filtre_1, - windowsize_filtre_1, - fs_filtre_2, - cutoff_filtre_2, - order_filtre_2, - windowsize_filtre_2, -): + +def update_heatmap_ascan(selec_transforme_hilbert,select_filtre_1,select_filtre_2,select_ascan_x,select_ascan_y,select_ascan_z,n_clicks,fs_filtre_1,cutoff_filtre_1,order_filtre_1,windowsize_filtre_1,fs_filtre_2,cutoff_filtre_2,order_filtre_2,windowsize_filtre_2): # TODO: implement the filter print("debut du traitement") - data_avec_traitement = volume[int(select_ascan_y) - 1, :, int(select_ascan_x) - 1] - data_sans_traitement = volume[int(select_ascan_y) - 1, :, int(select_ascan_x) - 1] - data_avec_traitement = switch_case( - data_avec_traitement, int(selec_transforme_hilbert) - ) - data_sans_traitement = switch_case( - data_sans_traitement, int(selec_transforme_hilbert) - ) - data_avec_traitement = switch_case( - data_avec_traitement, - int(select_filtre_1), - float(fs_filtre_1), - float(cutoff_filtre_1), - int(order_filtre_1), - int(windowsize_filtre_1), - ) - - data_avec_traitement = switch_case( - data_avec_traitement, - int(select_filtre_2), - float(fs_filtre_2), - float(cutoff_filtre_2), - int(order_filtre_2), - int(windowsize_filtre_2), - ) + data_avec_traitement=volume[int(select_ascan_y)-1,select_ascan_z[0]:select_ascan_z[1],int(select_ascan_x)-1] + data_sans_traitement=volume[int(select_ascan_y)-1,select_ascan_z[0]:select_ascan_z[1],int(select_ascan_x)-1] + + data_avec_traitement=switch_case(data_avec_traitement,int(selec_transforme_hilbert)) + data_sans_traitement=switch_case(data_sans_traitement,int(selec_transforme_hilbert)) + + data_avec_traitement=switch_case(data_avec_traitement,int(select_filtre_1),float(fs_filtre_1),float(cutoff_filtre_1),int(order_filtre_1),int(windowsize_filtre_1)) + data_avec_traitement=switch_case(data_avec_traitement,int(select_filtre_2),float(fs_filtre_2),float(cutoff_filtre_2),int(order_filtre_2),int(windowsize_filtre_2)) print("fin du traitement") - if n_clicks != None: - data_traits = switch_case(data_traits, int(selec_transforme_hilbert)) - data_traits = switch_case( - data_traits, - int(select_filtre_1), - float(fs_filtre_1), - float(cutoff_filtre_1), - int(order_filtre_1), - int(windowsize_filtre_1), - ) - data_traits = switch_case( - data_traits, - int(select_filtre_2), - float(fs_filtre_2), - float(cutoff_filtre_2), - int(order_filtre_2), - int(windowsize_filtre_2), - ) - fig = px.line(title="A-scan") - new_trace = go.Scatter(y=data_avec_traitement, mode="lines", name=" Ascan trait ") + if(n_clicks!=None): + data_traits=switch_case(data_traits,int(selec_transforme_hilbert)) + data_traits=switch_case(data_traits,int(select_filtre_1),float(fs_filtre_1),float(cutoff_filtre_1),int(order_filtre_1),int(windowsize_filtre_1)) + data_traits=switch_case(data_traits,int(select_filtre_2),float(fs_filtre_2),float(cutoff_filtre_2),int(order_filtre_2),int(windowsize_filtre_2)) + fig = px.line( title="A-scan") + new_trace = go.Scatter(y=data_avec_traitement, mode='lines', name=' Ascan trait ') fig.add_trace(new_trace) - new_trace = go.Scatter( - y=data_sans_traitement, mode="lines", name=" Ascan (hilbert) " - ) + new_trace = go.Scatter(y=data_sans_traitement, mode='lines', name=' Ascan (hilbert) ') fig.add_trace(new_trace) - + data_bscan=switch_case(volume[select_ascan_y - 1, select_ascan_z[0]:select_ascan_z[1], :],int(selec_transforme_hilbert)) + data_bscan=switch_case(data_bscan,int(select_filtre_1),float(fs_filtre_1),float(cutoff_filtre_1),int(order_filtre_1),int(windowsize_filtre_1)) + data_bscan=switch_case(data_bscan,int(select_filtre_2),float(fs_filtre_2),float(cutoff_filtre_2),int(order_filtre_2),int(windowsize_filtre_2)) fig2 = px.imshow( - volume[select_ascan_y - 1, :, :], + data_bscan, color_continuous_scale="Jet", aspect="auto", title="B-scan ZX", ) - - return [fig, fig2] + + return [fig, fig2] \ No newline at end of file