Example #1
0
def test_bug_fix_issue_36_on_realign():
    from pypreprocess.datasets import fetch_spm_auditory
    sd = fetch_spm_auditory("/tmp/spm_auditory/")

    # shouldn't throw an IndexError
    MRIMotionCorrection(n_sessions=8, quality=1.).fit(
        [sd.func[:2], sd.func[:3]] * 4).transform("/tmp")
def _spm_auditory_subject_data():
    """ Fetching auditory example into SubjectData Structure
    """
    subject_data = fetch_spm_auditory()
    subject_data['func'] = None
    base_dir = os.path.dirname(subject_data['anat'])
    subject_data.output_dir = os.path.join(base_dir, OUTPUT_DIR)
    return SubjectData(**subject_data)
Example #3
0
def demo_spm_auditory(output_dir):
    """Demo for SPM single-subject Auditory

    Parameters
    ----------
    output_dir: string
        where output will be written to

    """
    output_dir = os.path.join(output_dir, "spm_auditory_output")
    spm_auditory = fetch_spm_auditory()
    subject_id = "sub001"
    subjects = [SubjectData(subject_id=subject_id,
                            func=[spm_auditory.func],
                            output_dir=os.path.join(output_dir, subject_id))]
    _demo_runner(subjects, "SPM single-subject Auditory")
Example #4
0
def demo_spm_auditory(output_dir):
    """Demo for SPM single-subject Auditory

    Parameters
    ----------
    output_dir: string
        where output will be written to

    """
    output_dir = os.path.join(output_dir, "spm_auditory_output")
    spm_auditory = fetch_spm_auditory()
    subject_id = "sub001"
    subjects = [
        SubjectData(subject_id=subject_id,
                    func=[spm_auditory.func],
                    output_dir=os.path.join(output_dir, subject_id))
    ]
    _demo_runner(subjects, "SPM single-subject Auditory")
def demo_spm_auditory(output_dir="/tmp/spm_auditory_output"):
    """Demo for SPM single-subject Auditory

    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

    """
    spm_auditory = fetch_spm_auditory()
    subject_id = "sub001"
    subjects = [SubjectData(subject_id=subject_id,
                            func=[spm_auditory.func],
                            output_dir=os.path.join(output_dir, subject_id))]
    _demo_runner(subjects, "SPM single-subject Auditory")
Example #6
0
def demo_spm_auditory(output_dir="/tmp/spm_auditory_output"):
    """Demo for SPM single-subject Auditory

    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

    """
    spm_auditory = fetch_spm_auditory()
    subject_id = "sub001"
    subjects = [
        SubjectData(subject_id=subject_id,
                    func=[spm_auditory.func],
                    output_dir=os.path.join(output_dir, subject_id))
    ]
    _demo_runner(subjects, "SPM single-subject Auditory")
Example #7
0
def _spm_auditory_factory():
    sd = fetch_spm_auditory()
    return sd.func[0], sd.anat
Example #8
0
from pypreprocess.nipype_preproc_spm_utils import do_subjects_preproc
from pypreprocess.datasets import fetch_spm_auditory
from pypreprocess.reporting.glm_reporter import generate_subject_stats_report
import pandas as pd
from pypreprocess.external.nistats.design_matrix import (make_design_matrix,
                                                         check_design_matrix,
                                                         plot_design_matrix)
from pypreprocess.external.nistats.glm import FirstLevelGLM
import matplotlib.pyplot as plt

# file containing configuration for preprocessing the data
this_dir = os.path.dirname(os.path.abspath(__file__))
jobfile = os.path.join(this_dir, "spm_auditory_preproc.ini")

# fetch spm auditory data
sd = fetch_spm_auditory()
dataset_dir = os.path.dirname(os.path.dirname(os.path.dirname(sd.anat)))

# construct experimental paradigm
stats_start_time = time.ctime()
tr = 7.
n_scans = 96
_duration = 6
n_conditions = 2
epoch_duration = _duration * tr
conditions = ['rest', 'active'] * 8
duration = epoch_duration * np.ones(len(conditions))
onset = np.linspace(0, (len(conditions) - 1) * epoch_duration, len(conditions))
paradigm = pd.DataFrame({
    'onset': onset,
    'duration': duration,
Example #9
0
def _spm_auditory_factory():
    sd = fetch_spm_auditory()
    return sd.func[0], sd.anat
import numpy as np
import pylab as pl
import nibabel
from nipy.modalities.fmri.experimental_paradigm import BlockParadigm
from nipy.modalities.fmri.design_matrix import make_dmtx
from nipy.modalities.fmri.glm import FMRILinearModel
from pypreprocess.nipype_preproc_spm_utils import do_subjects_preproc
from pypreprocess.datasets import fetch_spm_auditory
from pypreprocess.reporting.glm_reporter import generate_subject_stats_report

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

# fetch spm auditory data
sd = fetch_spm_auditory()
dataset_dir = os.path.dirname(os.path.dirname(os.path.dirname(sd.anat)))

# construct experimental paradigm
stats_start_time = time.ctime()
tr = 7.
n_scans = 96
_duration = 6
epoch_duration = _duration * tr
conditions = ['rest', 'active'] * 8
duration = epoch_duration * np.ones(len(conditions))
onset = np.linspace(0, (len(conditions) - 1) * epoch_duration,
                    len(conditions))
paradigm = BlockParadigm(con_id=conditions, onset=onset, duration=duration)
hfcut = 2 * 2 * epoch_duration
fd = open(sd.func[0].split(".")[0] + "_onset.txt", "w")