主要内容

changeFilePaths

R2026b

Change file paths in multi-sensor ground truth data

Since R2026b

Description

Use the changeFilePaths function to update the file paths of ground truth data associated with a groundTruthMultiSensor object. You can change file paths for the ground truth data sources, pixel label data, and semantic point label data.

unresolvedPaths = changeFilePaths(gTruth,alternativePaths) changes the file paths stored in a groundTruthMultiSensor object, gTruth, based on pairs of current paths and alternative paths, alternativePaths. If gTruth is a vector of groundTruthMultiSensor objects, the function changes the file paths across all objects. The function returns the unresolved paths in unresolvedPaths. An unresolved path is any current path in alternativePaths not found in gTruth or any alternative path in alternativePaths not found at the specified path location. In both cases, unresolvedPaths returns only the current paths.

example

Examples

collapse all

Change the file paths to the data sources and pixel label data in a groundTruthMultiSensor object.

This example assumes you have a groundTruthMultiSensor object, gTruth, in the workspace. The data source and pixel label data of the object contain file paths corresponding to an image sequence showing a building.

Display the current path to the data source.

gTruth.DataSource
ans =
  ImageSequenceSource with properties:

            Name: "Image Sequence"
     Description: "An image sequence reader"
      SourceName: "C:\Sources\building"
    SourceParams: [1×1 struct]
      SignalName: "building"
      SignalType: Image
       Timestamp: {[5×1 duration]}
      NumSignals: 1

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)
unresolvedPaths = 5×1 string array
    "C:\Pixels\Label_1.png"
    "C:\Pixels\Label_2.png"
    "C:\Pixels\Label_3.png"
    "C:\Pixels\Label_4.png"
    "C:\Pixels\Label_5.png"

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

gTruth.ROILabelData.building.PixelLabelData
ans = 5×1 cell array
    "'C:\Pixels\Label_1.png'"
    "'C:\Pixels\Label_2.png'"
    "'C:\Pixels\Label_3.png'"
    "'C:\Pixels\Label_4.png'"
    "'C:\Pixels\Label_5.png'"

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)
unresolvedPaths =

  0×0 empty string array

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.

Input Arguments

collapse all

Multi-sensor ground truth data, specified as a groundTruthMultiSensor object or a vector of groundTruthMultiSensor objects.

Alternative file paths, specified as a 1-by-2 string vector or cell array of 1-by-2 string vectors of the form [pcurrent pnew].

  • pcurrent is a current file path in gTruth. This file path can be from the data source, pixel label data, or semantic point label data of gTruth. Specify pcurrent using backslashes as the path separators.

  • pnew is the new path to which you want to change pcurrent. Specify pnew using either forward slashes or backslashes as the path separators.

You can specify alternative paths to these files.

  • Signal data sources — The DataSource property of gTruth contains one MultiSignalSource object per signal. The changeFilePaths function updates the signal paths stored in these objects.

  • Pixel label data — The ROILabelData property of gTruth contains an ROILabelData object, which contains a table of ROI label data for each signal. For signals with pixel label data, which is stored in the PixelLabelData column of the table for that signal, the function updates the paths to the pixel label data.

  • Semantic point label data — For point cloud signals with semantic point label data, which is stored in the SemanticPointLabelData column of the table for that signal, the function updates the paths to the semantic point label data files.

If gTruth is a vector of groundTruthMultiSensor objects, the function changes the file paths across all objects.

Example: ["C:\Pixels\PixelLabelData_1" "C:\Pixels\PixelLabelData_2"] changes the path to the pixel label data folder. The function updates the path in all pixel label files stored in that folder.

Example: {["B:\Sources\video1.mp4" "C:\Sources\video1.mp4"]; ["B:\Sources\video2.mp4" "C:\Sources\video2.mp4"]} changes the drive letter in the paths to the data sources.

Output Arguments

collapse all

Unresolved file paths, returned as a string array. If the changeFilePaths function cannot find either the current path or new path, then it returns the unresolved current paths.

If the function finds and resolves all file paths, then it returns unresolvedPaths as an empty string array.

Version History

Introduced in R2026b