<commit_before>/**
 * Type
 *
 * A library of functions that take a file path and return a boolean
 * representing whether the given file path is valid within the
 * BIDS specification requirements.
 */
var anatSuffixes = ["T1w", "T2w", "T1map", "T2map", "T1rho", "FLAIR", "PD", "PDT2", "inplaneT1", "inplaneT2","angio",
    "SWImagandphase", "T2star", "FLASH", "PDmap", "photo"];

module.exports = {

    /**
     * Is BIDS
     *
     * Check if a given path is valid within the
     * bids spec.
     */
    isBIDS: function (path) {
        return (
            this.isTopLevel(path) ||
            this.isStimuliData(path) ||
            this.isSessionLevel(path) ||
            this.isSubjectLevel(path) ||
            this.isAnat(path) ||
            this.isDWI(path) ||
            this.isFunc(path) ||
            this.isMeg(path) ||
            this.isIEEG(path) ||
            this.isBehavioral(path) ||
            this.isCont(path) ||
            this.isFieldMap(path) ||
            this.isPhenotypic(path)
        );
    },

    /**
     * Check if the file has appropriate name for a top level file
     */
    isTopLevel: function (path) {
        var fixedTopLevelNames = ["/README", "/CHANGES", "/dataset_description.json", "/participants.tsv",
            "/participants.json", "/phasediff.json", "/phase1.json", "/phase2.json", "/fieldmap.json"];

        var funcTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:recording-[a-zA-Z0-9]+_)?(?:task-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?(?:echo-[0-9]+_)?'
            + '(bold.json|sbref.json|events.json|events.tsv|physio.json|stim.json|beh.json)$');

        var anatTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?'
            + '(' + anatSuffixes.join("|") + ').json$');

        var dwiTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?'
            + 'dwi.(?:json|bval|bvec)$');

        var multiDirFieldmapRe = new RegExp('^\\/(?:dir-[a-zA-Z0-9]+)_epi.json$');

        var megTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?'
            + '(_meg.json|_channels.tsv|_photo.jpg|_coordsystem.json)$');

        var ieegTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:_space-[a-zA-Z0-9]+)?'
            + '(_ieeg.json|_channels.tsv|_electrodes.tsv|_photo.jpg|_coordsystem.json)$');

        var otherTopFiles = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:recording-[a-zA-Z0-9]+_)?(?:task-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?'
            + '(physio.json|stim.json)$');

        return (fixedTopLevelNames.indexOf(path) != -1 || funcTopRe.test(path) || dwiTopRe.test(path) ||
        anatTopRe.test(path) || multiDirFieldmapRe.test(path) || otherTopFiles.test(path) || megTopRe.test(path) ||
        ieegTopRe.test(path));
    },

    /**
     * Check if file is appropriate associated data.
     */
    isAssociatedData: function (path) {
        var associatedData = new RegExp('^\\/(?:code|derivatives|sourcedata|stimuli|[.]git)\\/(?:.*)$');
        return associatedData.test(path);
    },

    isStimuliData: function (path) {<commit_msg>adding support for space in filename for ieeg<commit_after>/**
 * Type
 *
 * A library of functions that take a file path and return a boolean
 * representing whether the given file path is valid within the
 * BIDS specification requirements.
 */
var anatSuffixes = ["T1w", "T2w", "T1map", "T2map", "T1rho", "FLAIR", "PD", "PDT2", "inplaneT1", "inplaneT2","angio",
    "SWImagandphase", "T2star", "FLASH", "PDmap", "photo"];

module.exports = {

    /**
     * Is BIDS
     *
     * Check if a given path is valid within the
     * bids spec.
     */
    isBIDS: function (path) {
        return (
            this.isTopLevel(path) ||
            this.isStimuliData(path) ||
            this.isSessionLevel(path) ||
            this.isSubjectLevel(path) ||
            this.isAnat(path) ||
            this.isDWI(path) ||
            this.isFunc(path) ||
            this.isMeg(path) ||
            this.isIEEG(path) ||
            this.isBehavioral(path) ||
            this.isCont(path) ||
            this.isFieldMap(path) ||
            this.isPhenotypic(path)
        );
    },

    /**
     * Check if the file has appropriate name for a top level file
     */
    isTopLevel: function (path) {
        var fixedTopLevelNames = ["/README", "/CHANGES", "/dataset_description.json", "/participants.tsv",
            "/participants.json", "/phasediff.json", "/phase1.json", "/phase2.json", "/fieldmap.json"];

        var funcTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:recording-[a-zA-Z0-9]+_)?(?:task-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?(?:echo-[0-9]+_)?'
            + '(bold.json|sbref.json|events.json|events.tsv|physio.json|stim.json|beh.json)$');

        var anatTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?'
            + '(' + anatSuffixes.join("|") + ').json$');

        var dwiTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?'
            + 'dwi.(?:json|bval|bvec)$');

        var multiDirFieldmapRe = new RegExp('^\\/(?:dir-[a-zA-Z0-9]+)_epi.json$');

        var megTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?'
            + '(_meg.json|_channels.tsv|_photo.jpg|_coordsystem.json)$');

        var ieegTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?'
            + '(_ieeg.json|_channels.tsv|_electrodes.tsv|_photo.jpg|_coordsystem.json)$');

        var otherTopFiles = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:recording-[a-zA-Z0-9]+_)?(?:task-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?'
            + '(physio.json|stim.json)$');

        return (fixedTopLevelNames.indexOf(path) != -1 || funcTopRe.test(path) || dwiTopRe.test(path) ||
        anatTopRe.test(path) || multiDirFieldmapRe.test(path) || otherTopFiles.test(path) || megTopRe.test(path) ||
        ieegTopRe.test(path));
    },

    /**
     * Check if file is appropriate associated data.
     */
    isAssociatedData: function (path) {
        var associatedData = new RegExp('^\\/(?:code|derivatives|sourcedata|stimuli|[.]git)\\/(?:.*)$');
        return associatedData.test(path);
    },

    isStimuliData: function (path) {
{'fraction_non_alphanumeric': 0.24166916841789252, 'fraction_numerical': 0.02191534073851696, 'mean_word_length': 2.6251360174102287, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7078587', 'n_tokens_mistral': 2749, 'n_tokens_neox': 2572, 'n_words': 339}