3D Medical Imaging

Examples

Introduction

MRIcroGL includes a scripting language that allows you to automate many functions. To run these scripts, launch MRIcroGL and choose View/Scripting. Then paste the code into the scripting window and select the Script/Run command. For more information on scripting, see the Scripting web page.

carpCarp

This code shows a rendering of a fish. The edge detection routine allows you to see both the skin on the surface and the deep organs, while hiding the tissue in between. If you choose View/Transparency|Color after running this script you will see the why this script uses a couple of extra nodes to create a stair-case like color scheme: the skin is made very transparent while the bone is much more opaque.

begin
    RESETDEFAULTS;
    LOADIMAGE('carp');
    EDGEDETECT(4, 2);
    CONTRASTMINMAX(1, 255);
    CHANGENODE(2, 255, 255, 255, 255, 128);
    ADDNODE(83, 184, 55, 41,10);
    ADDNODE(122, 230, 230, 160, 62);
end.//Carp

clipClip

This script cleaves off one side of the image. Note that the clipping.

const
    kTime= 15;
var
    i: integer;
begin
    RESETDEFAULTS;
    LOADIMAGE('ch256');
    CLIPFORMVISIBLE(true);
    wait(500);
     AZIMUTH(40);
    for i := 1 to 9 do begin
        CLIP(i/15);
           wait(ktime);
    end;
    ADDNODE(128, 123, 88, 167,32);
    wait(ktime);
    elevation(-15);
    for i := 1 to 6 do begin
          azimuth(-10);
          wait(ktime);
    end;
end. //Clip

colorColordemo

This demo illustrates how you can adjust adjust the mapping of image intensity to image color and transparency. For example, we can effectively segment the image so that the kidneys appear red, bones appear white and other tissue is invisible.

const
    kTime= 15;
    kSteps= 36;
var
   i: integer;
begin
    RESETDEFAULTS;
    LOADIMAGE('abdo256');
    CONTRASTFORMVISIBLE(true);
    COLORNAME('ct_bones');
    for i := 1 to kSteps do begin
        AZIMUTH(10);
        wait(ktime);
    end;
    ELEVATION(-30);
    ADDNODE(192, 178, 94, 84, 128);
    CONTRASTMINMAX(0, 300);
    for i := 1 to kSteps do begin
         AZIMUTH(10);
         wait(ktime);
    end;
    COLORNAME('ct_kidneys');
    CHANGENODE(1, 100, 255, 100, 100,64);
    for i := 1 to 63 do begin
        AZIMUTH(10);
        wait(ktime);
    end;
end. //colordemo

cutoutCutoutdemo

This script adds axial slices to the image, so that at the start of the movie we only see the inferior portions of the brain, but over time we can see the whole brain.

const
    kTime= 15;
    kSteps= 8;
var
 gt: integer;
begin
    RESETDEFAULTS;
    loadimage('ch256');
    VIEWCORONAL(true);
      elevation(-30);
    for gt := 1 to ksteps do begin
        cutout(0,0,gt/ksteps,1,1,1);
             azimuth(10);
              wait(ktime);
      end;
end.//Cutoutdemo

cutout2Cutoutdemo2

This script removes different blocks from the visible human, allowing us to look inside.

const
    kTime= 15;
    kSteps= 5;
var
 lF: single;
 gt: integer;
begin
    RESETDEFAULTS;
    loadimage('visiblehuman');
    AZIMUTHELEVATION(115, 15);
    for gt := 1 to ksteps do begin
              wait(ktime);
        lF := gt * 0.1;
        cutout(0,lF,0.2,1,lF+0.25,1);
      end;
end. //Colordemo2

distanceDistancedemo

This animation starts with a view from inside the brain, over time the brain spins off into the distance.

const
    kTime= 15;
    kSteps= 36;
var
    i: integer;
begin
    RESETDEFAULTS;
    LOADIMAGE('ch256');
    for i := 1 to kSteps do begin
        cameradistance(i*0.3);
        azimuth(10);
        wait(ktime);
    end;
end.//Distancedemo

glassbrainGlassbrain

This demo makes uses edge detection and the image transparency to only show the surface of the brain structures, hiding the other tissue. This helps us visualize the location of brain activity located deep in the brain.

const
    kTime= 15;
    kSteps= 12;

var
   i: integer;
begin
    RESETDEFAULTS;
    loadimage('ch256');
    EDGEDETECT(2, 3);
    CHANGENODE(1, 1, 1, 255, 255, 25);
    ADDNODE(128, 123, 88, 167,12);
    OVERLAYLOAD('attention');
    OVERLAYMASKEDBYBACKGROUND(false);
    OVERLAYMINMAX(1, 2, 5);
    wait(ktime);
    elevation(-15);
    for i := 1 to kSteps do begin
          azimuth(-8);
          wait(ktime);
    end;
end.//Glassbrain

mipMaximumintensityprojection

Typically, rendering shows the surface of an object. However, the goal of maximum intensity projections is to show the brightest part of an object, regardless of its distance from the viewer. This demo shows how this technique can help when viewing angiography..

const
    kTime= 15;
    kSteps= 10;
var
 i: integer;
begin
    RESETDEFAULTS;
    LOADIMAGE('chris_MRA');
    for i := kSteps downto 0 do begin
        AZIMUTHELEVATION(i*10, 30);
        wait(kTime);
    end;
end.//Maximumintensitydemo

moviemakerMoviemaker

This example is useful if you want to make movies. The Windows version of MRIcroGL can generate AVI format videos. Alternatively, you can use the savebmp command to save each frame of your movie, and then use a more sophisticated video-editing program to create movies. This latter technique works with any operating system (Windows, Linux and OSX).

const
    kTime= 15;
    kFrames= 8;
var
    i: integer;
begin
    RESETDEFAULTS;
    BACKCOLOR(44, 88, 132);
    LOADIMAGE('visiblehuman')
    AZIMUTHELEVATION(30, 30);
    for i := 1 to kFrames do begin
        MODELESSMESSAGE('frame'+inttostr(i));
        Azimuth(10);
        WAIT(kTime);
        SAVEBMP('i'+inttostr(i));
    end;
    MODELESSMESSAGE('');
    MODALMESSAGE('Lets make a video (Windows OS only)');
    VIDEOSTART('clipvidX',12,false);
    AZIMUTHELEVATION(30, 30);
    for i := 1 to kFrames do begin
        MODELESSMESSAGE('frame'+inttostr(i));
        Azimuth(10);
        WAIT(kTime);
        VIDEOCAPTUREFRAME;
    end;
    MODELESSMESSAGE('');
end.//Moviemaker

overlayOverlaydemo

This script loads a background high resolution anatomical MRI scan of the brain. On top of this, two statistical maps from functional Magnetic Resonance Imaging are superimposed. This helps visualize the location of the brain activity.

begin
    RESETDEFAULTS;
    LOADIMAGE('ch256');
    OVERLAYLOAD('attention');
    OVERLAYMINMAX(1, 2, 5);
    OVERLAYLOAD('saccades');
    OVERLAYMINMAX(2, 2, 5);
    OVERLAYCOLORNUMBER(2, 3);
    OVERLAYFORMVISIBLE(true);
    OVERLAYTRANSPARENCYONOVERLAY(-1);
    AZIMUTHELEVATION(60, 30);
    COLORBARVISIBLE(true);
end.//Overlaydemo