From e3e987f0cdbf9a424d125d40494b1023352e3a27 Mon Sep 17 00:00:00 2001 From: Pixelguy14 Date: Sat, 15 Feb 2025 15:40:13 -0600 Subject: [PATCH] Fixed some errors to get ready for release --- app.jl | 57 +++++++++++++++++-------------------------- app.jl.html | 7 ------ config/env/global.jl | 2 +- executable.sh | 18 -------------- julia_imzML_visual.jl | 34 ++++++++++++++++++++++++++ start_MSI_GUI.jl | 20 --------------- 6 files changed, 58 insertions(+), 80 deletions(-) delete mode 100755 executable.sh diff --git a/app.jl b/app.jl index a1c16c0..07ef7d0 100644 --- a/app.jl +++ b/app.jl @@ -59,7 +59,6 @@ include("./julia_imzML_visual.jl") @in triq3dPlot=false # To generate 3d plot based on current triq image @in imageCPlot=false # To generate contour plots of current image @in triqCPlot=false # To generate contour plots of current triq image - @in btnCreateImz=false # To start process for creating imzML and Ibd with mzML and Syncro # Image change buttons @in imgPlus=false @in imgMinus=false @@ -274,13 +273,32 @@ include("./julia_imzML_visual.jl") btnSpectraDisable=false SpectraEnabled=true # Splitting the route the same way - full_route=replace(full_route, r"\.[^.]*$" => ".imzML") + full_route=replace(full_route, r"\.[^.]*$" => ".imzML") if isfile(full_route) btnStartDisable=false else btnStartDisable=true full_route=full_routeMz end + progressSpectraPlot=true + btnPlotDisable=true + btnStartDisable=true + msg="Loading SUM spectrum plot..." + sTime=time() + plotdata, plotlayout, xSpectraMz, ySpectraMz=sumSpectrumPlot(full_routeMz) + progressSpectraPlot=false + btnPlotDisable=false + if endswith(full_route, "imzML") + btnStartDisable=false + end + if isfile(full_routeMz) + # We enable coord search and spectra plot creation + btnSpectraDisable=false + SpectraEnabled=true + end + fTime=time() + eTime=round(fTime-sTime,digits=3) + msg="Plot loaded in $(eTime) seconds" end xCoord=0 yCoord=0 @@ -388,9 +406,7 @@ include("./julia_imzML_visual.jl") else msg="File does not exist or a parameter is incorrect, please try again." warning_msg=true - end - spectra=nothing # Important for memory cleaning - slice=nothing + end| GC.gc() # Trigger garbage collection if Sys.islinux() ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS @@ -414,30 +430,7 @@ include("./julia_imzML_visual.jl") btnPlotDisable=true btnStartDisable=true msg="Loading plot..." - spectraMz=LoadMzml(full_routeMz) - layoutSpectra=PlotlyBase.Layout( - title="SUM Spectrum plot", - xaxis=PlotlyBase.attr( - title="m/z", - showgrid=true - ), - yaxis=PlotlyBase.attr( - title="Intensity", - showgrid=true - ), - autosize=false, - margin=attr(l=0,r=0,t=120,b=0,pad=0) - ) - try - xSpectraMz=mean(spectraMz[1,:]) - ySpectraMz=mean(spectraMz[2,:]) - catch e - xSpectraMz=spectraMz[1,1] - ySpectraMz=spectraMz[2,1] - end - traceSpectra=PlotlyBase.scatter(x=xSpectraMz, y=ySpectraMz, mode="lines") - plotdata=[traceSpectra] # We add the data from spectra to the plot - plotlayout=layoutSpectra + plotdata, plotlayout, xSpectraMz, ySpectraMz=sumSpectrumPlot(full_routeMz) GC.gc() # Trigger garbage collection if Sys.islinux() ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS @@ -463,7 +456,7 @@ include("./julia_imzML_visual.jl") end @onbutton createXYPlot begin - msg="Sum spectrum plot selected" + msg="XY spectrum plot selected" sTime=time() if isfile(full_routeMz) # Check if the file exists progressSpectraPlot=true @@ -917,10 +910,6 @@ include("./julia_imzML_visual.jl") CompareDialog=true end - @onbutton btnCreateImz begin - msg="Not yet implemented" - end - # To include a visualization in the spectrum plot indicating where is the selected mass @onchange Nmass begin if !isempty(xSpectraMz) diff --git a/app.jl.html b/app.jl.html index ea456c0..e1e6b49 100644 --- a/app.jl.html +++ b/app.jl.html @@ -90,13 +90,6 @@ ]" :readonly="!SpectraEnabled" :disable="!SpectraEnabled"> - - -
diff --git a/config/env/global.jl b/config/env/global.jl index 5ea3d97..0b24049 100644 --- a/config/env/global.jl +++ b/config/env/global.jl @@ -1 +1 @@ -ENV["GENIE_ENV"] = "dev" +ENV["GENIE_ENV"] = "prod" diff --git a/executable.sh b/executable.sh deleted file mode 100755 index 934834e..0000000 --- a/executable.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -command="julia --project=. start_MSI_GUI.jl" - -case "$OSTYPE" in - linux*) - $command - ;; - darwin*) - $command - ;; - cygwin*|msys*|win32) - julia --project=. start_MSI_GUI.jl - ;; - *) - echo "Unsupported OS" - ;; -esac diff --git a/julia_imzML_visual.jl b/julia_imzML_visual.jl index f35973e..ef85f57 100644 --- a/julia_imzML_visual.jl +++ b/julia_imzML_visual.jl @@ -405,3 +405,37 @@ function medianFilterjl(pixMap) return target end +# sumSpectrumPlot recieves the local directory of the image as a string, +# returns the layout and data for the surface plotly plot +# this function loads the spectra data and makes a mean to display +# its values in the spectrum plot +function sumSpectrumPlot(mzmlRoute::String) + spectraMz=LoadMzml(mzmlRoute) + xSpectraMz=Float64[] + ySpectraMz=Float64[] + + layout=PlotlyBase.Layout( + title="SUM spectrum plot", + xaxis=PlotlyBase.attr( + title="m/z", + showgrid=true + ), + yaxis=PlotlyBase.attr( + title="Intensity", + showgrid=true + ), + autosize=false, + margin=attr(l=0,r=0,t=120,b=0,pad=0) + ) + try + xSpectraMz=mean(spectraMz[1,:]) + ySpectraMz=mean(spectraMz[2,:]) + catch e + xSpectraMz=spectraMz[1,1] + ySpectraMz=spectraMz[2,1] + end + trace=PlotlyBase.scatter(x=xSpectraMz, y=ySpectraMz, mode="lines") + plotdata=[trace] # We add the data from spectra to the plot + plotlayout=layout + return plotdata, plotlayout, xSpectraMz, ySpectraMz +end \ No newline at end of file diff --git a/start_MSI_GUI.jl b/start_MSI_GUI.jl index 973cbd6..0d69ef8 100644 --- a/start_MSI_GUI.jl +++ b/start_MSI_GUI.jl @@ -4,26 +4,6 @@ Pkg.activate(".") Pkg.instantiate() Pkg.gc() -""" -packages = [ - "GenieFramework", "Libz", "PlotlyBase", "CairoMakie", "Colors", - "Statistics", "NaturalSort", "Genie", - "Images", "LinearAlgebra", "NativeFileDialog", "StipplePlotly" -] - -# Check for missing packages -for pkg in packages - if !(pkg in keys(Pkg.dependencies())) - Pkg.add(pkg) - end -end - -# Add library for mzML imzML from GitHub if missing -if !("julia_mzML_imzML" in keys(Pkg.dependencies())) - Pkg.add(url="https://github.com/CINVESTAV-LABI/julia_mzML_imzML") -end -""" - using Genie # Load and configure Genie