maskTracks {sojourner} | R Documentation

## maskTracks

### Description

apply binary image masks to lists of track lists

### Usage

    maskTracks(folder, trackll)

    indexCell(folder, trackll, areaFilter = c(0, Inf),
        intensityFilter = c(0, Inf), export = FALSE, max.pixel = 128)

    filterOnCell(trackll, numTracks = 0)

    sampleTracks(trackll, num = 0)

### Arguments

`folder` | Full path to the output files.
`trackll` | A list of track lists.
`export` | Logical indicate if .csv output file should be generated
`max.pixel` | Pixel dimension of image
`areaFilter` | Range of cell areas (pixel sq) to keep in filtering
`intensityFilter` | Range of avg cell intensities (grayscale) to keep in filtering
`numTracks` | Minimum number of required tracks in the trackll
`num` | Number of tracks to randomly sample per trackl in trackll

### Details

IMPORTANT: It will take an extremely long time to mask large datasets. Filter/trim first using filterTrack() and trimTrack(), then mask using maskTracks(folder, trackll)! Note the mask file should have the same name as the output files with a '_MASK.tif' ending. If there are more mask files than trackll, masking will fail. If there are less mask files, trackls without masks will be deleted. Users can use plotMask() and plotTrackOverlay() to see the mask and its effect on screening tracks.

indexCell() will mask a trackll, separate each cell into a trackl, display all cell areas and mean intensities, and then apply any area and intensity filters. There is also the capability to export the final areas/intensities as 'indexCell.csv' to the home directory and the pixel dimensions can be changed.

filterOnCell() eliminates all trackl in trackll that has less than numTracks tracks.

sampleTracks() randomly samples num number of tracks for each trackl in trackll.

### Value

masked tracks in trackll format

### Examples

    #Basic masking with folder path with image masks
    folder = system.file('extdata','ImageJ',package='sojourner')
    trackll = createTrackll(folder=folder, input=3)
    trackll.masked <- maskTracks(folder = folder, trackll = trackll)

    #Compare the masking effect
    plotTrackOverlay(trackll)
    plotTrackOverlay(trackll.masked)

    #Plot mask
    mask.list=list.files(path=folder,pattern='_MASK.tif',full.names=TRUE)
    plotMask(folder)

    #If Nuclear image is available
    plotNucTrackOverlay(folder=folder,trackll=trackll)
    plotNucTrackOverlay(folder=folder,trackll=trackll.masked)

    #Plot mask
    plotMask(folder=folder)

    # To mask a trackll, separate each cell into a trackl, and apply any
    # intensity and area filters
    str(trackll, max.level=1)
    trackll_indexed = indexCell(folder = folder, trackll = trackll)
    str(trackll_indexed, max.level=1)

    # To eliminate all trackl in trackll that has less than numTracks = 5 tracks
    # In this example, we eliminate all cells less with less than 5 tracks
    trackll_filterOnCell = filterOnCell(trackll=trackll_indexed,
        numTracks = 5)
    str(trackll_filterOnCell, max.level=1)

    # To randomly sample num = 5 tracks fo each trackl in trackll
    # In this example, we randomly sample 5 tracks for each cell
    trackll_sampled = sampleTracks(trackll=trackll_filterOnCell, num=5)
    str(trackll_sampled, max.level=1)

[Package sojourner version 1.1.1 Index]