Skip to content

Instantly share code, notes, and snippets.

View alexrockhill's full-sized avatar

Alex Rockhill alexrockhill

View GitHub Profile
@alexrockhill
alexrockhill / group_level_tfr_stc.py
Last active April 3, 2023 18:57
Plot group-level results using the time-frequency volume source estimate viewer
import os.path as op
import numpy as np
import mne
import mne_gui_addons
import autoreject
from mne.time_frequency import csd_tfr
fs_dir = mne.datasets.fetch_fsaverage(verbose=True)
subjects_dir = op.dirname(fs_dir)
@alexrockhill
alexrockhill / vector_stc.py
Last active March 14, 2024 18:27
Plot a vector time-frequency source time course
# -*- coding: utf-8 -*-
"""
.. _ex-inverse-dics-epochs:
=======================================================================
Compute source level time-frequency timecourses using a DICS beamformer
=======================================================================
In this example, a Dynamic Imaging of Coherent Sources (DICS)
:footcite:`GrossEtAl2001` beamformer is used to transform sensor-level
time-frequency objects to the source level. We will look at the event-related
synchronization (ERS) of beta band activity in the :ref:`somato dataset
@alexrockhill
alexrockhill / flat_map_brain.py
Created February 2, 2023 23:07
Pial surface, inflated brain, flat map video visualization
import os
import os.path as op
import numpy as np
import mne
import imageio
misc_path = mne.datasets.misc.data_path()
sample_path = mne.datasets.sample.data_path()
subjects_dir = sample_path / 'subjects'
subject = 'fsaverage'
@alexrockhill
alexrockhill / inflate_brain.py
Created January 31, 2023 17:46
Inflate a brain from the pial surface to visualize sEEG contacts
import os
import os.path as op
import numpy as np
import mne
import imageio
misc_path = mne.datasets.misc.data_path()
sample_path = mne.datasets.sample.data_path()
subjects_dir = misc_path / 'seeg'
subject = 'sample_seeg'
@alexrockhill
alexrockhill / tfr_stc_viewer.md
Created September 10, 2022 06:13
GSOC 2022 Time-Frequency Visualization Final Report

For my GSoC this year, I made a graphical user interface (GUI) to view estimates of the time-course of activity in the brain from non-invasive electroecephalography (EEG) and magnetoencephalography (MEG) recordings. Although, the main pull request (PR) is ready but hasn't yet been merged (mne-tools/mne-python#10920), I am very happy with the end result and will see it through to the finish in the very near future. Being my second GSoC, I took on a project that was more central to the function of the MNE-Python tool; viewing estimates of brain activity, than my previous GSoC, which dealt with the new extension of supporting intracranial electrophysiology. I hope this will be an upgrade in functionality that empowers many users because of its centrality to MNE-Python. I really tried to make the development very stable and a good example because of this importance as well and I'm really happy with that although there are more PRs left on that (below).

The first task I took on that was i

@alexrockhill
alexrockhill / report.md
Last active August 19, 2021 18:28
Google Summer of Code Alex Rockhill iEEG GUI Project Final Report

My GSoC project to make a graphical user interface (GUI) to locate the positions of electrical recording contacts inside a patient's head who has been implanted with intracranial electrodes was a huge success.

I started by developing the accompanying routines to prepare the input data and process the data once the GUI has been used first. This process is described here:

https://mne.tools/dev/auto_tutorials/clinical/10_ieeg_localize.html

The pull requests (PRs) that contributed to this development are here:

mne-tools/mne-python#9484 mne-tools/mne-python#9544

"""
.. _tut_working_with_ecog:
======================
Working with ECoG data
======================
MNE supports working with more than just MEG and EEG data. Here we show some
of the functions that can be used to facilitate working with
electrocorticography (ECoG) data.
@alexrockhill
alexrockhill / test_write.py
Last active November 7, 2019 21:12
mne_bids.write with convert
# -*- coding: utf-8 -*-
"""Test the MNE BIDS converter.
For each supported file format, implement a test.
"""
# Authors: Mainak Jas <mainak.jas@telecom-paristech.fr>
# Teon L Brooks <teon.brooks@gmail.com>
# Chris Holdgraf <choldgraf@berkeley.edu>
# Stefan Appelhoff <stefan.appelhoff@mailbox.org>
# Matt Sanderson <matt.sanderson@mq.edu.au>
@alexrockhill
alexrockhill / main.py
Created October 29, 2019 02:13
fbs PyQt5 unable to write file
from fbs_runtime.application_context.PyQt5 import ApplicationContext
from PyQt5.QtWidgets import (QMainWindow, QLabel, QPushButton,
QWidget, QStackedWidget)
import sys
import os
import os.path as op
class AppContext(ApplicationContext):
def run(self, path):
def write_anat(bids_root, subject, t1w, session=None, acquisition=None,
raw=None, trans=None, deface=False, overwrite=False,
verbose=False):
"""Put anatomical MRI data into a BIDS format.
Given a BIDS directory and a T1 weighted MRI scan for a certain subject,
format the MRI scan to be in BIDS format and put it into the correct
location in the bids_dir. If a transformation matrix is supplied, a
sidecar JSON file will be written for the T1 weighted data.