履歴: ソフトウェア/Igor

各行は、その日時に書かれた内容です。追加・削除は、1 つ前の版との行数の差です (全 12 版)。「差分」は比較する版、「基準」は比べる相手の版を選びます

日時タイトル文字数追加削除内容差分基準
2013/3/10 21:14:35ソフトウェア/Igor 最新版602+1 -1表示差分—
2013/3/10 21:14:35ソフトウェア/Igor 608+0 -248表示差分選択
2013/3/9 3:47:03ソフトウェア/Igor 6,106+4 -2表示差分選択
2013/3/9 3:47:03ソフトウェア/Igor 6,066+125 -0表示差分選択
2013/3/7 14:39:26ソフトウェア/Igor 3,608+68 -0表示差分選択
2013/2/26 16:58:40ソフトウェア/Igor 1,615+7 -0表示差分選択
2013/2/23 6:12:01ソフトウェア/Igor 1,425+1 -1表示差分選択
2013/2/22 11:29:18ソフトウェア/Igor 1,432+22 -2表示差分選択
2013/2/22 8:21:49ソフトウェア/Igor 1,021+22 -89表示差分選択
2013/2/21 15:50:26ソフトウェア/Igor 2,733+18 -0表示中差分選択
2013/2/21 9:32:27ソフトウェア/Igor 2,162+80 -34表示差分選択
2013/2/21 4:15:48ソフトウェア/Igor 1,326— —表示—選択

2013/2/21 15:50:26 に書かれた内容

ソフトウェア/Igor


公開メモ

Igor とは†

データ解析に Wave Metrics 社の Igor Pro を使っています。

なかなか癖のあるソフトですが、 Igor 上でプログラムを組むことでかなり複雑なデータ解析も自動化できていろいろ捗ります。

ここには使い回しの効きそうなコード例を上げていこうと思います。

公式のオンラインヘルプはこちら: http://www.hulinks.co.jp/support/igor/programming/index.html

分野別記事へのリンク†

あるグラフ上に表示されたウェーブの一覧を表示する†

string graph_name = "Graph1"
string traces = TraceNameList(graph_name, ";", 1)
variable i
for(i = ItemsInList(traces) - 2; i>=0; i-=1)
    print StringFromList(i, traces)
endfor

画像の一覧なら、TraceNameList ではなく ImageNameList を呼べばいい。

string graph_name = "Graph1"
string images = ImageNameList(graph_name, ";", 1)
variable i
for(i = ItemsInList(images) - 2; i>=0; i-=1)
    print StringFromList(i, images)
endfor

グラフウィンドウ上の選択領域を得る†

グラフ上をマウスで斜めにドラッグすると矩形領域を選べますが、 この範囲を Igor では Marquee と呼んでいます。

使用例

// 与えられた座標がグラフの選択領域に含まれているかどうか返す
function IsPointInSelectedRegion(x, y)
variable x, y

    string graph_name = "Graph1"

    struct Rectangle selected_region
    GetMarqueeRegion(graph_name, selected_region)

    return IsPointInRect(x, y, selected_region)
end

コード

// 矩形領域を格納するための構造体
Structure Rectangle
    double left
    double right
    double top
    double bottom
EndStructure

// 指定された名前のグラフから選択範囲を得る
// 選択されていなければ全範囲 (left, bottom 軸で) を返す
function GetMarqueeRegion(graph_name, region)
string graph_name
Struct Rectangle &region

    GetMarquee/W=$graph_name left, bottom
    if(!V_Flag)
        GetAxis/q/W=$graph_name bottom
        V_Left   = V_min
        V_Right  = V_max
        GetAxis/q/W=$graph_name left
        V_Top    = V_min
        V_Bottom = V_max
    endif

    region.left = V_Left
    region.right = V_Right
    region.top = V_Top
    region.bottom = V_Bottom
end

// x, y で指定された点が rect 領域に入っているかどうかを返す 
function IsPointInRect(x, y, rect)
variable x, y
Struct Rectangle &rect
    variable result
    result = rect.left <= x
    result = x <= rect.right   && result
    result = rect.top <= y     && result
    result = y <= rect.bottom  && result
    return result
end

グラフ上の選択範囲を設定する†

SetMarquee を使えばいいのですが、単位をポイントに直さなければならないので、 PixelFromAxisVal と ScreenResolution を呼んで変換します。

コード

// 下軸、左軸の値を指定してグラフの選択範囲を設定する
function image_mouseup(x1, y1, x2, y2)
variable x1, y1, x2, y2
    x1 = PixelFromAxisVal("image", "bottom", x1) / ScreenResolution * 72
    x2 = PixelFromAxisVal("image", "bottom", x2) / ScreenResolution * 72
    y1 = PixelFromAxisVal("image", "left", y1) / ScreenResolution * 72
    y2 = PixelFromAxisVal("image", "left", y2) / ScreenResolution * 72
    SetMarquee/w=image, x1, y1, x2, y2
end