import os.path as op
import nipype.interfaces.io as nio           # Data i/o
import nipype.interfaces.utility as util     # utility
import nipype.interfaces.fsl as fsl
import nipype.pipeline.engine as pe          # pypeline engine
from forward.struct import create_structural_mesh_workflow

from forward.datasets import sample
data_path = sample.data_path()

subjects_dir = op.join(data_path,"subjects")

fsl.FSLCommand.set_default_output_type('NIFTI_GZ')

# Normally something like:
# subjects_dir = os.environ["SUBJECTS_DIR"]
subject_list = ['TMS007']

infosource = pe.Node(interface=util.IdentityInterface(
    fields=['subject_id', 'subjects_dir']), name="infosource")
infosource.iterables = ('subject_id', subject_list)
infosource.inputs.subjects_dir = subjects_dir

datasink = pe.Node(interface=nio.DataSink(),
                   name="datasink")
datasink.inputs.base_directory = op.abspath('structural_datasink')
datasink.inputs.container = 'subject'

preproc = create_structural_mesh_workflow()

struct_proc = pe.Workflow(name="struct_proc")
Esempio n. 2
0
import os.path as op
from forward.datasets import sample
data_path = sample.data_path(name="leadfield")

from forward.leadfield import compare_leadfields

lf1 = op.join(data_path, "TMS007_iso_leadfield.hdf5")
lf2 = op.join(data_path, "TMS007_aniso_leadfield.hdf5")
mesh_file = op.join(data_path, "TMS007_gmsh_cond_elec.msh")
write_mesh = False

rms_mesh_file, rms_hdf5_avg, rms_hdf5_x, rms_hdf5_y, rms_hdf5_z = compare_leadfields(
    lf2, lf1, mesh_file, write_mesh)
Esempio n. 3
0
'''
The third step is to rewrite elements of the volume mesh with new element IDs.
These element IDs will be used to create the source and sink for the forward
modelling step. Elements are identified by their proximity the location of the
EEG electrodes provided.
'''

from forward.electrodes import rewrite_mesh_with_electrodes
import os.path as op
import glob

from forward.datasets import sample
data_path = sample.data_path()

subject_id = 'TMS007'
'''
The files required can be found in the ForwardSample data package,
and as the outputs of the diffusion pipeline (or structural)
'''

electrode_position_file = op.join(data_path, subject_id,
                                  "ElectrodePositions.txt")
electrode_name_file = op.join(data_path, subject_id, "ElectrodeNames.txt")

# If you want to use the structural mesh, rather than the mesh including the conductivity
# tensors, you should uncomment the following line, and comment the one below it.
#mesh_path = op.abspath("structural_datasink/subject/volume_mesh/")
mesh_path = op.abspath("diffusion_datasink/subject/mesh_file/")

assert (op.exists(mesh_path))
search_string = "/*%s/%s*.msh" % (subject_id, subject_id)
import os.path as op
import nipype.interfaces.io as nio           # Data i/o
import nipype.interfaces.utility as util     # utility
import nipype.interfaces.fsl as fsl
import nipype.pipeline.engine as pe          # pypeline engine
from forward.struct import create_structural_mesh_workflow

from forward.datasets import sample
data_path = sample.data_path(name="simnibs")
almi5_path = sample.data_path(name="almi5")

subjects_dir = op.abspath(op.curdir)
# Normally something like:
# subjects_dir = os.environ["SUBJECTS_DIR"]

fsl.FSLCommand.set_default_output_type('NIFTI_GZ')

# The fat-suppressed T1 should be run through freesurfer!
# See http://simnibs.de/documentation/mri_sequences

subject_list = ['almi5']
name = 'FourImage_'
infosource = pe.Node(interface=util.IdentityInterface(
    fields=['subject_id', 'subjects_dir']), name="infosource")
infosource.iterables = ('subject_id', subject_list)
infosource.inputs.subjects_dir = subjects_dir

info = dict(t2=[['subject_id', '_T2']],
            t2fs=[['subject_id', '_T2fs']],
            t1=[['subject_id', '_T1']])
Esempio n. 5
0
import os.path as op
import nipype.interfaces.io as nio  # Data i/o
import nipype.interfaces.utility as util  # utility
import nipype.interfaces.fsl as fsl
import nipype.pipeline.engine as pe  # pypeline engine
from forward.struct import create_structural_mesh_workflow

from forward.datasets import sample

data_path = sample.data_path(name="simnibs")
almi5_path = sample.data_path(name="almi5")

subjects_dir = op.abspath(op.curdir)
# Normally something like:
# subjects_dir = os.environ["SUBJECTS_DIR"]

fsl.FSLCommand.set_default_output_type('NIFTI_GZ')

# The fat-suppressed T1 should be run through freesurfer!
# See http://simnibs.de/documentation/mri_sequences

subject_list = ['almi5']
name = 'FourImage_'
infosource = pe.Node(
    interface=util.IdentityInterface(fields=['subject_id', 'subjects_dir']),
    name="infosource")
infosource.iterables = ('subject_id', subject_list)
infosource.inputs.subjects_dir = subjects_dir

info = dict(t2=[['subject_id', '_T2']],
            t2fs=[['subject_id', '_T2fs']],
'''
Here we use the previously derived leadfield matrix and an example dipole
to map the cost function in the gray matter elements. 
'''


import os
import os.path as op
import nipype.interfaces.io as nio           # Data i/o
import nipype.interfaces.utility as util     # utility
import nipype.pipeline.engine as pe          # pypeline engine
from forward.dipole import create_cost_function_workflow

from forward.datasets import sample
data_path = sample.data_path(name="leadfield")

'''
Define the markers, ground electrode, and any bad electrodes to ignore
'''

markers = ['LeftEar', 'RightEar', 'NZ']
ground_electrode = 'IZ'
dipole_row = 3525

'''
Define the mesh file to be used. This should be the volume mesh 
output of the structural preprocessing workflow.
'''

conductivity_tensor_included = False
Esempio n. 7
0
import os
import os.path as op
import nipype.interfaces.io as nio           # Data i/o
import nipype.interfaces.utility as util     # utility
import nipype.interfaces.fsl as fsl
import nipype.pipeline.engine as pe          # pypeline engine
from forward.dti import create_conductivity_tensor_mesh_workflow

from forward.datasets import sample
data_path = sample.data_path(name="simnibs")

fsl.FSLCommand.set_default_output_type('NIFTI_GZ')

subject_list = ['almi5']
name="FourImage_"

infosource = pe.Node(interface=util.IdentityInterface(
    fields=['subject_id']), name="infosource")
infosource.iterables = ('subject_id', subject_list)

info = dict(dwi=[['subject_id', 'DWI']],
            bvecs=[['subject_id', 'DWI_bvecs']],
            bvals=[['subject_id', 'DWI_bvals']],
            mesh_file=[['subject_id', 'subject_id']],
            struct=[['subject_id', 'T1fs']],
            t1_fsl_space=[['subject_id', 'orig']])

datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
                                               outfields=info.keys()),
                     name='datasource')