Exemple #1
0
def freesurfer_create_subject_dir(basedir, T1dir, output_prefix):

    from nipype.interfaces.io import FreeSurferSource
    fs = FreeSurferSource()
    fs.inputs.subjects_dir = experiment_dir
    fs.inputs.subject_id = output_prefix
    res = fs.run()
    dir(res.outputs)
    print res.outputs
Exemple #2
0
def test_eulernumber(tmpdir):
    # grab a surface from fsaverage
    fssrc = FreeSurferSource(subjects_dir=fs.Info.subjectsdir(),
                             subject_id="fsaverage",
                             hemi="lh")
    pial = fssrc.run().outputs.pial
    assert isinstance(pial, str), "Problem when fetching surface file"

    eu = fs.EulerNumber()
    eu.inputs.in_file = pial
    res = eu.run()
    assert res.outputs.defects == 0
    assert res.outputs.euler == 2
Exemple #3
0
def test_mrisexpand(tmpdir):
    fssrc = FreeSurferSource(subjects_dir=fs.Info.subjectsdir(),
                             subject_id='fsaverage', hemi='lh')

    fsavginfo = fssrc.run().outputs.get()

    # dt=60 to ensure very short runtime
    expand_if = fs.MRIsExpand(in_file=fsavginfo['smoothwm'],
                              out_name='expandtmp',
                              distance=1,
                              dt=60)

    expand_nd = pe.Node(
        fs.MRIsExpand(in_file=fsavginfo['smoothwm'],
                      out_name='expandtmp',
                      distance=1,
                      dt=60),
        name='expand_node')

    # Interfaces should have same command line at instantiation
    orig_cmdline = 'mris_expand -T 60 {} 1 expandtmp'.format(fsavginfo['smoothwm'])
    assert expand_if.cmdline == orig_cmdline
    assert expand_nd.interface.cmdline == orig_cmdline

    # Run both interfaces
    if_res = expand_if.run()
    nd_res = expand_nd.run()

    # Commandlines differ
    node_cmdline = 'mris_expand -T 60 -pial {cwd}/lh.pial {cwd}/lh.smoothwm ' \
        '1 expandtmp'.format(cwd=nd_res.runtime.cwd)
    assert if_res.runtime.cmdline == orig_cmdline
    assert nd_res.runtime.cmdline == node_cmdline

    # Check output
    if_out_file = if_res.outputs.get()['out_file']
    nd_out_file = nd_res.outputs.get()['out_file']
    # Same filename
    assert op.basename(if_out_file) == op.basename(nd_out_file)
    # Interface places output in source directory
    assert op.dirname(if_out_file) == op.dirname(fsavginfo['smoothwm'])
    # Node places output in working directory
    assert op.dirname(nd_out_file) == nd_res.runtime.cwd

    # Remove test surface
    os.unlink(if_out_file)
Exemple #4
0
def test_mrisexpand(tmpdir):
    fssrc = FreeSurferSource(subjects_dir=fs.Info.subjectsdir(),
                             subject_id="fsaverage",
                             hemi="lh")

    fsavginfo = fssrc.run().outputs.get()

    # dt=60 to ensure very short runtime
    expand_if = fs.MRIsExpand(in_file=fsavginfo["smoothwm"],
                              out_name="expandtmp",
                              distance=1,
                              dt=60)

    expand_nd = pe.Node(
        fs.MRIsExpand(in_file=fsavginfo["smoothwm"],
                      out_name="expandtmp",
                      distance=1,
                      dt=60),
        name="expand_node",
    )

    # Interfaces should have same command line at instantiation
    orig_cmdline = "mris_expand -T 60 {} 1 expandtmp".format(
        fsavginfo["smoothwm"])
    assert expand_if.cmdline == orig_cmdline
    assert expand_nd.interface.cmdline == orig_cmdline

    # Run Node interface
    nd_res = expand_nd.run()

    # Commandlines differ
    node_cmdline = ("mris_expand -T 60 -pial {cwd}/lh.pial {cwd}/lh.smoothwm "
                    "1 expandtmp".format(cwd=nd_res.runtime.cwd))
    assert nd_res.runtime.cmdline == node_cmdline

    # Check output
    if_out_file = expand_if._list_outputs()["out_file"]
    nd_out_file = nd_res.outputs.get()["out_file"]
    # Same filename
    assert op.basename(if_out_file) == op.basename(nd_out_file)
    # Interface places output in source directory
    assert op.dirname(if_out_file) == op.dirname(fsavginfo["smoothwm"])
    # Node places output in working directory
    assert op.dirname(nd_out_file) == nd_res.runtime.cwd