help > Adding a customised legend
Showing 1-4 of 4 posts
Jan 31, 2021 11:01 AM | sankaritarina
Adding a customised legend
Hello,
I have written my first script for MRIcroGL! I have added two overlays and specified their colours, now I would like to add a legend that shows the colours and a corresponding label that I would like to specify.
Also, I have used mosaic to show S, C and A slices but they are poorly aligned. How can I move the S slice up a bit?
Is that possible?
Cheers!
I have written my first script for MRIcroGL! I have added two overlays and specified their colours, now I would like to add a legend that shows the colours and a corresponding label that I would like to specify.
Also, I have used mosaic to show S, C and A slices but they are poorly aligned. How can I move the S slice up a bit?
Is that possible?
Cheers!
Jan 31, 2021 12:01 PM | Chris Rorden
RE: Adding a customised legend
You can use the colorbarposition function to adjust whether the
colorer is visible or hidden
gl.colorbarposition(2)
You can export your image as a bitmap with this function:
gl.savebmp('mybitmap.png')
which will allow you to decorate your image with your favorite bitmap editor. My own suggestion would be to create your mosaics without text labels ("-L") and then use a vector-art tool like illustrator to add text. The vector text will appear sharper in high resolution layouts than bitmaps.
The Scripting/Templates/help provides an exhaustive list of the in-built Python functions. The Scripting/Templates/mosaic scripts also illustrate showing high quality images.
gl.colorbarposition(2)
You can export your image as a bitmap with this function:
gl.savebmp('mybitmap.png')
which will allow you to decorate your image with your favorite bitmap editor. My own suggestion would be to create your mosaics without text labels ("-L") and then use a vector-art tool like illustrator to add text. The vector text will appear sharper in high resolution layouts than bitmaps.
The Scripting/Templates/help provides an exhaustive list of the in-built Python functions. The Scripting/Templates/mosaic scripts also illustrate showing high quality images.
Jan 31, 2021 02:01 PM | sankaritarina
RE: Adding a customised legend
Okay, then I'll create my legend outside of MRIcroGL.
However, my sagittal slice is still cut off at the bottom, is there a way to properly align this?
However, my sagittal slice is still cut off at the bottom, is there a way to properly align this?
Jan 31, 2021 05:01 PM | Chris Rorden
RE: Adding a customised legend
The sagittal slice is not cut off at the bottom. The brain field of
view only shows a limited amount of the neck. You can see that the
sagittal slice is perfectly aligned with the coronal images and the
sagitall rendering by including a coronal slice that includes more
of the spinal column, for example y = -50mm in MNI space:
import gl
gl.resetdefaults()
#open background image
gl.loadimage('spm152')
#open overlay: show positive regions
gl.overlayload('spmMotor')
gl.minmax(1, 4, 4)
gl.opacity(1,50)
#open overlay: show negative regions
gl.overlayload('spmMotor')
gl.minmax(2, -4, -4)
gl.colorname (2,"3blue")
gl.mosaic("C 20 -50 S 0 20 S X R 0");
It is true that your image is longer in the A-P direction (Y) than the I-S (Z) direction, so the axial slice will appear taller than the coronal and sagittal slices. This reflects the field of view of your image. You may want to use the semicolon ";" to place your axial slices on a separate row from the coronal and sagittal slices. The screen height for axial slices is the Y-dimension, while it is the Z-dimension for the coronal and sagittal slices. In contrast, the screen width is the X-dimension for the axial and coronal slices, but the Y dimension for sagittal slices. You can always create your own template images with any field of view you wish.
import gl
gl.resetdefaults()
#open background image
gl.loadimage('spm152')
#open overlay: show positive regions
gl.overlayload('spmMotor')
gl.minmax(1, 4, 4)
gl.opacity(1,50)
#open overlay: show negative regions
gl.overlayload('spmMotor')
gl.minmax(2, -4, -4)
gl.colorname (2,"3blue")
gl.mosaic("A 10 20 30 40 ; C 20 -50 S 0 20 ");
import gl
gl.resetdefaults()
#open background image
gl.loadimage('spm152')
#open overlay: show positive regions
gl.overlayload('spmMotor')
gl.minmax(1, 4, 4)
gl.opacity(1,50)
#open overlay: show negative regions
gl.overlayload('spmMotor')
gl.minmax(2, -4, -4)
gl.colorname (2,"3blue")
gl.mosaic("C 20 -50 S 0 20 S X R 0");
It is true that your image is longer in the A-P direction (Y) than the I-S (Z) direction, so the axial slice will appear taller than the coronal and sagittal slices. This reflects the field of view of your image. You may want to use the semicolon ";" to place your axial slices on a separate row from the coronal and sagittal slices. The screen height for axial slices is the Y-dimension, while it is the Z-dimension for the coronal and sagittal slices. In contrast, the screen width is the X-dimension for the axial and coronal slices, but the Y dimension for sagittal slices. You can always create your own template images with any field of view you wish.
import gl
gl.resetdefaults()
#open background image
gl.loadimage('spm152')
#open overlay: show positive regions
gl.overlayload('spmMotor')
gl.minmax(1, 4, 4)
gl.opacity(1,50)
#open overlay: show negative regions
gl.overlayload('spmMotor')
gl.minmax(2, -4, -4)
gl.colorname (2,"3blue")
gl.mosaic("A 10 20 30 40 ; C 20 -50 S 0 20 ");