Skip to content

Instantly share code, notes, and snippets.

View alexrockhill's full-sized avatar

Alex Rockhill alexrockhill

View GitHub Profile
@alexrockhill
alexrockhill / MEM
Last active August 1, 2018 02:34
Memory-Mapping Error Example
from mne import create_info
from mne.io import Raw,RawArray
import numpy as np
for i in range(100):
raw_info = create_info([str(i) for i in range(100)],25000,['eeg' for _ in range(100)])
raw = RawArray(np.ones((100,int(1e7))),raw_info)
raw.save('test%i-raw.fif' %(i))
raw = Raw('test0-raw.fif',preload='test_workfile')
@alexrockhill
alexrockhill / sample.bvct
Last active October 24, 2018 14:56
Sample BVCT
<?xml version="1.0"?>
<BrainVisionCapTrakFileV1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CapTrakFileVersion>1.10</CapTrakFileVersion>
<RecordingDateTime>2018.01.12 10:48:44</RecordingDateTime>
<CapSize>58</CapSize>
<HeadShapeName>Round</HeadShapeName>
<CapTrakElectrodeList>
<CapTrakElectrode>
<Name>LPA</Name>
<X>-83.887782650513117</X>
import inspect
import os.path as op
import shutil
import numpy as np
from numpy.testing import (assert_array_almost_equal, assert_array_equal,
assert_allclose, assert_equal)
import pytest
from mne.utils import _TempDir, run_tests_if_main
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.
@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):
@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>
"""
.. _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 / 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

@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 / 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'