Identifying empirical ROI and extracting peak information
Contents
Identifying empirical ROI and extracting peak information#
Overview#
Since the analysis of specific regions of interest (ROI) reduces the span of statistical analyses from the entire voxel space to specific regions of activation it is a common approach to fMRI activation data analysis. This approach has multiple benefits over analyzing the activation across the entire voxel space.
Generating a ROI map from statistical maps#
ROI maps are generated with the QuNex command general_find_peaks, which is a part of matlab/qx_mri/general. The command takes a statistical map image as an input and outputs a map with generated ROIs. Prior to ROI computation, the input data can be additionally processed by performing the Gaussian smoothing and thresholding. ROIs are then computed with watershed segmentation algorithm. An example of a statistical map (input) and a generated ROI map (output) is shown in the image below.

general_find_peaks function description#
general_find_peaks is a wrapper to the nimage.img_find_peaks() method. The function generates a ROI map output file with the same format as the input image and a text report containing peak statistics.
qunex general_find_peaks \
--fin="<path_to_the_input_file>" \
--fout="<path_to_the_output_file>" \
--mins="<minimum_size_and_area_of_generated_ROIs>" \
--maxs="<maximum_size_and_area_of_generated_ROIs>" \
--val="<thresholding_type>" \
--t="<thresholding_value>" \
--presmooth="<presmoothing_parameters>" \
--projection="<type_of_surface_projection_for_both_hemispheres>" \
--options="<additional_processing_options>" \
--verbose="<whether_the_command_is_verbose>"
The breakdown of input parameters is as follows:
fin(string) Path to the input file.The file can be either:
NIfTI (volumetric) file (
.nii.gz), where data consists entirely of voxels, orCIFTI-2 (surface/volumetric) file (
.nii), consisting of a vertex/voxel data.CIFTI-2 images can either contain dense scalar data or dense data series. CIFT-2 files should therefore have extensions
dscalar.niiordtimeseries.nii. NIfTI files have.nii.gzextension, regardless of the temporal dimension.Image is read with the
nimage()function. For more information refer to help documentation fornimage().
fout(string) Path to the output file.If the file with the same path already exists, it will be overwritten. The output file should have the same format as the input file (
fin). For example, if the input file has adtseries.niiextension, so must the output file.Image is saved with the
nimage.img_saveimage()method. For more information refer toimg_saveimage()help documentation.mins(double or 1x2 double array) Minimum size and area of generated ROIs. Default:mins = [0, 0]When processing NIfTI files,
minsmust be a scalar, defining the minimum size of volumetric ROIs in voxels, as shown below.mins = <minimum size of volumetric ROIs (vox)>When processing CIFTI-2 files, it must be a 1x2 array, where the first element defines the minimum size of volumetric ROIs (voxels) and the second element the minimum area of surface ROIs in square millimeters (mm^2), as shown below.
mins = [<minimum size of volumetric ROIs (vox)>, <minimum area of surface ROIs (mm^2)>]maxs(double or 1x2 double array) Maximum size and area of generated ROIs. Default:maxs = [Inf, Inf]When processing NIfTI files,
maxsmust be a scalar, defining the maximum size of volumetric ROIs in voxels, as shown below.maxs = <maximum size of volumetric ROIs (vox)>When processing CIFTI-2 files, it must be a 1x2 array, where the first element defines the maximum size of volumetric ROIs (voxels) and the second element the maximum area of surface ROIs in square millimeters (mm^2), as shown below.
maxs = [<maximum size of volumetric ROIs (vox)>, <maximum area of surface ROIs (mm^2)>]val(char) Thresholding type. Default:val = 'b'valmust be a character indicating whether the thresholding is applied to:positive values (
val = 'p'), * negative values (val = 'n') orthe absolute value of the data (
val = 'b')
t(double): Thresholding value. Default:t = 0presmooth(string) Presmoothing parameters. Default:presmooth = [](no smoothing).presmoothmust have the following format:presmooth = 'fwhm:[<VF> <SF>]|ftype:<TYPE>|ksize:<KS> |wb_path:<PATH2WB>|hcpatlas:<PATH2HCP>'|timeSeries:<TS>|frames:<FLIST>'
where
fwhmFull Width at Half Maximum information for volumetric and surface smoothing, passed either as a scalar or as a 2-element vector, where the first element (<VF>) defines the volumetric and the second element (<SF>) the surface fwhm value. For NIfTI image smoothing it should be a scalar. If a scalar is passed for CIFTI-2 image smoothing, it uses the same value for volumetric and surface smoothing.ftypeType of a smoothing kernel for volumetric data. Options are'gaussian'or'box'. Surface data smoothing is performed with the geodesic Gaussian method. The default kernel for volumetric data smoothing is'Gaussian'.ksizeSmoothing kernel size for volumetric data, defined in voxels.maskPath to the mask image, which defines regions where smoothing is performed. If empty, it is by default set to be the same as the input file. If set tomask:no, no mask is used.wb_pathPath to wb_command program (Connectome Workbench). This is required for surface data smoothing. If the path is stored in the$PATHenvironment variable, then it is not required.hcpatlasPath to HCPATLAS folder containing projection (surf.gii) files. If<HCPATLAS>is stored as an environment variable$HCPATLAS, thenhcpatlaspath is not required.timeSeriesA boolean indicating whether a thresholded time series image should use each frame as a mask for the corresponding frame. By default the first frame is taken as a mask for all remaining frames.framesA list of frames passed as an array (e.g. [1 2 3]) to perform smoothing on. If left empty, it is by default set asoptions.frames.
maskparameter is particularly important in cases when a thresholded image is passed as an input togeneral_find_peaks(). Ifmaskis unspecified, it by default uses the input (thresholded) image as a mask. Ifmaskis explicitly specified asmask:no, then no mask is used and regions above the threshold are smeared into previously thresholded regions, as shown in the image below.

Smoothing is performed with the nimage.img_smooth() method. For more information refer to nimage.img_smooth() documentation.
projection(string) Type of surface projection for both hemispheres. Default:projection = 'type:midthickness'.projectiondefines the surface projection for left and right cortex. This projection forms the basis for all surface data operations.projectioncan be passed as:'type:midthickness','type:inflated', etc. for default HCP surfaces or'cortex_left:<CL_projection.surf.gii>|cortex_right:<CR_projection.surf.gii>'to use specific.surf.giifiles.
options(string) Additional processing options. Default:options = [](only the first frame is processed and no boundary operations).It must have the following format:
options = 'frames:<FR>|boundary:<BTYPE>|parcels:<PTYPE>',where
frames- frames to be processed. Specific frames can be selected by passing an array of frames (e.g. [1 2 3]), use the stringallto process all frames, if this parameter is empty ([]), only the first frame will be processed.boundarydefines the values of each ROI boundary. It can be set toremovein order to set boundary values to 0,highlightto set boundary values to -100 orwire, where only ROI boundaries have non-zero values. An example of a file, processed 4 times with all 4 options for the boundary is shown on the image below.parcelsdefines whether to generate a text file reporting the composition of identified ROIs across CIFTI-2 volume structures (parcels:volume) or the composition across CIFTI-2 volume structures and across parcels defined in the input atlas image (parcels:<path_to_atlas>). The same report can be generated separately with the functiongeneral_get_roi_parcels. The output file is named (<fin>_parcels.txt). If this parameters is empty, no file is generated.limitvoldefines whether to limit the growth of regions to subcortical structures as defined in CIFTI-2 format (applies to volume structures only). It can be set to1to limit the growth of regions. If set to0or left empty, the growth of regions is unaffected by CIFTI-2 subcortical region boundaries.

verbose(double) Defines whether the command is verbose or not. Default:verbose = 0.verbosecan be set as0 - non-verbose,
1 - prints only information from the top-level command (
general_find_peaks()) or * 2 - prints information from all subfunctions as well.
Examples#
NIfTI (volumetric) image#
To get a ROI image of both positive and negative peak regions with minimum z-values of (-)1, at least 50 contiguous voxels in size, but no larger than 250 voxels, after smoothing with a Gaussian kernel with fwhm = 3 and ksize = 6, use:
qunex general_find_peaks \
--fin="zscores.nii.gz" \
--fout="zscores_analyzed.nii.gz" \
--mins="50" \
--maxs="250" \
--val="b" \
--t=1 \
--presmooth="fwhm:3|ksize:6|ftype:gaussian" \
--verbose=2
To get a ROI image of both positive and negative peak regions with minimum z-values of (-)3, at least 72 contiguous voxels in size, but no larger than 300 voxels, after smoothing with a Gaussian kernel with fwhm = 2 and ksize = 7, use:
qunex general_find_peaks \
--fin="zscores.nii.gz" \
--fout="zscores_peaks_3_72_300.nii.gz" \
--mins="72" \
--maxs="300" \
--val="b" \
--t=3 \
--presmooth="fwhm:2|ksize:7" \
--verbose=1
CIFTI-2 (surface/volumetric) image#
To get a ROI image of both positive and negative peak regions with minimum z-values of (-)3, at least 72 contiguous voxels in size or with minimum area of 80 mm^2, but no larger than 300 voxels or 350 mm^2, after smoothing with a kernel with fwhm = 1 for volume and surfaces structures, where only frames 1, 6 and 7 will be processed, use:
qunex general_find_peaks \
--fin="zscores.dtseries.nii" \
--fout="zscores_analyzed.dtseries.nii" \
--mins="[72 80]" \
--maxs="[300 350]" \
--val="b" \
--t=1 \
--presmooth="fwhm:3" \
--projection="type:inflated" \
--options="frames:[1 6 7]" \
--verbose=1
To get a ROI image of both positive and negative peak regions with minimum z-values of (-)3, at least 72 contiguous voxels in size or with minimum area of 80 mm^2, but no larger than 300 voxels or 350 mm^2, after smoothing with a kernel with fwhm = 3 for volume and surfaces structures, where surface operations are based on specific surface files (surf.gii) for both hemispheres, use:
qunex general_find_peaks \
--fin="zscores.dtseries.nii" \
--fout="zscores_peaks_3_72_300.dscalar.nii.gz" \
--mins="[72 80]" \
--maxs="[300 350]" \
--val="b" \
--t=3 \
--presmooth="fwhm:1" \
--projection="cortex_left:CL_projection.surf.gii|cortex_right:CR_projection.surf.gii" \
--verbose=1
