コード例 #1
0
ファイル: coreg_demos.py プロジェクト: iglpdc/pypreprocess
def _nyu_rest_factory(session=1):
    from pypreprocess.nipype_preproc_spm_utils import SubjectData

    nyu_data = fetch_nyu_rest(sessions=[session], n_subjects=7)

    session_func = [x for x in nyu_data.func if "session%i" % session in x]
    session_anat = [
        x for x in nyu_data.anat_skull if "session%i" % session in x]

    for subject_id in set([os.path.basename(os.path.dirname
                                            (os.path.dirname(x)))
                           for x in session_func]):
        # instantiate subject_data object
        subject_data = SubjectData()
        subject_data.subject_id = subject_id
        subject_data.session_id = session

        # set func
        subject_data.func = [x for x in session_func if subject_id in x]
        assert len(subject_data.func) == 1
        subject_data.func = subject_data.func[0]

        # set anat
        subject_data.anat = [x for x in session_anat if subject_id in x]
        assert len(subject_data.anat) == 1
        subject_data.anat = subject_data.anat[0]

        # set subject output directory
        subject_data.output_dir = "/tmp/%s" % subject_id

        subject_data.sanitize(deleteorient=True, niigz2nii=False)

        yield (subject_data.subject_id, subject_data.func[0],
               subject_data.anat)
コード例 #2
0
def demo_nyu_rest(data_dir="/tmp/nyu_data", output_dir="/tmp/nyu_mrimc_output"):
    """Demo for FSL Feeds data.

    Parameters
    ----------
    data_dir: string, optional
        where the data is located on your disk, where it will be
        downloaded to
    output_dir: string, optional
        where output will be written to

    """

    # fetch data
    nyu_data = fetch_nyu_rest(data_dir=data_dir)

    # subject data factory
    def subject_factory(session=1):
        session_func = [x for x in nyu_data.func if "session%i" % session in x]

        for subject_id in set([os.path.basename(os.path.dirname(os.path.dirname(x))) for x in session_func]):
            # set func
            func = [x for x in session_func if subject_id in x]
            assert len(func) == 1
            func = func[0]

            yield SubjectData(
                subject_id=subject_id, func=func, output_dir=os.path.join(output_dir, "session%i" % session, subject_id)
            )

    # invoke demon to run de demo
    _demo_runner(subject_factory(), "NYU resting state")
コード例 #3
0
def demo_nyu_rest(data_dir="/tmp/nyu_data",
                  n_subjects=1,
                  output_dir="/tmp/nyu_rest_output",
                  ):
    """Demo for FSL Feeds data.

    Parameters
    ----------
    data_dir: string, optional
        where the data is located on your disk, where it will be
        downloaded to
    output_dir: string, optional
        where output will be written to

    """

    # fetch data
    nyu_data = fetch_nyu_rest(data_dir=data_dir, n_subjects=1)

    # subject data factory
    def subject_factory(session=1):
        session_func = [x for x in nyu_data.func if "session%i" % session in x]

        for subject_id in set([os.path.basename(
                    os.path.dirname
                    (os.path.dirname(x)))
                               for x in session_func]):
            # set func
            func = [
                x for x in session_func if subject_id in x]
            assert len(func) == 1
            func = func[0]

            yield SubjectData(subject_id=subject_id, func=func,
                              output_dir=os.path.join(
                    output_dir,
                    "session%i" % session, subject_id))

    # invoke demon to run de demo
    _fmri_demo_runner(subject_factory(), "NYU Resting State")
コード例 #4
0
ファイル: coreg_demos.py プロジェクト: rameshvs/pypreprocess
    def _nyu_rest_factory(session=1):
        from pypreprocess.nipype_preproc_spm_utils import SubjectData

        nyu_data = fetch_nyu_rest(data_dir=os.path.join(
            os.environ['HOME'], "CODE/datasets/nyu_rest/"),
                                  sessions=[session],
                                  n_subjects=7)

        session_func = [x for x in nyu_data.func if "session%i" % session in x]
        session_anat = [
            x for x in nyu_data.anat_skull if "session%i" % session in x
        ]

        for subject_id in set([
                os.path.basename(os.path.dirname(os.path.dirname(x)))
                for x in session_func
        ]):
            # instantiate subject_data object
            subject_data = SubjectData()
            subject_data.subject_id = subject_id
            subject_data.session_id = session

            # set func
            subject_data.func = [x for x in session_func if subject_id in x]
            assert len(subject_data.func) == 1
            subject_data.func = subject_data.func[0]

            # set anat
            subject_data.anat = [x for x in session_anat if subject_id in x]
            assert len(subject_data.anat) == 1
            subject_data.anat = subject_data.anat[0]

            # set subject output directory
            subject_data.output_dir = "/tmp/%s" % subject_id

            subject_data.sanitize(do_deleteorient=True, do_niigz2nii=False)

            yield (subject_data.subject_id, subject_data.func[0],
                   subject_data.anat)
コード例 #5
0
"""

# standard imports
import sys
import os

# import API for preprocessing business
from pypreprocess.nipype_preproc_spm_utils import do_subjects_preproc

# input data-grabber for SPM Auditory (single-subject) data
from pypreprocess.datasets import fetch_nyu_rest

# file containing configuration for preprocessing the data
this_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
jobfile = os.path.join(os.path.dirname(sys.argv[0]), "nyu_rest_preproc.ini")

# set dataset dir
if len(sys.argv) > 1:
    dataset_dir = sys.argv[1]
else:
    dataset_dir = os.path.join(this_dir, "nyu_rest")

# fetch spm auditory data
fetch_nyu_rest(data_dir=dataset_dir)

# preprocess the data
results = do_subjects_preproc(jobfile,
                              dataset_dir=os.path.join(dataset_dir,
                                                       "nyu_rest"))
assert len(results) == 1
コード例 #6
0
"""
Preprocessing of NYU rest data.
"""

# standard imports
import sys
import os

# import API for preprocessing business
from pypreprocess.nipype_preproc_spm_utils import do_subjects_preproc

# input data-grabber for SPM Auditory (single-subject) data
from pypreprocess.datasets import fetch_nyu_rest

# file containing configuration for preprocessing the data
jobfile = os.path.join(os.path.dirname(sys.argv[0]),
                       "nyu_rest_preproc.ini")


# fetch spm auditory data
sd = fetch_nyu_rest()

# preprocess the data
dataset_dir = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.dirname(
        sd.anat_skull[0]))))
results = do_subjects_preproc(jobfile, dataset_dir=dataset_dir)