Note
The code needs the FieldTrip package installed, with path properly setup, for this example to run.
\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import json # noqa\nimport pprint # noqa\nparams = json.load(open(\"params.json\"))\npprint.pprint({'time frequency parameters': params[\"tfr\"]})\nft_path = params[\"tfr\"]['fieldtrip_path']\nrefmethod = params[\"tfr\"]['refmethod']\nchannels_name = params[\"tfr\"]['channels_name']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Then, we create our workflow and specify the `base_dir` which tells\nnipype the directory in which to store the outputs.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"workflow_name = 'time_frequency_analysis'\n\nmain_workflow = pe.Workflow(name=workflow_name)\nmain_workflow.base_dir = data_path"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Then we create a node to pass input filenames to DataGrabber from nipype\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"subject_ids = ['SubjectUCI29']\ninfosource = create_iterator(['subject_id'], [subject_ids])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"and a node to grab data.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"template_path = '%s*.mat'\ntemplate_args = [['subject_id']]\ndatasource = create_datagrabber(data_path, template_path, template_args,\n infields=['subject_id'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We then the output (subject_id) of the infosource node to the datasource one.\nSo, these two nodes taken together can grab data.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"main_workflow.connect(infosource, 'subject_id', datasource, 'subject_id')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, the :class:`ephypype.nodes.Reference` interface is encapsulated in a\nnode and connected to the datasource node.\nWe set the channel names of sEEG data and refmethod equal to 'bipolar' in\norder to apply a bipolar montage to the depth electrodes.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"reference_node = pe.Node(interface=Reference(), name='rereference')\nreference_node.inputs.channels = channels_name\nreference_node.inputs.ft_path = ft_path\nreference_node.inputs.refmethod = refmethod\nreference_node.inputs.script = ''\n\n# Then we connect the output of datasource node to the input of reference_node\nmain_workflow.connect(datasource, 'raw_file', reference_node, 'data_file')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The output of the reference_node will be a FieldTrip data structure\ncontaining the sEEG data in bipolar montage. Now we create and connect\ntwo new nodes (import_epochs, compute_tfr_morlet) that convert the FieldTrip\ndata in MNE format and compute time-frequency representation of the\ndata using |Morlet_wavelets| rispectively.\n\n.. |Morlet_wavelets| raw:: html\n\n