Jupyter notebook examples

Import nifti-snapshot

  • If nifti-snapshot had been installed through github clone, add the nifti-snapshot/nifti_snapshot to the path either by export or sys.path.append

[ ]:
import nifti_snapshot

Simple visualization of a map

[103]:
img_loc = '101_diff_map.nii.gz'
[112]:
fig = nifti_snapshot.SimpleFigure(
    image_files = [img_loc],
    title = 'Difference map between GAD-T1w and T1w',
    vmin_list = [-100],
    vmax_list = [100],
    make_transparent_zero = True,
    cbar_width = 0.5,
    cbar_title = 'GAD T1w - T1w intensity'
)
        image_files : ['101_diff_map.nii.gz']
        title : Difference map between GAD-T1w and T1w
        vmin_list : [-100]
        vmax_list : [100]
        make_transparent_zero : True
        cbar_width : 0.5
        cbar_title : GAD T1w - T1w intensity
_images/single_image_example_5_1.png

Control size of the boxes and number of axes

[116]:
fig = nifti_snapshot.SimpleFigure(
    ncols=3, nrows=3, slice_gap=2,
    image_files = [img_loc],
    box_x = [80, 180],
    box_y = [80, 160],
    box_z = [40, 150],
    slice_num_lowest = 35,
    slice_num_highest = 59,
    title = 'Difference map between GAD-T1w and T1w',
    vmin_list = [-100],
    vmax_list = [100],
    make_transparent_zero = True,
    cbar_width = 0.5,
    hspace = 0.02,
    wspace = 0.02,
    cbar_title = 'GAD T1w - T1w intensity'
)
        ncols : 3
        nrows : 3
        slice_gap : 2
        image_files : ['101_diff_map.nii.gz']
        box_x : [80, 180]
        box_y : [80, 160]
        box_z : [40, 150]
        slice_num_lowest : 35
        slice_num_highest : 59
        title : Difference map between GAD-T1w and T1w
        vmin_list : [-100]
        vmax_list : [100]
        make_transparent_zero : True
        cbar_width : 0.5
        hspace : 0.02
        wspace : 0.02
        cbar_title : GAD T1w - T1w intensity
_images/single_image_example_7_1.png

Control maximum and minimum intensity by vmin_list and vmax_list

[117]:
fig = nifti_snapshot.SimpleFigure(
    ncols=3, nrows=3, slice_gap=2,
    image_files = [img_loc],
    box_x = [80, 180],
    box_y = [80, 160],
    box_z = [40, 150],
    slice_num_lowest = 35,
    slice_num_highest = 59,
    title = 'Difference map between GAD-T1w and T1w',
    vmin_list = [-1000],
    vmax_list = [1000],
    make_transparent_zero = True,
    cbar_width = 0.5,
    hspace = 0.02,
    wspace = 0.02,
    cbar_title = 'GAD T1w - T1w intensity'
)
        ncols : 3
        nrows : 3
        slice_gap : 2
        image_files : ['101_diff_map.nii.gz']
        box_x : [80, 180]
        box_y : [80, 160]
        box_z : [40, 150]
        slice_num_lowest : 35
        slice_num_highest : 59
        title : Difference map between GAD-T1w and T1w
        vmin_list : [-1000]
        vmax_list : [1000]
        make_transparent_zero : True
        cbar_width : 0.5
        hspace : 0.02
        wspace : 0.02
        cbar_title : GAD T1w - T1w intensity
_images/single_image_example_9_1.png
[119]:
fig = nifti_snapshot.SimpleFigure(
    ncols=3, nrows=3, slice_gap=2,
    image_files = [img_loc],
    box_x = [80, 180],
    box_y = [80, 160],
    box_z = [40, 150],
    slice_num_lowest = 35,
    slice_num_highest = 59,
    title = 'Difference map between GAD-T1w and T1w',
    vmin_list = [1],
    vmax_list = [300],
    make_transparent_zero = True,
    cbar_width = 0.5,
    hspace = 0.02,
    wspace = 0.02,
    cbar_title = 'GAD T1w - T1w intensity'
)
        ncols : 3
        nrows : 3
        slice_gap : 2
        image_files : ['101_diff_map.nii.gz']
        box_x : [80, 180]
        box_y : [80, 160]
        box_z : [40, 150]
        slice_num_lowest : 35
        slice_num_highest : 59
        title : Difference map between GAD-T1w and T1w
        vmin_list : [1]
        vmax_list : [300]
        make_transparent_zero : True
        cbar_width : 0.5
        hspace : 0.02
        wspace : 0.02
        cbar_title : GAD T1w - T1w intensity
_images/single_image_example_10_1.png
[120]:
fig = nifti_snapshot.SimpleFigure(
    ncols=3, nrows=3, slice_gap=2,
    image_files = [img_loc],
    box_x = [80, 180],
    box_y = [80, 160],
    box_z = [40, 150],
    slice_num_lowest = 35,
    slice_num_highest = 59,
    title = 'Difference map between GAD-T1w and T1w',
    vmin_list = [1],
    vmax_list = [1000],
    make_transparent_zero = True,
    cbar_width = 0.5,
    hspace = 0.02,
    wspace = 0.02,
    cbar_title = 'GAD T1w - T1w intensity'
)
        ncols : 3
        nrows : 3
        slice_gap : 2
        image_files : ['101_diff_map.nii.gz']
        box_x : [80, 180]
        box_y : [80, 160]
        box_z : [40, 150]
        slice_num_lowest : 35
        slice_num_highest : 59
        title : Difference map between GAD-T1w and T1w
        vmin_list : [1]
        vmax_list : [1000]
        make_transparent_zero : True
        cbar_width : 0.5
        hspace : 0.02
        wspace : 0.02
        cbar_title : GAD T1w - T1w intensity
_images/single_image_example_11_1.png
[121]:
fig = nifti_snapshot.SimpleFigure(
    ncols=3, nrows=3, slice_gap=2,
    image_files = [img_loc],
    box_x = [80, 180],
    box_y = [80, 160],
    box_z = [40, 150],
    slice_num_lowest = 35,
    slice_num_highest = 59,
    title = 'Difference map between GAD-T1w and T1w',
    vmin_list = [1],
    vmax_list = [1500],
    make_transparent_zero = True,
    cbar_width = 0.5,
    hspace = 0.02,
    wspace = 0.02,
    cbar_title = 'GAD T1w - T1w intensity'
)
        ncols : 3
        nrows : 3
        slice_gap : 2
        image_files : ['101_diff_map.nii.gz']
        box_x : [80, 180]
        box_y : [80, 160]
        box_z : [40, 150]
        slice_num_lowest : 35
        slice_num_highest : 59
        title : Difference map between GAD-T1w and T1w
        vmin_list : [1]
        vmax_list : [1500]
        make_transparent_zero : True
        cbar_width : 0.5
        hspace : 0.02
        wspace : 0.02
        cbar_title : GAD T1w - T1w intensity
_images/single_image_example_12_1.png

Simple histogram

[123]:
fig = nifti_snapshot.SimpleHistogram(
    ncols=3, nrows=3, slice_gap=2,
    image_files = [img_loc],
    box_x = [80, 180],
    box_y = [80, 160],
    box_z = [40, 150],
    slice_num_lowest = 35,
    slice_num_highest = 59,
    title = 'Difference map between GAD-T1w and T1w',
    title_font_size = 20,
    vmin_list = [400],
    vmax_list = [1500],
    make_transparent_zero = True,
    cbar_width = 0.5,
    hspace = 0.1,
    wspace = 0.1,
    top = 0.85,
    cbar_title = 'GAD T1w - T1w intensity'
)
        ncols : 3
        nrows : 3
        slice_gap : 2
        image_files : ['101_diff_map.nii.gz']
        box_x : [80, 180]
        box_y : [80, 160]
        box_z : [40, 150]
        slice_num_lowest : 35
        slice_num_highest : 59
        title : Difference map between GAD-T1w and T1w
        title_font_size : 20
        vmin_list : [400]
        vmax_list : [1500]
        make_transparent_zero : True
        cbar_width : 0.5
        hspace : 0.1
        wspace : 0.1
        top : 0.85
        cbar_title : GAD T1w - T1w intensity
/Users/kangik/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
_images/single_image_example_14_2.png