コード例 #1
0
ファイル: show_aparc.py プロジェクト: ofek-schechner/mmvt
import os
from surfer import Brain
import glob
import mne
import colorsys
from PIL import Image
from mayavi import mlab
mlab.options.backend = 'auto'
import utils

subject = 'hc004' # 'mg79' #"fsaverage"
hemi = "rh"
surf = "pial"
subjects_dir = utils.get_exisiting_dir(['/home/noam/subjects', '/home/noam/subjects/mri', '/homes/5/npeled/space3/subjects'])
aparc_name = 'laus250'

os.environ['SUBJECTS_DIR'] = subjects_dir
os.environ['SUBJECT'] = subject

def annotation_to_labels():
    fol = os.path.join(subjects_dir, subject, 'label', aparc_name)
    if not(os.path.isdir(fol)):
        os.mkdir(fol)
    labels = mne.read_labels_from_annot(subject, parc=aparc_name, hemi='both', surf_name='pial')
    for label in labels:
        label.save(os.path.join(fol, label.name))


def get_spaced_colors(n):
    HSV_tuples = [(x*1.0/n, 0.5, 0.5) for x in range(n)]
    RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples)
コード例 #2
0
ファイル: spm_to_surf.py プロジェクト: pelednoam/mmvt
import os
import glob
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt

FS_SUBJECT = "colin27"
mri_robust_register = "mri_robust_register --mov {spm_brain_file} --dst {fs_brain_file} --lta {reg_file} --satit --vox2vox --mapmov {reg_spm_brain}"
mri_mask = "mri_mask {spm_map} {spm_mask} {spm_map_masked}"
# mri_vol2surf = 'mri_vol2surf --mov {spm_map_masked} --hemi {hemi} --surf pial --reg {reg_file} --projfrac-avg 0 1 0.1 --surf-fwhm 3 --o {fs_hemi_map}'
mri_vol2surf = "mri_vol2surf --mov {spm_mask} --hemi {hemi} --surf pial --reg {reg_file} --projfrac-avg 0 1 0.1 --surf-fwhm 3 --o {fs_hemi_map}"

SUBJECTS_DIR = "/homes/5/npeled/space3/subjects"
os.environ["SUBJECTS_DIR"] = SUBJECTS_DIR
FREE_SURFER_HOME = utils.get_exisiting_dir(
    [os.environ.get("FREESURFER_HOME", ""), "/usr/local/freesurfer/stable5_3_0", "/home/noam/freesurfer"]
)

SPM_ROOT = "/homes/5/npeled/space3/spm_subjects"
SPM_BRAIN_TEMPLATE = "w{subject}_MEMPRAGE_4e_1mm_iso_2.nii"
MAP_ROI = "VLPFC"
SPM_MASK_TEMPLATE = "{}_{}_Mask.img".format("{subject}", MAP_ROI)
FS_HEMI_MAP_TEMPLATE = "{}_{}_{}.mgz".format("{subject}", MAP_ROI, "{hemi}")
FS_BRAIN_FILE = "$SUBJECTS_DIR/colin27/mri/orig.mgz"


def run(
    root_dir,
    spm_brain_file,
    fs_brain_file,
    reg_file,
コード例 #3
0
ファイル: spm_to_surf.py プロジェクト: dorianps/mmvt
import os
import glob
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt

FS_SUBJECT = 'colin27'
mri_robust_register = 'mri_robust_register --mov {spm_brain_file} --dst {fs_brain_file} --lta {reg_file} --satit --vox2vox --mapmov {reg_spm_brain}'
mri_mask = 'mri_mask {spm_map} {spm_mask} {spm_map_masked}'
# mri_vol2surf = 'mri_vol2surf --mov {spm_map_masked} --hemi {hemi} --surf pial --reg {reg_file} --projfrac-avg 0 1 0.1 --surf-fwhm 3 --o {fs_hemi_map}'
mri_vol2surf = 'mri_vol2surf --mov {spm_mask} --hemi {hemi} --surf pial --reg {reg_file} --projfrac-avg 0 1 0.1 --surf-fwhm 3 --o {fs_hemi_map}'

SUBJECTS_DIR = '/homes/5/npeled/space3/subjects'
os.environ['SUBJECTS_DIR'] = SUBJECTS_DIR
FREE_SURFER_HOME = utils.get_exisiting_dir([
    os.environ.get('FREESURFER_HOME', ''), '/usr/local/freesurfer/stable5_3_0',
    '/home/noam/freesurfer'
])

SPM_ROOT = '/homes/5/npeled/space3/spm_subjects'
SPM_BRAIN_TEMPLATE = 'w{subject}_MEMPRAGE_4e_1mm_iso_2.nii'
MAP_ROI = 'VLPFC'
SPM_MASK_TEMPLATE = '{}_{}_Mask.img'.format('{subject}', MAP_ROI)
FS_HEMI_MAP_TEMPLATE = '{}_{}_{}.mgz'.format('{subject}', MAP_ROI, '{hemi}')
FS_BRAIN_FILE = '$SUBJECTS_DIR/colin27/mri/orig.mgz'


def run(root_dir,
        spm_brain_file,
        fs_brain_file,
        reg_file,
        reg_spm_brain,
コード例 #4
0
ファイル: meg_statistics.py プロジェクト: ofek-schechner/mmvt
import mne
from mne import spatial_tris_connectivity, grade_to_tris
from mne.stats import spatio_temporal_cluster_test, spatio_temporal_cluster_1samp_test, summarize_clusters_stc
from mne.minimum_norm import (write_inverse_operator, make_inverse_operator, apply_inverse,
        apply_inverse_epochs, read_inverse_operator)
from mne.source_estimate import _make_stc, VolSourceEstimate

# data_path = mne.datasets.sample.data_path()


# from surfer import Brain
# from surfer import viz

import utils

COMP_ROOT = utils.get_exisiting_dir(('/homes/5/npeled/space3', '/home/noam'))
LOCAL_SUBJECTS_DIR = op.join(COMP_ROOT, 'subjects')
REMOTE_ROOT_DIR = '/autofs/space/lilli_001/users/DARPA-MEG/ecr'
LOCAL_ROOT_DIR = op.join(COMP_ROOT, 'MEG/ECR/group')
BLENDER_DIR = op.join(COMP_ROOT, 'visualization_blender')
SUBJECTS_DIR = '/autofs/space/lilli_001/users/DARPA-MEG/freesurfs'
os.environ['SUBJECTS_DIR'] = LOCAL_SUBJECTS_DIR

blender_template = op.join(BLENDER_DIR, 'fsaverage', '{patient}_{cond_name}')


def get_subjects():
    if not op.isfile(op.join(LOCAL_ROOT_DIR, 'subjects.npy')):
        epos = glob.glob(op.join(REMOTE_ROOT_DIR, 'ave', '*_ecr_nTSSS_conflict-epo.fif'))
        subjects = [utils.namebase(s).split('_')[0] for s in epos]
        np.save(op.join(LOCAL_ROOT_DIR, 'subjects'), subjects)