コード例 #1
0
import os
from graphpype.nodes.correl_mat import (ExtractTS, IntersectMask,
                                        ExtractMeanTS, RegressCovar,
                                        ComputeConfCorMat)
from graphpype.utils import _make_tmp_dir

from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_nii")
img_file = os.path.join(data_path, "wrsub-01_task-rest_bold.nii")
gm_mask_file = os.path.join(data_path, "rwc1sub-01_T1w.nii")
wm_mask_file = os.path.join(data_path, "rwc2sub-01_T1w.nii")
csf_mask_file = os.path.join(data_path, "rwc3sub-01_T1w.nii")
indexed_mask_file = os.path.join(data_path, "ROI_HCP",
                                 "indexed_mask-ROI_HCP.nii")


def test_neuropycon_data():
    """test if neuropycon_data is installed"""
    assert os.path.exists(data_path)
    assert os.path.exists(img_file)
    assert os.path.exists(gm_mask_file)
    assert os.path.exists(wm_mask_file)
    assert os.path.exists(csf_mask_file)
    assert os.path.exists(indexed_mask_file)


def test_extract_ts():
    """ test ExtractTS"""
    _make_tmp_dir()
コード例 #2
0
ファイル: test_utils_net.py プロジェクト: neuroidss/graphpype
import os
import shutil
import numpy as np

from graphpype.utils_net import (return_net_list, read_Pajek_corres_nodes,
                                 read_Pajek_corres_nodes_and_sparse_matrix,
                                 export_Louvain_net_from_list)

from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_con")
conmat_file = os.path.join(data_path, "Z_cor_mat_resid_ts.npy")
coords_file = os.path.join(data_path, "ROI_MNI_coords-Atlas.txt")
Z_list_file = os.path.join(data_path, "data_graph", "Z_List.txt")
Pajek_net_file = os.path.join(data_path, "data_graph", "Z_List.net")


def test_data():
    """test if test_data is accessible"""
    assert os.path.exists(data_path)
    assert os.path.exists(conmat_file)
    assert os.path.exists(coords_file)
    assert os.path.exists(Z_list_file)
    assert os.path.exists(Pajek_net_file)


tmp_dir = "/tmp/test_graphpype"
if os.path.exists(tmp_dir):
    shutil.rmtree(tmp_dir)

os.makedirs(tmp_dir)
コード例 #3
0
import nipype.pipeline.engine as pe

from nipype.interfaces.utility import IdentityInterface
import nipype.interfaces.io as nio

import json  # noqa
import pprint  # noqa

###############################################################################

# Check if data are available

from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_nii")

data_path_mask = load_test_data("data_nii_HCP")

ROI_mask_file = op.join(data_path_mask, "indexed_mask-ROI_HCP.nii")
ROI_coords_file = op.join(data_path_mask, "ROI_coords-ROI_HCP.txt")
ROI_MNI_coords_file = op.join(data_path_mask, "ROI_MNI_coords-ROI_HCP.txt")
ROI_labels_file = op.join(data_path_mask, "ROI_labels-ROI_HCP.txt")

###############################################################################
# Then, we create our workflow and specify the `base_dir` which tells
# nipype the directory in which to store the outputs.

# workflow directory within the `base_dir`
conmat_analysis_name = 'nii_to_dyn_graph'
コード例 #4
0
# Authors: David Meunier <*****@*****.**>
# License: BSD (3-clause)
# sphinx_gallery_thumbnail_number = 2
import os.path as op
import nipype.pipeline.engine as pe
import nipype.interfaces.io as nio

from ephypype.nodes import create_iterator
from ephypype.nodes import get_frequency_band

###############################################################################
# Check if data are available

from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_inv_ts")

###############################################################################
# First, we create our workflow and specify the `base_dir` which tells
# nipype the directory in which to store the outputs.

# workflow directory within the `base_dir`
graph_analysis_name = 'inv_ts_to_graph_analysis'

main_workflow = pe.Workflow(name=graph_analysis_name)
main_workflow.base_dir = data_path

###############################################################################
# We now use a json file for describing the connectivity parameters, loaded
# from a json as a dictionnary
コード例 #5
0
def test_load_test_data():
    """Test load_test_data"""
    data_path = load_test_data("data_nii")
    assert os.path.exists(data_path)
コード例 #6
0
# Authors: David Meunier <*****@*****.**>

# License: BSD (3-clause)
# sphinx_gallery_thumbnail_number = 2
import os.path as op

import nipype.pipeline.engine as pe

from nipype.interfaces.utility import IdentityInterface
import nipype.interfaces.io as nio

###############################################################################
# Check if data are available
from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_con_meg")

###############################################################################
# This will be what we will loop on

freq_band_names = ['alpha', 'beta']

###############################################################################
# Then, we create our workflow and specify the `base_dir` which tells
# nipype the directory in which to store the outputs.

# workflow directory within the `base_dir`
graph_analysis_name = 'graph_analysis'

main_workflow = pe.Workflow(name=graph_analysis_name)
main_workflow.base_dir = data_path
コード例 #7
0
ファイル: test_utils_img.py プロジェクト: forksbot/graphpype
import os
# import numpy as np
# import nibabel as nib

# from graphpype.utils_img import (return_data_img_from_roi_mask)
from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_nii_HCP")
indexed_mask_file = os.path.join(data_path, "indexed_mask-ROI_HCP.nii")


def test_data():
    """test if test_data is accessible"""
    assert os.path.exists(data_path)
    # assert os.path.exists(indexed_mask_file)


# def test_return_data_img_from_roi_mask():
# """test_return_data_img_from_roi_mask"""
# data_img = nib.load(indexed_mask_file).get_data()
# test_vect = np.random.rand(len(np.unique(data_img))-1)

# data_img_vect = return_data_img_from_roi_mask(indexed_mask_file,
#                                               test_vect)
# data_img_vect_vals = np.unique(data_img_vect.get_data())[1:]

# assert all(data_img_vect_vals == np.unique(test_vect))
コード例 #8
0
from graphpype.labeled_mask import (segment_mask_in_ROI)

import os
import shutil

from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_nii_mask")
mask_file = os.path.join(data_path, "rwc1sub-01_T1w.nii")


def test_data():
    """test if test_data is accessible"""
    assert os.path.exists(data_path)
    assert os.path.exists(mask_file)


nb_ROIs = 10

tmp_dir = "/tmp/test_graphpype"

if os.path.exists(tmp_dir):
    shutil.rmtree(tmp_dir)

os.makedirs(tmp_dir)


def test_segment_mask_in_ROI():
    """test_segment_mask_in_ROI"""
    # with cube (default)
    indexed_mask_rois_file, _, _ = segment_mask_in_ROI(mask_file,
コード例 #9
0
import os
import string
import numpy as np
import nibabel as nib

from graphpype.utils_cor import (
    mean_select_mask_data, mean_select_indexed_mask_data, regress_parameters,
    return_conf_cor_mat, filter_data, normalize_data, return_corres_correl_mat,
    where_in_labels, return_corres_correl_mat_labels, spearmanr_by_hand)

from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_nii_min")

img_file = os.path.join(data_path, "wrsub-01_task-rest_bold.nii")
mask_file = os.path.join(data_path, "rwc1sub-01_T1w.nii")

data_path_HCP = load_test_data("data_nii_HCP")
indexed_mask_file = os.path.join(data_path_HCP, "indexed_mask-ROI_HCP.nii")


def test_data():
    """test if test_data is accessible"""
    assert os.path.exists(data_path)
    assert os.path.exists(img_file)
    assert os.path.exists(mask_file)

    assert os.path.exists(data_path_HCP)
    assert os.path.exists(indexed_mask_file)