Skip to content

Instantly share code, notes, and snippets.

@cosacog
cosacog / process_fwave.R
Created February 24, 2023 11:41
Process Fwave recorded by Neuropack
#%% function
load_raw <- function(fname_raw){
samp_time <- 0.05 # ms
line_ini <-0;line_end <-0
linesRaw <- readLines(fname_raw)
for (ii in seq(1, length(linesRaw))){
if (length(grep(pattern='"1-1"', linesRaw[ii]))>0){
line_ini <- ii
}
if (length(grep(pattern="Wave End", linesRaw[ii]))>0){
@cosacog
cosacog / 0readme.md
Last active January 28, 2022 13:46
Allocate nurses daily for a week

window_allocate_nurse.py

これは何

  • 1週間の勤務を振り分けするスクリプトです
  • 3つ(*.pyのファイル)分かれてますが、window_allocate_nurse.pyがメインのスクリプトです

必要な環境

  • python: anacondaがよいでしょう。
@cosacog
cosacog / type_key_sequence.py
Last active January 23, 2019 10:44
psychopyでキータイプの配列を練習します。説明は下の方です。
from __future__ import absolute_import, division
from psychopy import locale_setup, sound, gui, visual, core, data, event, logging, clock
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED,
STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)
import numpy as np # whole numpy lib is available, prepend 'np.'
from numpy import (sin, cos, tan, log, log10, pi, average,
sqrt, std, deg2rad, rad2deg, linspace, asarray)
from numpy.random import random, randint, normal, shuffle
import os # handy system and path functions
import sys # to get file system encoding
@cosacog
cosacog / load_raw_n_remontage.py
Last active January 31, 2019 08:22
load raw and remontage EEG channels。要mne python。説明は下の方にあります。
import mne
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
'''
EEG
21: Th1, 22: lt iliac crest, 23: rt. iliac crest
24.25: lt abductor hallucis, 26.27: rt abductor hallucis
61: lt.apb, 62: rt.apb
@cosacog
cosacog / SurfaceEmg2powspctrm.py
Last active March 28, 2019 11:32
EDFを読み込んでbipolar montageのpowerspctrumを計算. 説明は下にあります。
import mne, os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
class SurfaceEmg:
def __init__(self, path_edf, path_ch_pairs, sec_window=5.0, minute_analysis=3):
# load edf
self._raw = mne.io.read_raw_edf(path_edf, preload=True)
# load channel pairs
@cosacog
cosacog / HemifieldFlashAndTms.py
Last active December 10, 2018 15:25
Psychopyでflash + TMSトリガーを出すスクリプト。説明は下の方にあります。
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
This experiment was created using PsychoPy2 Experiment Builder (v1.83.04), 2017_06_14_1638
If you publish work using this script please cite the relevant PsychoPy publications
Peirce, JW (2007) PsychoPy - Psychophysics software in Python. Journal of Neuroscience Methods, 162(1-2), 8-13.
Peirce, JW (2009) Generating stimuli for neuroscience using PsychoPy. Frontiers in Neuroinformatics, 2:10. doi: 10.3389/neuro.11.010.2008
"""
@cosacog
cosacog / CheckerboardPatternOnPsychopy.md
Last active April 5, 2023 19:21
display checkerboard pattern on psychopy

Checkerboard pattern display on psychopy

最初に

  • 説明は一番下に置いてます.
  • 通常は.psyexpファイルだけあればよいです.
  • ダウンロードは右上の"Download zip"からダウンロードして解凍してください.

ファイルの種類

1. 普通はこれがあればおk(Builder用 .psyexpファイル)

  • gratings_15min.psyexp: 15分
  • gratings_30min.psyexp: 30分
@cosacog
cosacog / img_processing_for_visual_experiment.py
Last active December 10, 2018 11:38
Simple image processing: adjust mean level, gamma 説明は下の方にあります。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw, ImageFilter, ImageOps, ImageStat
import numpy as np
import matplotlib.pyplot as plt
class ImageProcForVisualExperiment():
def __init__(self, path_img=None):
self.path_img = path_img
@cosacog
cosacog / btn_lt.png
Last active March 5, 2018 03:47
line bisection task using psychopy. refer to Fierro et al. (2000) PMID: 10841369、ダウンロードする時は右上のダウンロードボタンからお願いします。
btn_lt.png
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# import iroiro
from __future__ import division # so that 1/3=0.333 instead of 1/3=0
from psychopy import locale_setup, visual, core, data, event, logging, sound, gui, parallel
from psychopy.constants import * # things like STARTED, FINISHED
import numpy as np # whole numpy lib is available, prepend 'np.'
import os # handy system and path functions
import sys # to get file system encoding