- Examples to load, make and save a nii struct: To load Analyze data or NIFTI data to a structure: nii = load_nii(NIFTI_file_name, [img_idx], [old_RGB24]); img_idx is a numerical array of image indices along the temporal axis, which is only available in NIFTI data. After you specify img_idx, only those images indexed by img_idx will be loaded. If there is no img_idx or img_idx is empty, all available images will be loaded. For RGB image, most people use RGB triple sequentially for each voxel, like [R1 G1 B1 R2 G2 B2 ...]. However, some program like Analyze 6.0 developed by AnalyzeDirect uses old RGB24, in a way like [R1 R2 ... G1 G2 ... B1 B2 ...] for each slices. In this case, you can set old_RGB24 flag to 1 and load data correctly: nii = load_nii(NIFTI_file_name, [], 1); To get a total number of images along the temporal axis: num_scan = get_nii_frame(NIFTI_file_name); You can also load the header extension if it exists: nii.ext = load_nii_ext(NIFTI_file_name); You can just load the Analyze or NIFTI header: (header contains: hk, dime, and hist) hdr = load_nii_hdr(NIFTI_file_name); You can also save the structure to a new file: (header extension will be saved if there is nii.ext structure) save_nii(nii, NIFTI_file_name); To make the structure from any 3D (or 4D) data: img = rand(91,109,91); or img = rand(64,64,21,18); nii = make_nii(img [, voxel_size, origin, datatype] ); Use "help load_nii", "help save_nii", "help make_nii" etc. to get more detail information. - Examples to plot a nii struct: (More detail descriptions are available on top of "view_nii.m") Simple way to plot a nii struct: view_nii(nii); The default colormap will use the Gray if all data values are non-negative; otherwise, the default colormap will use BiPolar. You can choose other colormap, including customized colormap from panel. To imbed the plot into your existing figure: h = gcf; opt.command = 'init'; opt.setarea = [0.3 0.1 0.6 0.8]; view_nii(h, nii, opt); To add a colorbar: opt.usecolorbar = 1; view_nii(gcf, opt); Here, opt.command is implicitly set to 'update'. To display in real aspect ratio: opt.usestretch = 0; view_nii(gcf, opt); If you want the data value to be directly used as the index of colormap, instead of scale to the whole colormap: opt.useimagesc = 0; view_nii(gcf, opt); If you modified the data value without changing the dimension, voxel_size, and origin, you can update the display by: opt.command = 'updateimg'; view_nii(gcf, nii.img, opt); If the data is completely different, display can be updated by: opt.command = 'updatenii'; view_nii(gcf, nii, opt); - Contrast and Brightness are available under Gray and Bipolar colormap: Increase contrast in Gray colormap will make high end values more distinguishable by sacrificing the low end values; The minimum contrast (default) will display the whole range. Increase or decrease contrast in BiPolar colormap will shift the distinguishable position for both positive and negative values. Increase or decrease brightness in Gray colormap will shift the distinguishable position. Increase or decrease brightness in BiPolar colormap will make both positive and negative values more distinguishable. - Required files: All files in this package.