HED JavaScript Library
    Preparing search index...

    Class BidsDirectoryAccessor

    A BIDS file accessor for local directory environments (e.g., Node.js).

    This class reads files from the local file system.

    // In a Node.js environment:
    const { BidsDataset, BidsDirectoryAccessor } = require('hed-validator');
    const path = require('path');

    async function main() {
    const dataRoot = path.join(__dirname, 'path/to/bids/dataset');
    const [dataset, issues] = await BidsDataset.create(dataRoot, BidsDirectoryAccessor);
    if (dataset) {
    const validationIssues = await dataset.validate();
    // process issues
    } else {
    // process creation issues
    }
    }

    main();

    Hierarchy (View Summary)

    Index

    Constructors

    • Constructs a BidsDirectoryAccessor.

      Parameters

      • datasetRootDirectory: string

        The absolute path to the dataset's root directory.

      • fileMap: Map<string, string>

        A map of relative file paths to their absolute paths.

      Returns BidsDirectoryAccessor

      If the dataset root directory path is invalid.

    Properties

    datasetRootDirectory: string

    The root directory of the dataset.

    fileMap: Map<string, any>

    Map of relative file paths to file representations.

    organizedPaths: Map<string, Map<string, string[]>>

    Organized paths.

    SPECIAL_DIRS: string[] = ...

    BIDS special directories.

    SUFFIXES: string[] = ...

    BIDS suffixes.

    Methods

    • Asynchronously reads the content of a file from the file system.

      Parameters

      • relativePath: string

        The relative path to the file within the dataset.

      Returns Promise<string>

      A promise that resolves with the file content as a string, or null if the file is not found or an error occurs.

    • Factory method to create a BidsDirectoryAccessor.

      This method recursively reads the specified directory and creates a file map.

      Parameters

      • datasetRootDirectory: string

        The absolute path to the dataset's root directory.

      Returns Promise<BidsDirectoryAccessor>

      A Promise that resolves to a new BidsDirectoryAccessor instance.

      If the dataset root directory path is empty.