Dear MRtrix community,
To make a movie, I want to generate the frames using a for loop in which MRview is called from commandline. I have a T1 image overlayed with a specific map with given intensity range, colourbar and opacity. I use the following bash code within the loop:
mrview -load "$workingDir"/t1w.nii -intensity_range 0,1000000 -noannotation -voxelinfo 0 \
-overlay.load "$concentrationmapToLoad" \
-overlay.opacity 0.4 \
-overlay.colourmap 1 \
-overlay.intensity 100,1000 \
-overlay.threshold_min 100 \
-overlay.interpolation 1 \
-capture.folder "$workingDir" \
-capture.prefix movie_ \
-capture.grab
Unfortunately, the colourmap for the overlay is not applied (it keeps using the gray colourmap instead of the hot colourmap) and the overlay intensities are not applied. However, when I run the code and the MRview window appears, the settings are correctly set in the GUI. It is only after I click on the Overlay - Max intensity and hit ‘Enter’ button on my key board, that the settings are applied. But this is of course not convenient as it requires manual intervention which is unwanted.
Anyone has any idea?
Thank you in advance
The debug message from mrview -debug shows the following:
```text mrview: [DEBUG] No config file found at "/etc/mrtrix.conf" mrview: [DEBUG] No config file found at "/home/inge/.mrtrix.conf" mrview: [INFO] GL renderer: Quadro K600/PCIe/SSE2 mrview: [INFO] GL version: 3.3.0 NVIDIA 440.31 mrview: [INFO] GL vendor: NVIDIA Corporation mrview: [DEBUG] loading font into OpenGL texture... mrview: [DEBUG] compiling OpenGL vertex shader: #version 330 core layout(location = 0) in vec2 pos; layout(location = 1) in vec2 font_pos; uniform float scale_x; uniform float scale_y; out vec2 tex_coord; void main () { gl_Position = vec4 (pos[0]*scale_x-1.0, pos[1]*scale_y-1.0, 0.0, 1.0); tex_coord = font_pos; }mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in vec2 tex_coord;
uniform sampler2D sampler;
uniform float red, green, blue;
out vec4 color;
void main () {
color.ra = texture (sampler, tex_coord).rg;
color.rgb = color.r * vec3 (red, green, blue);
}
mrview: [DEBUG] font loaded
mrview: [INFO] opening image “/home/inge/CVO/SC452/t1w.nii”…
mrview: [DEBUG] memory-mapping file “/home/inge/CVO/SC452/t1w.nii”…
mrview: [DEBUG] file “/home/inge/CVO/SC452/t1w.nii” mapped at 0x7f5676bff000, size 20971872 (read-only)
mrview: [DEBUG] transforms_match: FOV difference in scanner coordinates: 2.5702313851701569e-07
mrview: [DEBUG] unmapping file “/home/inge/CVO/SC452/t1w.nii”
mrview: [DEBUG] sanitising image information…
mrview: [INFO] image “/home/inge/CVO/SC452/t1w.nii” opened with dimensions 160x256x256, voxel spacing 1x1x1, datatype Int16LE
mrview: [DEBUG] memory-mapping file “/home/inge/CVO/SC452/t1w.nii”…
mrview: [DEBUG] file “/home/inge/CVO/SC452/t1w.nii” mapped at 0x7f5676bff000, size 20971520 (read-only)
mrview: [DEBUG] image “/home/inge/CVO/SC452/t1w.nii” loaded
mrview: [DEBUG] image “/home/inge/CVO/SC452/t1w.nii” initialised with strides = [ 1 160 40960 ], start = 0, using indirect IO
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
gl_Position = MVP * vec4 (vertpos,1);
texcoord = texpos;
}
mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
texcoord.t < 0.0 || texcoord.t > 1.0 ||
texcoord.p < 0.0 || texcoord.p > 1.0) discard;
color = texture (tex, texcoord.stp);
float amplitude = color.r;
if (isnan(amplitude) || isinf(amplitude)) discard;
amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
color.rgb = vec3 (amplitude);
}
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
gl_Position = vec4 (pos, 0.0, 1.0);
}
mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
color = vec4 (0.5, 0.5, 0.0, 1.0);
}
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 data;
uniform float scale_x, scale_y;
out float amplitude;
void main () {
gl_Position = vec4 (data.xscale_x-1.0, data.yscale_y-1.0, 0.0, 1.0);
amplitude = data.z;
}
mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in float amplitude;
out vec3 color;
uniform vec3 colourmap_colour;
void main () {
color.rgb = vec3 (amplitude);
}
mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
color = vec3(1.0, 1.0, 0.0);
}
mrview: [INFO] opening image “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii”…
mrview: [DEBUG] memory-mapping file “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii”…
mrview: [DEBUG] file “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii” mapped at 0x7f56743fe000, size 41943392 (read-only)
mrview: [DEBUG] transforms_match: FOV difference in scanner coordinates: 2.5701358558757657e-07
mrview: [DEBUG] unmapping file “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii”
mrview: [DEBUG] sanitising image information…
mrview: [INFO] image “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii” opened with dimensions 160x256x256, voxel spacing 1x1x1, datatype Float32LE
mrview: [DEBUG] memory-mapping file “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii”…
mrview: [DEBUG] file “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii” mapped at 0x7f56743fe000, size 41943040 (read-only)
mrview: [DEBUG] image “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii” loaded
mrview: [DEBUG] image “/home/inge/CVO/SC452/concentration_uM_filtered_t1w_space_vol_0019.nii” initialised with strides = [ 1 160 40960 ], start = 0, using indirect IO
mrview: [INFO] mrview: loading image data
mrview: [INFO] mrview: loading image data [done]
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
gl_Position = MVP * vec4 (vertpos,1);
texcoord = texpos;
}
mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
texcoord.t < 0.0 || texcoord.t > 1.0 ||
texcoord.p < 0.0 || texcoord.p > 1.0) discard;
color = texture (tex, texcoord.stp);
float amplitude = color.r;
if (isnan(amplitude) || isinf(amplitude)) discard;
if (amplitude < alpha_offset) discard;
color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
color.rgb = vec3 (2.7213 * amplitude, 2.7213 * amplitude - 1.0, 3.7727 * amplitude - 2.7727);
}
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
gl_Position = MVP * vec4 (vertpos,1);
texcoord = texpos;
}
mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float lower;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
texcoord.t < 0.0 || texcoord.t > 1.0 ||
texcoord.p < 0.0 || texcoord.p > 1.0) discard;
color = texture (tex, texcoord.stp);
float amplitude = color.r;
if (isnan(amplitude) || isinf(amplitude)) discard;
if (amplitude < lower) discard;
if (amplitude < alpha_offset) discard;
color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
color.rgb = vec3 (2.7213 * amplitude, 2.7213 * amplitude - 1.0, 3.7727 * amplitude - 2.7727);
}
</details>