Region of interest

src.roi.createRoi(varargin)

Returns a mask to be used as a ROI by spm_summarize. Can also save the ROI as binary image.

USAGE:

mask = createROI(type, ...
                specification, ...
                volumeDefiningImage = '', ...
                outputDir = pwd, ...
                saveImg = false);

mask = createROI('mask', roiImage);
mask = createROI('sphere', sphere);
mask = createROI('intersection', specification);
mask = createROI('expand', specification);

See the demos/roi to see examples on how to use it.

Parameters:
  • type (string) – 'mask', 'sphere', 'intersection', 'expand'

  • volumeDefiningImage (string) – fullpath of the image that will define the space (resolution, …) if the ROI is to be saved.

  • saveImg (boolean) – Will save the resulting image as binary mask if set to true

  • specification

    depending on the chosen type this can be:

    roiImage:
    • string:

      fullpath of the roi image for 'mask'

    sphere:
    • structure:

      defines the characteristic for 'sphere'

    • sphere.location: X Y Z coordinates in millimeters

    • spehere.radius: radius in millimeters

    specification:
    • structure:

      defines the characteristic for 'intersection' and 'expand'

    • sphere.location: X Y Z coordinates in millimeters

    • sphere.radius: radius in millimeters

Returns:

mask:
  • structure:

    the volume of interest adapted from spm_ROI

  • mask.def: VOI definition [sphere, mask]

  • mask.rej: cell array of disabled VOI definition options

  • mask.xyz : centre of VOI {mm} (for sphere)

  • mask.spec: VOI definition parameters (radius for sphere)

  • mask.str : description of the VOI

  • mask.descrip

  • mask.label

  • mask.roi

    • mask.roi.size: number of voxel in ROI

    • mask.roi.XYZ : voxel coordinates

    • mask.roi.XYZmm : voxel world coordinates

  • mask.global

    • mask.global.hdr : header of the “search space” where the roi is defined

    • mask.global.img

    • mask.global.XYZ

    • mask.global.XYZmm

src.roi.getPeakCoordinates(varargin)

This function gets the coordinates of a peak within a specified region of interest.

USAGE:

[worldCoord, voxelCoord, maxVal] = getPeakCoordinates(dataImage, roiImage, threshold)
Parameters:
  • dataImage (path) – data image (beta / t / Z map) to find the maximum in

  • roiImage (path) – binary mask limiting the volume where to find the peak

  • threshold (numerical) – threshold above which peak must be found

src.roi.keepHemisphere(inputImage, hemisphere, paddingValue)

Only keep the values from one hemisphere. Sets the other half to NaN. Writes an image with an extra entity _hemi-[R|L]

USAGE:

keepHemisphere(image, hemisphere)
Parameters:
  • image (string) –

  • hemisphere (string) – 'L' or 'R'

src.roi.plotDataInRoi(varargin)

Creates a figure showing a histogram of the content of a set of ROIs used on a set of data files.

ROI label is extracted from the label entity in the BIDS filename.

USAGE:

figHandle = plotDataInRoi(dataImages, roiImages, ...
                              'scaleFactor', 1, ...
                              'roiAs', 'rows', ...
                              'dataLabel', {})
Parameters:
  • dataImages (path or cellstr of paths) –

  • roiImages (path or cellstr of paths) –

  • scaleFactor (numerical) – value to scale the factor by. Default to 1.

  • roiAs ('rows' or 'cols') – Determine if the ROI are supposed to be organized by rows or columns. Default to ‘rows’.

  • dataLabel (cellstr) – strings to use to label the data rows or columns.

  • maxVox (positive integer) – max of scale for nb of voxels. Default to [].

  • nbBins (positive integer) – use the same number of bins for all graphs. By default based on the number of unique values across all the datasets.

EXAMPLE:

mask1 = fullfile(pwd, 'label-V1_mask.nii')
mask2 = fullfile(pwd, 'label-V2_mask.nii')

data1 = fullfile(pwd, 'label-0001_beta.nii')
data2 = fullfile(pwd, 'label-0002_beta.nii')

mask = cellstr(cat(1, mask1, mask2));
data = cellstr(cat(1, data1, data2));

plotDataInRoi(data, mask);
src.roi.thresholdToMask(varargin)

Returns a binary mask for an image after applying voxel wise threshold and an optional cluster size threshold

USAGE:

outputImage = thresholdToMask(inputImage, peakThreshold, clusterSize)
Parameters:
  • inputImage (path) –

  • peakThreshold (float) –

  • clusterSize (integer >= 0 (Default)) –

Returns:

  • outputImage:

    (string)

src.roi.renameNeuroSynth(inputImage)

rename a neurosynth map a name that is more bids friendly

USAGE:

outputImage = renameNeuroSynth(inputImage)

EXAMPLE:

inputImage = fullfile(pwd, 'motion_association-test_z_FDR_0.01.nii.gz');
outputImage = renameNeuroSynth(inputImage);

outputImage
>>
  fullfile(pwd, 'space-MNI_label-neurosynthMotion_probseg.nii.gz');
src.roi.resliceRoiImages(referenceImage, imagesToCheck, dryRun)

Check if images are in the same orientation and reslice if necessarrry.

USAGE:

reslicedImages = resliceRoiImages(referenceImage, imagesToCheck, dryRun)
Parameters:
  • referenceImage (path) –

  • imagesToCheck (path or cellstr) –

  • dryRun (logical) – Returns the matlabbatch without running it.