123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- - 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);
- This is an example to plot EEG source imaging on top of T1 background:
- 1. download overlay.zip and unzip it from:
- http://www.rotman-baycrest.on.ca/~jimmy/NIFTI/overlay.zip
- 2. T1 = load_nii('T1.nii');
- 3. EEG = load_nii('EEG.nii');
- 4. option.setvalue.idx = find(EEG.img);
- 5. option.setvalue.val = EEG.img(option.setvalue.idx);
- 6. option.useinterp = 1;
- 7. option.setviewpoint = [62 48 46];
- 8. view_nii(T1, option);
- - 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.
|