• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python fsl.Info类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nipype.interfaces.fsl.Info的典型用法代码示例。如果您正苦于以下问题:Python Info类的具体用法?Python Info怎么用?Python Info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Info类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setup_infile

def setup_infile():
    global tmp_infile, tmp_dir
    ext = Info.output_type_to_ext(Info.output_type())
    tmp_dir = tempfile.mkdtemp()
    tmp_infile = os.path.join(tmp_dir, "foo" + ext)
    open(tmp_infile, "w")
    return tmp_infile, tmp_dir
开发者ID:amoliu,项目名称:nipype,代码行数:7,代码来源:test_preprocess.py


示例2: setup_infile

def setup_infile():
    global tmp_infile, tmp_dir
    ext = Info.output_type_to_ext(Info.output_type())
    tmp_dir = tempfile.mkdtemp()
    tmp_infile = os.path.join(tmp_dir, 'foo' + ext)
    file(tmp_infile, 'w')
    return tmp_infile, tmp_dir
开发者ID:satra,项目名称:NiPypeold,代码行数:7,代码来源:test_preprocess.py


示例3: setup_flirt

def setup_flirt(tmpdir):
    ext = Info.output_type_to_ext(Info.output_type())
    tmp_dir = str(tmpdir)
    _, infile = tempfile.mkstemp(suffix=ext, dir=tmp_dir)
    _, reffile = tempfile.mkstemp(suffix=ext, dir=tmp_dir)

    return (tmp_dir, infile, reffile)
开发者ID:mick-d,项目名称:nipype,代码行数:7,代码来源:test_preprocess.py


示例4: setup_flirt

def setup_flirt(tmpdir):
    ext = Info.output_type_to_ext(Info.output_type())
    infile = tmpdir.join("infile"+ext)
    infile.open("w")
    reffile = tmpdir.join("reffile"+ext)
    reffile.open("w")
    return (tmpdir, infile.strpath, reffile.strpath)
开发者ID:bpinsard,项目名称:nipype,代码行数:7,代码来源:test_preprocess.py


示例5: setup_infile

def setup_infile(tmpdir):
    ext = Info.output_type_to_ext(Info.output_type())
    tmp_dir = str(tmpdir)
    tmp_infile = os.path.join(tmp_dir, 'foo' + ext)
    open(tmp_infile, 'w')

    return (tmp_infile, tmp_dir)
开发者ID:mick-d,项目名称:nipype,代码行数:7,代码来源:test_preprocess.py


示例6: setup_infile

def setup_infile():
    global tmp_infile, tmp_dir, cwd
    cwd = os.getcwd()
    ext = Info.output_type_to_ext(Info.output_type())
    tmp_dir = tempfile.mkdtemp()
    tmp_infile = os.path.join(tmp_dir, 'foo' + ext)
    open(tmp_infile, 'w')
    os.chdir(tmp_dir)
    return tmp_infile, tmp_dir
开发者ID:DimitriPapadopoulos,项目名称:nipype,代码行数:9,代码来源:test_model.py


示例7: create_files_in_directory_plus_output_type

def create_files_in_directory_plus_output_type(request, tmpdir):
    func_prev_type = set_output_type(request.param)
    origdir = tmpdir.chdir()
    filelist = ['a.nii', 'b.nii']
    nifti_image_files(tmpdir.strpath, filelist, shape=(3,3,3,4))

    out_ext = Info.output_type_to_ext(Info.output_type())

    def fin():
        set_output_type(func_prev_type)
        origdir.chdir()

    request.addfinalizer(fin)
    return (filelist, tmpdir.strpath, out_ext)
开发者ID:mfalkiewicz,项目名称:nipype,代码行数:14,代码来源:fixtures.py


示例8: run_feat

def run_feat(bold_file, bold_folder, brainmask_file, feat_gen):
    from nipype.interfaces.fsl import ImageStats, FEAT, Info
    # from bm_functions import gen_default_feat_config
    from numpy import shape
    from textwrap import dedent

    fslFilename = bold_folder + 'feat.fsf'

    # Get the number of voxels in the 4D file
    statComp = ImageStats()
    statComp.inputs.in_file = bold_file
    statComp.inputs.op_string = '-v'

    numVox = int(statComp.run().outputs.out_stat[0])

    # Get the number of raw volumes
    statComp.inputs.split_4d = True

    numVol = shape(statComp.run().outputs.out_stat)[0]

    # Generate the file
    standard_T1_brain = Info.standard_image('MNI152_T1_2mm_brain')
    theString = feat_gen(bold_folder, bold_file, brainmask_file, standard_T1_brain, numVox, numVol)
    with open(fslFilename,'w') as out_file:
        out_file.write(dedent(theString))
    out_file.close()   

    # Run feat using the previously manipulated config
    runFeat = FEAT(fsf_file = fslFilename)
    # Run and pass back the foldername
    return runFeat.run().outputs.feat_dir
开发者ID:BrainModes,项目名称:TVB-Pypeline,代码行数:31,代码来源:fmri_preproc.py


示例9: create_files_in_directory

def create_files_in_directory():
    testdir = os.path.realpath(mkdtemp())
    origdir = os.getcwd()
    os.chdir(testdir)

    filelist = ['a.nii', 'b.nii']
    for f in filelist:
        hdr = nb.Nifti1Header()
        shape = (3, 3, 3, 4)
        hdr.set_data_shape(shape)
        img = np.random.random(shape)
        nb.save(nb.Nifti1Image(img, np.eye(4), hdr),
                os.path.join(testdir, f))

    out_ext = Info.output_type_to_ext(Info.output_type())
    return filelist, testdir, origdir, out_ext
开发者ID:amoliu,项目名称:nipype,代码行数:16,代码来源:test_maths.py


示例10: set_output_type

def set_output_type(fsl_output_type):
    prev_output_type = os.environ.get('FSLOUTPUTTYPE', None)

    if fsl_output_type is not None:
        os.environ['FSLOUTPUTTYPE'] = fsl_output_type
    elif 'FSLOUTPUTTYPE' in os.environ:
        del os.environ['FSLOUTPUTTYPE']

    FSLCommand.set_default_output_type(Info.output_type())
    return prev_output_type
开发者ID:shoshber,项目名称:nipype,代码行数:10,代码来源:fixtures.py


示例11: test_tbss_skeleton

def test_tbss_skeleton():
    skeletor = fsl.TractSkeleton()

    files, newdir, olddir = create_files_in_directory()

    # Test the underlying command
    yield assert_equal, skeletor.cmd, "tbss_skeleton"

    # It shouldn't run yet
    yield assert_raises, ValueError, skeletor.run

    # Test the most basic way to use it
    skeletor.inputs.in_file = files[0]

    # First by implicit argument
    skeletor.inputs.skeleton_file = True
    yield assert_equal, skeletor.cmdline, \
    "tbss_skeleton -i a.nii -o %s"%os.path.join(newdir, "a_skeleton.nii")

    # Now with a specific name
    skeletor.inputs.skeleton_file = "old_boney.nii"
    yield assert_equal, skeletor.cmdline, "tbss_skeleton -i a.nii -o old_boney.nii"

    # Now test the more complicated usage
    bones = fsl.TractSkeleton(in_file="a.nii", project_data=True)

    # This should error
    yield assert_raises, ValueError, bones.run

    # But we can set what we need
    bones.inputs.threshold = 0.2
    bones.inputs.distance_map = "b.nii"
    bones.inputs.data_file = "b.nii" # Even though that's silly

    # Now we get a command line
    yield assert_equal, bones.cmdline, \
    "tbss_skeleton -i a.nii -p 0.200 b.nii %s b.nii %s"%(Info.standard_image("LowerCingulum_1mm.nii.gz"),
                                                         os.path.join(newdir, "b_skeletonised.nii"))

    # Can we specify a mask?
    bones.inputs.use_cingulum_mask = Undefined
    bones.inputs.search_mask_file = "a.nii"
    yield assert_equal, bones.cmdline, \
    "tbss_skeleton -i a.nii -p 0.200 b.nii a.nii b.nii %s"%os.path.join(newdir, "b_skeletonised.nii")

    # Looks good; clean up
    clean_directory(newdir, olddir)
开发者ID:Alunisiira,项目名称:nipype,代码行数:47,代码来源:test_dti.py


示例12: fsl_name

def fsl_name(obj, fname):
    """Create valid fsl name, including file extension for output type.
    """
    ext = Info.output_type_to_ext(obj.inputs.output_type)
    return fname + ext
开发者ID:satra,项目名称:NiPypeold,代码行数:5,代码来源:test_preprocess.py


示例13: Registration

from nipype.pipeline.engine import Workflow, Node, MapNode
from nipype.interfaces.fsl import Info

# FreeSurfer - Specify the location of the freesurfer folder
fs_dir = '/data/adamt/Apps/fs6beta'
FSCommand.set_default_subjects_dir(fs_dir)

# Specify variables
experiment_dir = '/data/Hippo_hr/cpb/'          # location of experiment folder
input_dir_1st = 'output_ANTS_test_1st_lvl'     # name of 1st-level output folder
output_dir = 'output_ANTS_test_norm'  # name of norm output folder
working_dir = '/home/zhoud4/Hippo_hr/cpb/ants1/lhipp3_batch/'  # name of norm working directory
subject_list = ['d701', 'd702', 'd703']                     # list of subject identifiers

# location of template file
template = Info.standard_image('.nii.gz')

# Registration (good) - computes registration between subject's structural and MNI template.
antsreg = Node(Registration(args='--float',
                            collapse_output_transforms=True,
                            fixed_image=template,
                            initial_moving_transform_com=True,
                            num_threads=1,
                            output_inverse_warped_image=True,
                            output_warped_image=True,
                            sigma_units=['vox']*3,
                            transforms=['Rigid', 'Affine', 'SyN'],
                            terminal_output='file',
                            winsorize_lower_quantile=0.005,
                            winsorize_upper_quantile=0.995,
                            convergence_threshold=[1e-06],
开发者ID:dalejn,项目名称:ants_scripts,代码行数:31,代码来源:ANTS_TEST.py


示例14: setup_infile

def setup_infile(tmpdir):
    ext = Info.output_type_to_ext(Info.output_type())
    tmp_infile = tmpdir.join('foo' + ext)
    tmp_infile.open("w")
    return (tmp_infile.strpath, tmpdir.strpath)
开发者ID:bpinsard,项目名称:nipype,代码行数:5,代码来源:test_preprocess.py


示例15: Node

FSCommand.set_default_subjects_dir(fs_dir)


###
# Specify variables
experiment_dir = '~/nipype_tutorial'          # location of experiment folder
input_dir_1st = 'output_fMRI_example_1st'     # name of 1st-level output folder
output_dir = 'output_fMRI_example_norm_ants'  # name of norm output folder
working_dir = 'workingdir_fMRI_example_norm_ants'  # name of norm working directory
subject_list = ['sub001', 'sub002', 'sub003',
                'sub004', 'sub005', 'sub006',
                'sub007', 'sub008', 'sub009',
                'sub010']                     # list of subject identifiers

# location of template file
template = Info.standard_image('MNI152_T1_1mm_brain.nii.gz')


###
# Specify Normalization Nodes

# Registration - computes registration between subject's structural and MNI template.
antsreg = Node(Registration(args='--float',
                            collapse_output_transforms=True,
                            fixed_image=template,
                            initial_moving_transform_com=True,
                            num_threads=1,
                            output_inverse_warped_image=True,
                            output_warped_image=True,
                            sigma_units=['vox']*3,
                            transforms=['Rigid', 'Affine', 'SyN'],
开发者ID:JanisReinelt,项目名称:nipype-beginner-s-guide,代码行数:31,代码来源:example_fMRI_2_normalize_ANTS_partial.py


示例16: custom_level1design_feat

def custom_level1design_feat(func_file, highres_file=None, session_info=None, output_dirname='firstlevel',
                             contrasts='single-trial', smoothing=0, temp_deriv=False, registration='full', highpass=100,
                             slicetiming=None, motion_correction=None, bet=True, prewhitening=True, motion_regression=None,
                             thresholding='uncorrected', p_val=0.05, z_val=2.3, mask=None, hrf='doublegamma',
                             open_feat_html=False):
    """ Custom implementation of a FSL create-level1-design function.
    This function (which can be wrapped in a custom Nipype Function node) creates an FSL design.fsf
    file. This function is similar to the Nipype Level1Design node (interfaces.fsl.model) but allows
    for way more options to be set.
    Parameters
    ----------
    func_file : str
        Path to functional file (4D) with timeseries data
    highres_file : str
        Path to file corresponding to high-resolution anatomical scan (should already be skull-stripped!).
        Only necessary if doing functional-highres-standard registration (i.e. registration = 'full');
        otherwise, set to None.
    session_info : Nipype Bunch-object
        Bunch-object (dict-like) with information about stimulus-related and nuisance regressors.
    output_dirname : str
        Name of output directory (.feat will be appended to it).
    contrasts : str, tuple, or list
        (List of) tuple(s) with defined contrasts. Should be formatted using the Nipype syntax:
        `(name_of_contrast, 'T', [cond_name_1, cond_name_2], [weight_1, weight_2])` for a t-contrast,
        or `(name_of_f_test, 'F', [contrast_1, contrast_2])` for F-tests.
    smoothing : float or int
        Smoothing kernel in FWHM (mm)
    temp_deriv : bool
        Whether to include temporal derivates of real EVs.
    registration : str
        Registration-scheme to apply. Currently supports three types: 'full', which registers
        the functional file to the high-res anatomical (using FLIRT BBR) and subsequent linear-
        non-linear registration to the MNI152 (2mm) standard brain (using FNIRT); another option
        is 'fmriprep', which only calculates a 3-parameter (translation only) transformation because
        output from the fmriprep-preprocessing-pipeline is already registered to MNI but is still in
        native dimensions (i.e. EPI-space). Last option is 'none', which doesn't do any registration.
    highpass : int
        Length (in seconds) of FSL highpass filter to apply.
    slicetiming : str
        Whether to apply slice-time correction; options are 'up' (ascending), 'down' (descending),
        or 'no' (no slicetiming correction).
    motion_correction : bool
        Whether to apply motion-correction (MCFLIRT).
    bet : bool
        Whether to BET (skullstrip) the functional file.
    prewhitening : bool
        Whether to do prewhitening.
    motion_regression : str
        Whether to do motion-regression. Options: 'no' (no motion regression), 'yes' (standard 6 parameters motion
        regression), 'ext' (extended 24 parameter motion regression).
    thresholding : str
        What type of thresholding to apply. Options: 'none', 'uncorrected', 'voxel', 'cluster'.
    p_val : float
        What p-value to use in thresholding.
    z_val : float
        What minimum z-value to use in cluster-correction
    mask : str
        File to use in pre-thresholding masking. Setting to None means no masking.
    hrf : str
        What HRF-model to use. Default is 'doublegamma', but other options are: 'gamma',
        'gammabasisfunctions', 'gaussian'.
    open_feat_html : bool
        Whether to automatically open HTML-progress report.
    Returns
    -------
    design_file : str
        The path to the created design.fsf file
    confound_txt_file : str
        Path to the created confounds.txt file
    ev_files : list
        List with paths to EV-text-files.
    """
    import os.path as op
    import nibabel as nib
    from nipype.interfaces.fsl import Info
    import numpy as np
    import spynoza

    if isinstance(session_info, list):

        if len(session_info) == 1:
            session_info = session_info[0]

    if registration == 'full' and highres_file is None:
        raise ValueError("If you want to do a full registration, you need to specify a highres file!")

    if motion_correction in (0, False, 'yes') and motion_regression in ('yes', True, 1, 'ext', 2):
        raise ValueError("If you want to do motion-regression, make sure to turn on motion-correction!")

    if hrf == 'gammabasisfunctions' and temp_deriv:
        print("Cannot add temporal deriv when hrf = gammabasisfunctions; setting temp-deriv to False")
        temp_deriv = False

    n_orig_evs = len(session_info.conditions)
    if contrasts == 'single-trial':

        cons = []
        for i in range(n_orig_evs):
            con_values = np.zeros(len(session_info.conditions))
            con_values[i] = 1
#.........这里部分代码省略.........
开发者ID:spinoza-rec,项目名称:nitools,代码行数:101,代码来源:nodes.py



注:本文中的nipype.interfaces.fsl.Info类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python matlab.MatlabCommand类代码示例发布时间:2022-05-27
下一篇:
Python base.CommandLine类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap