Tile Generators


Tile objects are typically generated from defining information through tile generator functions which take as arguments specific parameters and return a Tile object.

If the Tile Generator is only provided specific Tile parameters it must be called multiple times (such as through a loop) with each new parameter set producing a single tile each time. If the argument is an array of roiData objects then multiple Tiles can be produces at once.

Users can write their own Tile Generators and use what ever data is necessary so long as they end up with the necessary constructor arguments for a Tile object (See Tile Objects page).

The following is the structure of the default generator function:

function tiles = defaultTileGenerator(hCoordinateSystem, tileParams, extraParams)
    % Usage: Generates Tile objects from either user specified parameters or
    % from roiData objects.
    %
    % Tile params should be arranged as such {tileCenter, tileSize, zPos, channel, imageData}
    % Tile params will checked to see if they are roiData objects

    assert(isa(hCoordinateSystem, 'scanimage.components.CoordinateSystems'), 'Param 1 is not a valid coordinate system');
    assert(iscell(tileParams), 'Tile params must be a cell array of either roiData objects or tile parameters: centerXY, sizeXY, Z, channel, resolution, imageData(*optional)');

    if nargin<3||isempty(extraParams)
        rollingAvgFactor = 1;
        availableChannels = 4;
    else
        assert(iscell(extraParams), 'Extra parameters must be in a cell array. Valid extra params are: {rollingAvgFactor, maxChansAvail}.');
        rollingAvgFactor = extraParams{1};
        if numel(extraParams)>=2
            availableChannels = extraParams{2};
        end
    end

    tfRoiData = most.util.cellArrayClassUniformity(tileParams, 'scanimage.mroi.RoiData');

    if tfRoiData
        roiData = tileParams;
        tiles = scanimage.components.tiles.tile.empty(0,1);
        for roiNum = 1:numel(roiData)
            % Parse out data from roiData objects
            .
            .
            .
            tiles(end+1) = scanimage.components.tiles.tile(hCoordinateSystem, scanfield, zs(zIdx), chansAvail, imData, rollingAvgFactor);
        end
    else
        % Parse out tile Params.
        .
        .
        .
        tiles = scanimage.components.tiles.tile(hCoordinateSystem, sf, zPos, chans, imageData, rollingAvgFactor);
    end
end