added time measurements for main functions of the app

This commit is contained in:
Pixelguy14 2025-01-19 17:07:04 -06:00
parent c92576d5a5
commit d18b113641
4 changed files with 85 additions and 75 deletions

View File

@ -184,9 +184,9 @@ version = "1.1.1"
[[deps.CairoMakie]]
deps = ["CRC32c", "Cairo", "Cairo_jll", "Colors", "FileIO", "FreeType", "GeometryBasics", "LinearAlgebra", "Makie", "PrecompileTools"]
git-tree-sha1 = "77bc0964dd77811630e6c3329536a86b3b965cba"
git-tree-sha1 = "6d76f05dbc8b7a52deaa7cdabe901735ae7b6724"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
version = "0.13.0"
version = "0.13.1"
[[deps.Cairo_jll]]
deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
@ -418,9 +418,9 @@ version = "1.11.0"
[[deps.Distributions]]
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
git-tree-sha1 = "7901a6117656e29fa2c74a58adb682f380922c47"
git-tree-sha1 = "03aa5d44647eaec98e1920635cdfed5d5560a8b9"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.25.116"
version = "0.25.117"
[deps.Distributions.extensions]
DistributionsChainRulesCoreExt = "ChainRulesCore"
@ -1361,9 +1361,9 @@ version = "0.5.15"
[[deps.Makie]]
deps = ["Animations", "Base64", "CRC32c", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "Contour", "Dates", "DelaunayTriangulation", "Distributions", "DocStringExtensions", "Downloads", "FFMPEG_jll", "FileIO", "FilePaths", "FixedPointNumbers", "Format", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageBase", "ImageIO", "InteractiveUtils", "Interpolations", "IntervalSets", "InverseFunctions", "Isoband", "KernelDensity", "LaTeXStrings", "LinearAlgebra", "MacroTools", "MakieCore", "Markdown", "MathTeXEngine", "Observables", "OffsetArrays", "PNGFiles", "Packing", "PlotUtils", "PolygonOps", "PrecompileTools", "Printf", "REPL", "Random", "RelocatableFolders", "Scratch", "ShaderAbstractions", "Showoff", "SignedDistanceFields", "SparseArrays", "Statistics", "StatsBase", "StatsFuns", "StructArrays", "TriplotBase", "UnicodeFun", "Unitful"]
git-tree-sha1 = "021b6b64b68f6ee09fb35a1528a2b5a7f48ac00c"
git-tree-sha1 = "9680336a5b67f9f9f6eaa018f426043a8cd68200"
uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
version = "0.22.0"
version = "0.22.1"
[[deps.MakieCore]]
deps = ["ColorTypes", "GeometryBasics", "IntervalSets", "Observables"]
@ -1603,9 +1603,9 @@ version = "10.42.0+1"
[[deps.PDMats]]
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "949347156c25054de2db3b166c52ac4728cbad65"
git-tree-sha1 = "966b85253e959ea89c53a9abebbf2e964fbf593b"
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
version = "0.11.31"
version = "0.11.32"
[[deps.PNGFiles]]
deps = ["Base64", "CEnum", "ImageCore", "IndirectArrays", "OffsetArrays", "libpng_jll"]
@ -2317,9 +2317,9 @@ uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.11.3"
[[deps.Tricks]]
git-tree-sha1 = "7822b97e99a1672bfb1b49b668a6d46d58d8cbcb"
git-tree-sha1 = "6cae795a5a9313bbb4f60683f7263318fc7d1505"
uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775"
version = "0.1.9"
version = "0.1.10"
[[deps.TriplotBase]]
git-tree-sha1 = "4d4ed7f294cda19382ff7de4c137d24d16adc89b"

90
app.jl
View File

@ -11,7 +11,7 @@ using Statistics
using NaturalSort
using Images
using LinearAlgebra
using NativeFileDialog
using NativeFileDialog # Opens the file explorer depending on the OS
@genietools
# == Code import ==
@ -69,10 +69,10 @@ end
@in triqProb=0.98
@in triqColor=256
# Interface Buttons
# Interface Buttons and Validations
@in btnSearch=false # To search for files in your device
@in mainProcess=false # To generate images
@in CompareBtn=false # to open dialog
@in compareBtn=false # To open dialog
@in createSumPlot=false # To generate sum spectrum plot
@in image3dPlot=false # To generate 3d plot based on current image
@in triq3dPlot=false # To generate 3d plot based on current triq image
@ -81,12 +81,12 @@ end
@in progress=false
@in progressPlot=false
@in triqEnabled=false
@in ImgPlus=false
@in ImgMinus=false
@in ImgPlusT=false
@in ImgMinusT=false
@in imgPlus=false
@in imgMinus=false
@in imgPlusT=false
@in imgMinusT=false
#TABS
# TAB variables
@out tabIDs=["tab0","tab1","tab2","tab3","tab4"]
@out tabLabels=["Image", "TrIQ", "Spectrum Plot", "Topology Plot","Surface Plot"]
@in selectedTab= "tab0"
@ -100,10 +100,12 @@ end
@out colorbar="/.png"
@out colorbarT="/.png"
# Messages to interface Variables
@out msg=""
@out msgimg=""
@out msgtriq=""
# Saves the route where imzML and mzML files are located
@out full_route=""
@out full_routeMz=""
@out full_routeMz2=""
@ -111,23 +113,22 @@ end
# For the creation of images with a more specific mass charge
@out text_nmass=""
# For image search
# Image lists we apply a filter that searches specific type of images into our public folder, then we sort it in a "numerical" order
# For image search image lists we apply a filter that searches specific type of images into our public folder, then we sort it in a "numerical" order
@in msi_bmp=sort(filter(filename -> startswith(filename, "MSI_") && endswith(filename, ".bmp"), readdir("public")),lt=natural)
@in col_msi_png=sort(filter(filename -> startswith(filename, "colorbar_MSI_") && endswith(filename, ".png"), readdir("public")),lt=natural)
@in triq_bmp=sort(filter(filename -> startswith(filename, "TrIQ_") && endswith(filename, ".bmp"), readdir("public")),lt=natural)
@in col_triq_png=sort(filter(filename -> startswith(filename, "colorbar_TrIQ_") && endswith(filename, ".png"), readdir("public")),lt=natural)
# Set current image for the list
# Set current image for the list to display
@out current_msi=""
@out current_col_msi=""
@out current_triq=""
@out current_col_triq=""
@out indeximg=0
@out indeximgTriq=0
@out lastimg=0
@out lastimgTriq=0
# Starting and finishing times to measure how long it takes for a function to finish in elapse time
@out sTime=time()
@out fTime=time()
@out eTime=time()
# Interface Plot Spectrum
layoutSpectra=PlotlyBase.Layout(
@ -219,22 +220,13 @@ end
col_triq_png=sort(filter(filename -> startswith(filename, "colorbar_TrIQ_") && endswith(filename, ".png"), readdir("public")),lt=natural)
end
end
"""
@onchange Nmass begin
indeximg=floor(Int, Nmass)
indeximgTriq=floor(Int, Nmass)
lastimg=floor(Int, Nmass)
lastimgTriq=floor(Int, Nmass)
end
"""
@onbutton mainProcess begin
progress=true # Start progress button animation
btnStartDisable=true # We disable the button to avoid multiple requests
btnPlotDisable=true
indeximg=floor(Int, Nmass)
text_nmass=replace(string(Nmass), "." => "_")
sTime=time()
#full_route=joinpath(file_route, file_name)
if isfile(full_route) && Nmass > 0 && Tol > 0 && Tol <= 1
msg="File exists, Nmass=$(Nmass) Tol=$(Tol). Loading file will begin, please be patient."
@ -274,7 +266,9 @@ end
# We update the directory to include the new placed images.
triq_bmp=sort(filter(filename -> startswith(filename, "TrIQ_") && endswith(filename, ".bmp"), readdir("public")),lt=natural)
col_triq_png=sort(filter(filename -> startswith(filename, "colorbar_TrIQ_") && endswith(filename, ".png"), readdir("public")),lt=natural)
msg="The file has been created successfully inside the 'public' folder of the app."
fTime=time()
eTime=round(fTime-sTime,digits=3)
msg="The file has been created in $(eTime) seconds successfully inside the 'public' folder of the app"
selectedTab="tab1"
#println("all msi in folder=",triq_bmp)
#println("all col msi in folder= ",col_triq_png)
@ -305,7 +299,9 @@ end
msi_bmp=sort(filter(filename -> startswith(filename, "MSI_") && endswith(filename, ".bmp"), readdir("public")),lt=natural)
col_msi_png=sort(filter(filename -> startswith(filename, "colorbar_MSI_") && endswith(filename, ".png"), readdir("public")),lt=natural)
selectedTab="tab0"
msg="The file has been created successfully inside the 'public' folder of the app."
fTime=time()
eTime=round(fTime-sTime,digits=3)
msg="The file has been created in $(eTime) seconds successfully inside the 'public' folder of the app"
#println("all msi in folder=",msi_bmp)
#println("all col msi in folder= ",col_msi_png)
end
@ -330,13 +326,13 @@ end
@onbutton createSumPlot begin
msg="Sum spectrum plot selected"
sTime=time()
#full_route=joinpath( file_route, file_name )
if isfile(full_route) # Check if the file exists
btnPlotDisable=false
btnStartDisable=false
full_routeMz=split( full_route, "." )[1] * ".mzML" # Splitting the route from imzml to mzml so the plotting can work
if isfile(full_routeMz) && (full_routeMz2 == "" || full_routeMz2 != full_routeMz) # Check if the mzml exists
println("I'm working as intended")
progressPlot=true
btnPlotDisable=true
btnStartDisable=true
@ -366,10 +362,12 @@ end
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS
end
selectedTab="tab2"
msg="Plot loaded."
fTime=time()
eTime=round(fTime-sTime,digits=3)
msg="Plot loaded in $(eTime) seconds"
full_routeMz2=full_routeMz # To avoid creating the plot if its the same file read as before
else
msg="the mzML file was not found"
msg="the mzML file was not found or you're trying to load the same mzML"
warning_msg=true
end
else
@ -383,7 +381,7 @@ end
# Image loaders based on the position of the current image (increment and decrement for both normal and filter)
# And a pre-generated list from all image files from /public folder
@onbutton ImgMinus begin
@onbutton imgMinus begin
# Append a query string to force the image to refresh
timestamp=string(time_ns())
# Update the array of images listed in the public folder
@ -402,7 +400,7 @@ end
text_nmass=replace(text_nmass, ".bmp" => "")
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
end
@onbutton ImgPlus begin
@onbutton imgPlus begin
# Append a query string to force the image to refresh
timestamp=string(time_ns())
# Update the array of images listed in the public folder
@ -422,7 +420,7 @@ end
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
end
@onbutton ImgMinusT begin
@onbutton imgMinusT begin
# Append a query string to force the image to refresh
timestamp=string(time_ns())
new_msi=decrement_image(current_triq, triq_bmp)
@ -441,7 +439,7 @@ end
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
end
@onbutton ImgPlusT begin
@onbutton imgPlusT begin
# Append a query string to force the image to refresh
timestamp=string(time_ns())
new_msi=increment_image(current_triq, triq_bmp)
@ -466,6 +464,7 @@ end
cleaned_imgInt=replace(imgInt, r"\?.*" => "")
cleaned_imgInt=lstrip(cleaned_imgInt, '/')
var=joinpath( "./public", cleaned_imgInt )
sTime=time()
if isfile(var)
progressPlot=true
@ -531,7 +530,9 @@ end
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS
end
selectedTab="tab4"
msg="Plot loaded."
fTime=time()
eTime=round(fTime-sTime,digits=3)
msg="Plot loaded in $(eTime) seconds"
catch e
msg="Failed to load and process image: $e"
warning_msg=true
@ -551,6 +552,7 @@ end
cleaned_imgIntT=replace(imgIntT, r"\?.*" => "")
cleaned_imgIntT=lstrip(cleaned_imgIntT, '/')
var=joinpath( "./public", cleaned_imgIntT )
sTime=time()
if isfile(var)
progressPlot=true
@ -610,7 +612,9 @@ end
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS
end
selectedTab="tab4"
msg="Plot loaded."
fTime=time()
eTime=round(fTime-sTime,digits=3)
msg="Plot loaded in $(eTime) seconds"
catch e
msg="Failed to load and process image: $e"
warning_msg=true
@ -631,6 +635,7 @@ end
cleaned_imgInt=replace(imgInt, r"\?.*" => "")
cleaned_imgInt=lstrip(cleaned_imgInt, '/')
var=joinpath("./public", cleaned_imgInt)
sTime=time()
if isfile(var)
progressPlot=true
@ -676,7 +681,9 @@ end
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure Julia returns the freed memory to OS
end
selectedTab="tab3"
msg="Plot loaded."
fTime=time()
eTime=round(fTime-sTime,digits=3)
msg="Plot loaded in $(eTime) seconds"
catch e
msg="Failed to load and process image: $e"
warning_msg=true
@ -696,6 +703,7 @@ end
cleaned_imgIntT=replace(imgIntT, r"\?.*" => "")
cleaned_imgIntT=lstrip(cleaned_imgIntT, '/')
var=joinpath("./public", cleaned_imgIntT)
sTime=time()
if isfile(var)
progressPlot=true
@ -741,7 +749,9 @@ end
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure Julia returns the freed memory to OS
end
selectedTab="tab3"
msg="Plot loaded."
fTime=time()
eTime=round(fTime-sTime,digits=3)
msg="Plot loaded in $(eTime) seconds"
catch e
msg="Failed to load and process image: $e"
warning_msg=true
@ -756,7 +766,7 @@ end
btnStartDisable=false
end
@onbutton CompareBtn begin
@onbutton compareBtn begin
CompareDialog=true
end

View File

@ -100,7 +100,7 @@
Loading...
</template>
</q-btn>
<q-btn id="btnStyle" icon="zoom_out_map" class="q-ma-sm on-right" v-on:click="CompareBtn=true" padding="sm" label="Compare"></q-btn>
<q-btn id="btnStyle" icon="zoom_out_map" class="q-ma-sm on-right" v-on:click="compareBtn=true" padding="sm" label="Compare"></q-btn>
</div>
<p>{{msg}}</p>
</div>
@ -115,8 +115,8 @@
<!-- Btn image changer -->
<h6>Image Visualizer</h6>
<div>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="ImgMinus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="ImgPlus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="imgMinus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="imgPlus=true"></q-btn>
</div>
<!-- Image manager -->
<div id="image-container" class="row st-col col-12 items-center">
@ -135,8 +135,8 @@
<!-- Triq Btn image changer -->
<h6>TrIQ Visualizer</h6>
<div>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="ImgMinusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="ImgPlusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="imgMinusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="imgPlusT=true"></q-btn>
</div>
<!-- Triq Image manager -->
<div id="image-container" class="row st-col col-12 items-center">
@ -197,8 +197,8 @@
<!-- Content for Tab 0 -->
<!-- Btn image changer -->
<div>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="ImgMinus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="ImgPlus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="imgMinus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="imgPlus=true"></q-btn>
</div>
<!-- Image manager -->
<div id="image-container" class="row st-col col-12 items-center">
@ -216,8 +216,8 @@
<!-- Content for Tab 1 -->
<!-- Triq Btn image changer -->
<div>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="ImgMinusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="ImgPlusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="imgMinusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="imgPlusT=true"></q-btn>
</div>
<!-- Triq Image manager -->
<div id="image-container" class="row st-col col-12 items-center">
@ -251,8 +251,8 @@
<!-- Content for Tab 0 -->
<!-- Btn image changer -->
<div>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="ImgMinus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="ImgPlus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="imgMinus=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="imgPlus=true"></q-btn>
</div>
<!-- Image manager -->
<div id="image-container" class="row st-col col-12 items-center">
@ -270,8 +270,8 @@
<!-- Content for Tab 1 -->
<!-- Triq Btn image changer -->
<div>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="ImgMinusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="ImgPlusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_back" class="q-my-sm" v-on:click="imgMinusT=true"></q-btn>
<q-btn id="btnStyle" icon="arrow_forward" class="q-my-sm on-right" v-on:click="imgPlusT=true"></q-btn>
</div>
<!-- Triq Image manager -->
<div id="image-container" class="row st-col col-12 items-center">

View File

@ -1,18 +1,11 @@
PENDING
Rmsi & julia coherence with image creation and colorbar
avoid image enlargement -> CURRENT WIP
image flip upside down
colorbar revamp
Multiple plot types
Tag for time it takes in creating image and creating plots -> CURRENT WIP
Create function that makes the imzML from mzML files
Create function that makes the imzML from mzML files ?
Possibility to add multiple imzML to process at once ?
Pixel selection marks
Rotate vertical images
Easier input for files
TrIQ default values
Comparative for two values
Per pixel of image plot creation for spectra
Multiple spectra plot types
Even faster initial boot and subsectuential boot
DONE
Quicker start for julia GUI
@ -23,4 +16,11 @@ DONE
Code cleanse
better code readability
Better blind search for images
3d topography for images
3d topology plots for images
2d contour plots for images
Image flip upside down
Tag for time it takes in creating image and creating plots
Rotate vertical images
Easier input for files
TrIQ default values
Comparative for two views