This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# この中で実際に使うのは | |
# 1. マウスクリックなどで決めたトリガーを基に取り出す | |
# detect_emg_onset_1ch_by_stim_ch(raw, ch_emg, stim_channel, event_id) | |
# 2. 視察で筋電図から大まかにピークを取り出して、次に再度各区間で立ち上がり時刻を正確に決める | |
# detect_emg_onset_1ch_vis_inspect(raw, ch_emg) | |
# 3. 閾値で筋電図からピークを検出して、次に再度各区間で立ち上がり時刻を正確に決める | |
# detect_emg_onset_1ch_by_thr(raw, ch_emg, win_mv) # e.g. win_mv=0.3 | |
# のどれかです. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# function設定(componentの任意の条件(neutral/centerとか)とcomponentの番号から | |
# mapとevoked(componentから作成)のプロット | |
def plot_comp_map_and_evoked(comps, cnd, idx_comp, is_peak_need): | |
""" | |
component (icaの)を各条件、component番号で加算平均波形をプロットする。 | |
comps: icaで出てくるcomponentのデータ. e.g.comps=ica.get_sources(epochs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# _*_ coding: utf-8 -*- | |
def make_movie_circle_plot(con,n_seed_label,labels, times, con_method, vmin, vmax): | |
""" | |
mne pythonで作ったcon(connectivity)のデータから時系列でfigureを作る | |
# all-to-allかseed basedのデータにするか | |
#n_seed_label = 9 # number or None: e.g. labels[9].name=entorhinal-rh | |
#n_seed_label = None | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 下準備(環境変数の設定) | |
export SUBJECTS_DIR=/data_wo_matometa_drive/MRI_wo_matomeru_directory #"/"を最後つけない | |
export SUBJECT=hikenja_no_namae #ここの最後に"/"をつけない | |
export DICOM_DIR=/dicom_no_aru_directory # 例:/net/raid0/mnt/share/hikenja/dicom | |
# 以下基本変更なし | |
# データを入れるディレクトリをまとめて作る(mriとかT1とかbemとかsurfとかorigとか) | |
mksubjdirs $SUBJECTS_DIR/$SUBJECT # freesurferのコマンド |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
def filter_raw_list(list_fname, bp_freq): | |
u""" | |
filter raw files. save file name with "l_freq"_"h_freq".fif | |
Arguments | |
list_fname: list of raw.fif | |
bp_freq: band pass frequency. e.g (0,40) | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ## データ読み込み | |
# setwd('C:/directory/to/xlsx/file') | |
# rrdata_pre<-read.table('before.txt',sep='/t',header=F) | |
# rrdata_pst<-read.table('after.txt',sep='/t',header=F) | |
# time_onset <- sum(rrdata_pre)/1000 # ここで前後を区切る | |
# doPlot<-TRUE | |
# names(rrdata_pre) <- names(rrdata_pst) <- 'Time' | |
# rrdata <- rbind(rrdata_pre,rrdata_pst) | |
## define function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def half_ydir_label(label_orig): | |
''' | |
要mne等 | |
labelをy軸方向に半分にするスクリプト | |
params: label_orig. 元のlabel | |
return: label_half. y軸方向に半分になったlabel | |
''' | |
ypos_label = label_orig.pos[:,1] | |
idx_half_label = np.where(ypos_label >= np.median(ypos_label)) # example: y positions are anterior |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DetectOnset <- function(data, intvl_thr){ | |
# dataからオンセットを取り出す | |
# params: | |
# data: 1chのデータ | |
# intvl_thr: これ以下の間隔の時は1つながりのトリガーとする | |
thr <- (median(data) + max(data))*0.5 | |
bin_data <- data > thr | |
bin_onset <- which((tail(bin_data,-1) == 1) & (head(bin_data,-1) == 0)) + 1 | |
bin_ofset <- which((tail(bin_data,-1) == 0) & (head(bin_data,-1) == 1)) | |
# exclude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from psychopy import visual, core, event, parallel | |
import numpy as np | |
import cv2 | |
# define | |
K_ESC = 27 | |
K_ARROW_UP = 2490368 # arrow up | |
K_ARROW_DOWN = 2621440 # arrow down | |
K_RIGHT = 114 # "r" | |
K_LEFT = 108 # "l" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
## settings | |
prt_num = int('00001111',2) # port number(digit number) indicates port 8,7,6,5,4,3,2,1 | |
t_range = [5, 7] # time range for TMS (sec) | |
t_init_wait = 3 # time for start TMS (sec) | |
n_rep_tms = 12 # TMS repetition frequency (times) | |
p_prt_address = '0xCFF8' |
OlderNewer