Hello, this is my first go at using Julia and GLMakie.
The goal is to display a 3D MIP CT image extracted from DICOM data.
Julia 1.6
DICOM v0.10.0
AbstractPlotting v0.17.3
GLMakie v0.2.6
Windows 10 x64
Visual Studio Code 1.55.2
Version 1 code:
module QntImageDisplay
using ModernGL
using GLMakie
using Colors
export static_image_display_v_1
function static_image_display_v_1(
imageVolume::Array{Float32, 3})
set_window_config!(
float=true,
framerate = 60.0,
title = "Qnt3DMIPDisplay")
set_theme!(backgroundcolor = :indigo)
voxelScalarCutoffMin::Float32 = -200.0
voxelScalarMax::Float32 = maximum(imageVolume)
image3D = volume(
imageVolume, # (rows, columns, slices) order
algorithm=:mip,
colormap=:grays,
colorrange = (voxelScalarCutoffMin, voxelScalarMax))
display(image3D)
end
end
3D_MP_Display_v_1_2021_04_19.jpg “Sorry, new users can only put one embedded media item in a post.”
This code works as expected. However, the spatial aspect is not correct - the patient looks like he has been subjected to the medieval rack. I next tried to use Axis3 to display the correct spatial aspect based upon my understanding of the Axis3 Makie documentation
Version 2 code:
module QntImageDisplay
using ModernGL
using GLMakie
using Colors
export static_image_display_v_2
function static_image_display_v_2(
imageVolume::Array{Float32, 3},
spatialExtent::Vector{Float32})
set_window_config!(
float=true,
framerate = 60.0,
title = "Qnt3DMIPDisplay")
set_theme!(backgroundcolor = :indigo)
figure = Figure(
resolution = (1280, 720),
fontsize = 12)
# In this example: spatialExtent Float32[380.416, 380.416, 401.0]
axis3 = Axis3(
figure[1, 1],
aspect = (
spatialExtent[1],
spatialExtent[2],
spatialExtent[3]),
viewmode = :fitzoom)
voxelScalarCutoffMin::Float32 = -200.0
voxelScalarMax::Float32 = maximum(imageVolume)
volume!(
imageVolume,
algorithm=:mip,
colormap=:grays,
colorrange = (voxelScalarCutoffMin, voxelScalarMax))
display(figure)
end
end
Issues:
The 3D image spatial aspect is now correct. However, the mouse controls do not respond as expected.
- Right mouse button: no pan
- Middle mouse button: no zoom
- Left mouse button. Rotation restricted to half of one full rotation. Rotation appears to be convolved with zoom.
Is there a problem with my use of Figure and/or Axis3 in the above code or are these Axis3 issues?
Also, a general beginner’s question. To get GLMakie to display the output, I found that I had to run the top level file in the REPL as
julia> include(“QntMain.jl”)
rather than “Run code” of the .run extension. Is this a feature or am I missing something?