<commit_before>import pandas as pd
import glob
import os.path as op
import dipy.core.gradients as dpg
from dipy.segment.mask import median_otsu


def do_preprocessing():
    raise NotImplementedError


class AFQ(object):
    """
    Requires the following file structure:

    study_folder/
                sub-01
                sub-02/sess-test
                sub-02/sess-retest/anat/T1w.nii.gz
                sub-02/sess-retest/dwi/dwi.nii.gz
                sub-02/sess-retest/dwi/dwi.bvals
                sub-02/sess-retest/dwi/dwi.bvecs


    All subjects'/sessions' dwi_prefix needs to be the same!

    That is, you *can't* have:

        sub-01/sess-test/dwi/dwi.nii.gz
        sub-02/sess-retest/dwi/dwi_foo.nii.gz

    Even though these are different subjects/sessions/etc.

    Instead you can (and must!) have:

        sub-01/sess-test/dwi/mydata_foo.nii.gz
        sub-02/sess-retest/dwi/mydata_foo.nii.gz

    Where any part of this string (e.g. "foo") can report on things like the
    number of directions, the preprocessing that happened, etc.

    """
    def __init__(self, raw_path=None, preproc_path=None,
                 sub_prefix="sub", dwi_folder="dwi",
                 dwi_file="*dwi*", anat_folder="anat",
                 anat_file="*T1w"):
        self.raw_path = raw_path
        self.preproc_path = preproc_path
        if self.preproc_path is None:
            if self.raw_path is None:
                e_s = "must provide either preproc_path or raw_path (or both)"
                raise ValueError(e_s)
            # This creates the preproc_path such that:
            self.preproc_path = do_preprocessing(self.raw_path)
        # This is the place in which each subject's full data lives
        self.subject_dirs = glob.glob(preproc_path + '%s*'%sub_prefix)
        self.subjects = [op.split(p)[-1] for p in self.subject_dirs]<commit_msg>More flexible pattern for T1w, for HCP data.<commit_after>import pandas as pd
import glob
import os.path as op
import dipy.core.gradients as dpg
from dipy.segment.mask import median_otsu


def do_preprocessing():
    raise NotImplementedError


class AFQ(object):
    """
    Requires the following file structure:

    study_folder/
                sub-01
                sub-02/sess-test
                sub-02/sess-retest/anat/T1w.nii.gz
                sub-02/sess-retest/dwi/dwi.nii.gz
                sub-02/sess-retest/dwi/dwi.bvals
                sub-02/sess-retest/dwi/dwi.bvecs


    All subjects'/sessions' dwi_prefix needs to be the same!

    That is, you *can't* have:

        sub-01/sess-test/dwi/dwi.nii.gz
        sub-02/sess-retest/dwi/dwi_foo.nii.gz

    Even though these are different subjects/sessions/etc.

    Instead you can (and must!) have:

        sub-01/sess-test/dwi/mydata_foo.nii.gz
        sub-02/sess-retest/dwi/mydata_foo.nii.gz

    Where any part of this string (e.g. "foo") can report on things like the
    number of directions, the preprocessing that happened, etc.

    """
    def __init__(self, raw_path=None, preproc_path=None,
                 sub_prefix="sub", dwi_folder="dwi",
                 dwi_file="*dwi*", anat_folder="anat",
                 anat_file="*T1w*"):
        self.raw_path = raw_path
        self.preproc_path = preproc_path
        if self.preproc_path is None:
            if self.raw_path is None:
                e_s = "must provide either preproc_path or raw_path (or both)"
                raise ValueError(e_s)
            # This creates the preproc_path such that:
            self.preproc_path = do_preprocessing(self.raw_path)
        # This is the place in which each subject's full data lives
        self.subject_dirs = glob.glob(preproc_path + '%s*'%sub_prefix)
        self.subjects = [op.split(p)[-1] for p in self.subject_dirs]
{'fraction_non_alphanumeric': 0.09620453347390617, 'fraction_numerical': 0.012387981022667369, 'mean_word_length': 2.1546134663341645, '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': '2694154', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1262, 'n_words': 300}