rordenlab/MRIcroGL

Looking for script command for "Hide voxels with zero intensity"

mahirtazwar opened this issue · 2 comments

I am trying to write a script to display a statistical map (with positive and negative values) over a template. The overlay has the colormap "NIH".

On the GUI, I can check the option "Hide Voxels with Zero Intensity" for the overlay, and it shows the positive and negative values like I wanted (as demonstrated below).

Screen Shot 1

However, when trying to script to get the same outcome, I could not find the appropriate command for "Hide Voxels with Zero Intensity". The command gl.overlaymaskwithbackground(1) does not work (as shown below, zero in overlay = red color).

Screen Shot 2

Over at MRIcroGL10_OLD/COMMANDS.md, I found the command gl.overlayhidezeros(1), which does not appear to work with the current version of MRIcroGL.

Is there any command or way to hide the zero intensity voxels? As an alternative, I am using the command gl.wait(5000) to check the "Hide Voxels with Zero Intensity" option manually when the window pops up, and this solves my issue. But I would much rather automate the process with scripts. A segment of my script is given below for reference.

import gl
gl.resetdefaults()
gl.backcolor(255,255,255)     ## White background
gl.bmpzoom(2)
gl.loadimage("template.nii.gz")
gl.sharpen()
gl.overlayload("statFile.nii.gz")
gl.opacity(1,100)
gl.colorname(1,"NIH")
# gl.overlaymaskwithbackground(1)
gl.wait(5000)
  1. I would avoid the NIH color scheme - this is provided for historical replication only. Consider viridis, magma or mako. For details see here and here.
  2. You will want to set the intensity range for the overlay. For example, this script creates an image with the range -2...-7.
import gl
gl.resetdefaults()
gl.loadimage('spm152')
gl.overlayload('spmMotor')
gl.minmax(1, -2, -7)
gl.opacity(1,100)
gl.colorname (1,"NIH")
gl.orthoviewmm(-37,-19,50)

gl

  1. If you want to show positive and negative color schemes, load the map twice. The Scripting/Templates/basic menu item shows you how:
import gl
gl.resetdefaults()
gl.loadimage('spm152')
gl.overlayload('spmMotor')
gl.minmax(1, 2, 9)
gl.colorname (1,"magma")
gl.opacity(1,100)
gl.overlayload('spmMotor')
gl.minmax(2, -2, -9)
gl.colorname (2,"mako")
gl.orthoviewmm(-37,-19,50)

mako

Thank you for the detailed response. It looks like there is no command for "Hide Voxels with Zero Intensity", and the solution is to load the overlay twice and specify the minimum and maximum values using gl.minmax() command while avoiding $0$ value. For example,

gl.minmax(1, -0.0001, -0.62)
gl.minmax(2, 0.0001, 0.03)

As for colormap, I am trying to use a modified version of HSV (without the cyclic component) color scale (CLUT given below for reference). I will check out the resources you've provided to see if my custom color scale can work.

[FLT]
min=0
max=0
[INT]
numnodes=6
[BYT]
nodeintensity0=0
nodeintensity1=51
nodeintensity2=85
nodeintensity3=128
nodeintensity4=204
nodeintensity5=255
[RGBA255]
nodergba0=255|0|0|0
nodergba1=255|255|0|14
nodergba2=0|255|0|28
nodergba3=0|255|255|43
nodergba4=0|0|255|57
nodergba5=255|0|255|71