Ejemplo n.º 1
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import fetch_data, get_home, get_testing_files_dict

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['processing.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_extract_dwi_shell.py', '--help')
    assert ret.success


def test_execution_processing_1000(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_dwi = os.path.join(get_home(), 'processing', 'dwi_crop.nii.gz')
    in_bval = os.path.join(get_home(), 'processing', 'dwi.bval')
    in_bvec = os.path.join(get_home(), 'processing', 'dwi.bvec')
    ret = script_runner.run('scil_extract_dwi_shell.py', in_dwi, in_bval,
                            in_bvec, '0', '1000', 'dwi_crop_1000.nii.gz',
                            '1000.bval', '1000.bvec', '-t', '30')
    assert ret.success


def test_execution_processing_3000(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
Ejemplo n.º 2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import get_testing_files_dict, fetch_data, get_home

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['filtering.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_filter_tractogram.py', '--help')
    assert ret.success


def test_execution_filtering(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_tractogram = os.path.join(get_home(), 'filtering',
                                 'bundle_all_1mm_inliers.trk')
    in_roi = os.path.join(get_home(), 'filtering', 'mask.nii.gz')
    in_bdo = os.path.join(get_home(), 'filtering', 'sc.bdo')
    ret = script_runner.run('scil_filter_tractogram.py', in_tractogram,
                            'bundle_4.trk', '--display_counts', '--drawn_roi',
                            in_roi, 'any', 'include', '--bdo', in_bdo, 'any',
                            'include', '--save_rejected',
                            'bundle_4_rejected.trk')
    assert ret.success
Ejemplo n.º 3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import get_testing_files_dict, fetch_data, get_home


# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['stats.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run(
        'scil_group_comparison.py',
        '--help')
    assert ret.success


def test_execution_bundles(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_json = os.path.join(get_home(), 'stats', 'participants.tsv')
    in_participants = os.path.join(get_home(), 'stats', 'meanstd_all.json')

    ret = script_runner.run('scil_group_comparison.py',
                            in_participants, in_json, 'Group',
                            '-b', 'AF_L',
                            '-m', 'FIT_FW',
                            '--va', 'mean',
Ejemplo n.º 4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import get_testing_files_dict, fetch_data, get_home

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['connectivity.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_filter_connectivity.py', '--help')
    assert ret.success


def test_execution_connectivity(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_sc = os.path.join(get_home(), 'connectivity', 'sc.npy')
    in_sim = os.path.join(get_home(), 'connectivity', 'len.npy')
    ret = script_runner.run('scil_filter_connectivity.py', 'mask.npy',
                            '--greater_than', in_sc, '5', '1',
                            '--greater_than', in_sim, '0', '1',
                            '--keep_condition_count')
    assert ret.success
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import get_testing_files_dict, fetch_data, get_home


# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['tractometry.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_compute_endpoints_metric.py', '--help')
    assert ret.success


def test_execution_tractometry(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_bundle = os.path.join(get_home(), 'tractometry',
                             'IFGWM_uni.trk')
    in_ref = os.path.join(get_home(), 'tractometry',
                          'mni_masked.nii.gz')
    ret = script_runner.run('scil_compute_endpoints_metric.py', in_bundle,
                            in_ref, 'out/')

    assert ret.success
Ejemplo n.º 6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import fetch_data, get_home, get_testing_files_dict

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['tracking.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_smooth_streamlines.py', '--help')
    assert ret.success


def test_execution_tracking(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_tracto = os.path.join(get_home(), 'tracking', 'union_shuffle_sub.trk')
    ret = script_runner.run('scil_smooth_streamlines.py', in_tracto,
                            'union_shuffle_sub_smooth.trk', '--gaussian', '10',
                            '-e', '0.05')
    assert ret.success
Ejemplo n.º 7
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import fetch_data, get_home, get_testing_files_dict

fetch_data(get_testing_files_dict(), keys=['commit_amico.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_compute_msmt_fodf.py', '--help')
    assert ret.success


def test_execution_processing(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_dwi = os.path.join(get_home(), 'commit_amico', 'dwi.nii.gz')
    in_bval = os.path.join(get_home(), 'commit_amico', 'dwi.bval')
    in_bvec = os.path.join(get_home(), 'commit_amico', 'dwi.bvec')
    in_wm_frf = os.path.join(get_home(), 'commit_amico', 'wm_frf.txt')
    in_gm_frf = os.path.join(get_home(), 'commit_amico', 'gm_frf.txt')
    in_csf_frf = os.path.join(get_home(), 'commit_amico', 'csf_frf.txt')
    mask = os.path.join(get_home(), 'commit_amico', 'mask.nii.gz')

    ret = script_runner.run('scil_compute_msmt_fodf.py', in_dwi, in_bval,
                            in_bvec, in_wm_frf, in_gm_frf, in_csf_frf,
                            '--mask', mask, '--wm_out_fODF', 'wm_fodf.nii.gz',
                            '--gm_out_fODF', 'gm_fodf.nii.gz',
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import get_testing_files_dict, fetch_data, get_home


# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['others.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_generate_gradient_sampling.py', '--help')
    assert ret.success


def test_execution_others(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    ret = script_runner.run('scil_generate_gradient_sampling.py',
                            '32', '64', 'encoding.b', '--mrtrix', '--eddy',
                            '--duty', '--b0_every', '25', '--b0_end',
                            '--bvals', '800', '1200')
    assert ret.success
Ejemplo n.º 9
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import get_testing_files_dict, fetch_data, get_home

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['bundles.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_register_tractogram.py', '--help')
    assert ret.success


def test_execution_bundles(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_moving = os.path.join(get_home(), 'bundles', 'bundle_0_reco.tck')
    in_static = os.path.join(get_home(), 'bundles', 'voting_results',
                             'bundle_0.trk')
    in_ref = os.path.join(get_home(), 'bundles', 'bundle_all_1mm.nii.gz')
    ret = script_runner.run('scil_register_tractogram.py', in_moving,
                            in_static, '--only_rigid',
                            '--moving_tractogram_ref', in_ref)
    assert ret.success
Ejemplo n.º 10
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import get_testing_files_dict, fetch_data, get_home

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys='surface_vtk_fib.zip')
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_compress_streamlines.py', '--help')
    assert ret.success


def test_execution_surface_vtk_fib(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_fib = os.path.join(get_home(), 'surface_vtk_fib', 'gyri_fanning.trk')
    ret = script_runner.run('scil_compress_streamlines.py', in_fib,
                            'gyri_fanning_c.trk', '-e', '0.1')
    assert ret.success
Ejemplo n.º 11
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import fetch_data, get_home, get_testing_files_dict

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['ihMT.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_compute_ihMT_maps.py', '--help')
    assert ret.success


def test_execution_ihMT_no_option(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))

    in_mask = os.path.join(get_home(), 'ihMT', 'mask.nii.gz')

    in_e1_altnp = os.path.join(get_home(), 'ihMT',
                               'echo-1_acq-altnp_ihmt.nii.gz')
    in_e2_altnp = os.path.join(get_home(), 'ihMT',
                               'echo-2_acq-altnp_ihmt.nii.gz')
    in_e3_altnp = os.path.join(get_home(), 'ihMT',
                               'echo-3_acq-altnp_ihmt.nii.gz')

    in_e1_altpn = os.path.join(get_home(), 'ihMT',
Ejemplo n.º 12
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import tempfile

from scilpy.io.fetcher import get_testing_files_dict, fetch_data, get_home

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['anatomical_filtering.zip'])
tmp_dir = tempfile.TemporaryDirectory()


def test_help_option(script_runner):
    ret = script_runner.run('scil_filter_tractogram_anatomically.py', '--help')
    assert ret.success


def test_execution_filtering(script_runner):
    os.chdir(os.path.expanduser(tmp_dir.name))
    in_tractogram = os.path.join(get_home(), 'anatomical_filtering',
                                 'tractogram_filter_ana.trk')
    in_wmparc = os.path.join(get_home(), 'anatomical_filtering',
                             'wmparc_filter_ana.nii.gz')
    ret = script_runner.run('scil_filter_tractogram_anatomically.py',
                            in_tractogram, in_wmparc,
                            os.path.expanduser(tmp_dir.name), '--minL', '40',
                            '--maxL', '200', '-a', '300')
    assert ret.success