%% Change File Paths in Multisignal Ground Truth Data
% Change the file paths to the data sources and pixel label data in a groundTruthMultisignal object.
% Load a groundTruthMultisignal object containing ground truth data into the workspace. The data source and pixel label data of the object contain file paths corresponding to an image sequence showing a building. MATLAB® displays a warning that the path to the data source cannot be found.

load('gTruthMultiOldPaths.mat')

%
% Display the current path to the data source.

gTruth.DataSource

%
% Specify the current path to the data source and an alternative path and store these paths in a cell array. Use the changeFilePaths function to update the data source path based on the paths in the cell array. Because the function does not find the pixel label data at the specified new path, it returns the current unresolved paths.

currentPathDataSource = "C:\Sources\building";
newPathDataSource = fullfile(matlabroot,"toolbox\vision\visiondata\building");
alternativePaths = {[currentPathDataSource newPathDataSource]};
unresolvedPaths = changeFilePaths(gTruth,alternativePaths)

%
% Verify that the paths in the groundTruthMultisignal object match the unresolved paths returned by the changeFilePaths function. The unresolved paths are stored in the ROILabelData property of the groundTruthMultisignal object, in the PixelLabelData column of the table for the building image sequence signal.

gTruth.ROILabelData.building.PixelLabelData

%
% Specify the current path and an alternative path for the pixel label files and change the file paths. The function updates the paths for all pixel labels. Because the function resolves all paths, it returns an empty array of unresolved paths.

currentPathPixels = "C:\Pixels";
newPathPixels = fullfile(matlabroot,"toolbox\vision\visiondata\buildingPixellabels");
alternativePaths = {[currentPathPixels newPathPixels]};
unresolvedPaths = changeFilePaths(gTruth,alternativePaths)

% To view the new data source path, use the gTruth.DataSource command. To view the new pixel label data paths, use the gTruth.ROILabelData.building.PixelLabelData command.
% Copyright 2019 The MathWorks, Inc.