Main Content

roimask

Get ROI table mask

Since R2020b

Description

tbl = roimask(msk) returns a region-of-interest (ROI) table mask, tbl, based on the source and properties in msk.

example

[tbl,numroi,cats] = roimask(msk) also returns numroi, a vector containing the number of regions found for each of the categories listed in cats.

example

Examples

collapse all

Generate an 18-by-2 mask of binary sequences. Use the mask to create a signalMask object and label the categories as A and B. Extract an ROI table mask from the object.

binSeqs = logical([ ...
    0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 1 1;
    1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0]');

m = signalMask(binSeqs,'Categories',["A" "B"]);

roiTbl = roimask(m)
roiTbl=4×2 table
    ROILimits    Value
    _________    _____

     1     2       B  
     5     7       A  
    10    12       B  
    15    18       A  

Extend the regions of interest by one sample to the left and right.

m.RightExtension = 1;
m.LeftExtension = 1;

roiTbl = roimask(m)
roiTbl=4×2 table
    ROILimits    Value
    _________    _____

     1     3       B  
     4     8       A  
     9    13       B  
    14    19       A  

Generate a 16-sample categorical sequence mask with two categories, A and B. Specify as missing those samples that do not belong to A or B. Use the mask to create a signalMask object. Extract an ROI table mask from the object.

catSeq = categorical(["A" "A" "A" missing missing "B" "B" ...
  missing missing "B" "B" missing "B" "A" "A" "A"]);

m = signalMask(catSeq);

roiTbl = roimask(m)
roiTbl=5×2 table
    ROILimits    Value
    _________    _____

     1     3       A  
     6     7       B  
    10    11       B  
    13    13       B  
    14    16       A  

Output a list of categories and the number of regions belonging to each category.

[~,nroi,cats] = roimask(m)
nroi = 2×1

     2
     3

cats = 2x1 string
    "A"
    "B"

Merge same-category regions separated by only one sample.

m.MergeDistance = 1;

roiTbl = roimask(m)
roiTbl=4×2 table
    ROILimits    Value
    _________    _____

     1     3       A  
     6     7       B  
    10    13       B  
    14    16       A  

Input Arguments

collapse all

Signal mask, specified as a signalMask object.

Example: signalMask(table([2 4;6 7],["male" "female"]')) specifies a signal mask with a three-sample male region and a two-sample female region.

Example: signalMask(categorical(["" "male" "male" "male" "" "female" "female" ""]',["male" "female"])) specifies a signal mask with a three-sample male region and a two-sample female region.

Example: signalMask([0 1 1 1 0 0 0 0;0 0 0 0 0 1 1 0]','Categories',["male" "female"]) specifies a signal mask with a three-sample male region and a two-sample female region.

Output Arguments

collapse all

ROI table mask, returned as a table.

  • If SampleRate is specified, the region limits in tbl are expressed in seconds.

  • If RightExtension is greater than zero and SourceType is specified as 'categoricalSequence' or 'binarySequences', the region limits in tbl may go beyond the length of the sequence.

Number of regions found for each of the categories in cats, returned as a vector of integers.

Category list, returned as a vector of strings.

Version History

Introduced in R2020b