Manual jp

From NeuroTychoWiki
Revision as of 16:52, 28 February 2011 by Aihara (talk | contribs) (Created page with "=Windows環境におけるpythonでの解析環境の構築マニュアル = 注意:このマニュアルに書いてあるソフトウェアをインストールする際には...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Windows環境におけるpythonでの解析環境の構築マニュアル

注意:このマニュアルに書いてあるソフトウェアをインストールする際には、パソコンの管理者権限が必要です。また、windowsに関しては32bit版を想定しております。

Python

  1. http://www.python.org/download/releases/2.6.6/から、Pythonのバージョン2.6.6の"Windows x86 MSI Installer"をダウンロード
    1. 0805d491734b39856b5c8e178c9de66e.png
  2. インストーラーを起動
    1. C926e6405ff303a6c80625204a5b7a9f.png アイコンをダブルクリックしてインストーラを起動
  3. インストーラープログラムを以下の手順で進める
    1. 特に指定が無い画面については、"Next"ボタンを押して先に進めてください。
    2. 743ee27846ed5bd129ed67a12d3bf5de.png "Install for all users"を選択して、"Next"ボタンを押す
    3. 94be0d2c7a90dc5450c1581903b6e2fe.png 画面に書かれているものから変更せずにそのまま"Next"ボタンを押す
    4. File:Data/050998d9a57e931e46c2c70119982d27.png "Next"ボタンを押してインストールを開始する

Numpy

NumPy is a open-source numerical computation module for Python.

  1. Download "numpy-1.5.1-win32-superpack-python2.6.exe" from http://sourceforge.net/projects/numpy/files/NumPy/1.5.1/.
    1. File:d9f9e4c26024b18dc4b21b099e7f900d.png]]
  2. Run the installer.
    1. 347aa09541427e1dcfb7935f86d5c897.png Double click this icon to start installer.
  3. Step through the installer program.
    1. Except as otherwise noted, click "Next" to bring forward Installation.
    2. 5df43fd3c06be4c91191e64e21ec4999.png Choice "Python Version 2.6" and click "Next".

Scipy

Scipy is a open-source python module for mathematics, science, and engineering.

  1. Download "scipy-0.8.0-win32-superpack-python2.6.exe" from http://sourceforge.net/projects/scipy/files/scipy/0.8.0/.
    1. B5e1b8069c20d716069c8a3eb221b87a.png
  2. Run the installer.
    1. 55c0bcade8ab3d8a2c51dd08854a2576.png Double click this icon to start installer.
  3. Step through the installer plogram.
    1. Except as otherwise noted, click "Next" to bring forward Installation.
    2. A2ee9ebb15add7638912245704e55878.png Choice "Python Version 2.6" and click "Next".

Matplotlib

Matplotlib is a plotting library for the Python.

  1. Visit the official page of matplotlib at http://matplotlib.sourceforge.net/.
  2. Click on the download link.
    1. http://gyazo.argmax.jp/data/88d00ceb483579b5c45915a42ad2dbcf.png
  3. Download "matplotlib-1.0.1.win32-py2.6.exe".
    1. B3ac9b2154bafd5809b68f8cdf0ac429.png
  4. Run the installer.
    1. Dea1f1d5e133c39cd9a52559bb8207ab.png Double click this icon to start installer.
  5. Step through the installer program.
    1. Except as otherwise noted, click "Next" to bring forward Installation.
    2. Cd94b01550095502721ca4acc5747f28.png Choice "Python Version 2.6" and click "Next".

Sample code for analyzing neurotycho data in python

Notice the we assume "C:/neurotycho" as download directory. If You have download neurotycho datasets elsewhere, adapt the pathes below.

plotting

#!/usr/bin/python
#-*- coding: utf-8 -*-
import numpy as np
import scipy.io
import scipy
import matplotlib
import matplotlib.pyplot as plt

_indir = "C:/neurotycho/20100604_S1_ST_K2_ToruYanagawa_mat_ECoG128-Event3/"

def load_mat(path):
    """
    loading a matlab data using scipy.io
    """
    return scipy.io.loadmat(path)

if __name__=="__main__":
    mat = load_mat(_indir+"ECoG_ch1.mat")#loading ECoG data
    data = mat["ECoGData_ch1"][0]
    event = load_mat(_indir+"Event.mat")##loading event data
    eindex = event["EventIndex"][0]#EventIndex is one-row vector contains indexes when events were occurred in ECoG data.
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(data)#plotting ECoGdata
    ax.annotate('Inject anesthetic drug',
                xy=(eindex[0],data[eindex[0]]),
                xytext=(eindex[0]-170000,2000),
                arrowprops=dict(facecolor='black', shrink=0.1,),
                )
    plt.show()

result

Ca592b24adff54e62f5e2f7af236e919.png