たれぱんのびぼーろく

わたしの備忘録、生物学とプログラミングが多いかも

光でネズミの脳を支配し、強制的に走らせる

概要

我々は脳で感じ、考え、運動の指令を出している。
もし運動の指令を出す脳部位がわかったとする。その部位を外部から活性化すれば、運動を強制できるのではないか。
ネズミを用いた実験でこれが実証された。

動画

動画ここクリック、必見
論文:
Identification of a Brainstem Circuit Regulating Visual Cortical State in Parallel with Locomotion.
Neuron. 2014. A. Moses Lee, et al..

背景

  • 脳の分業制と部位特異性
  • 運動に関する部位
  • 光遺伝学

ブレイン・マシン・インターフェース、フルダイブ技術との関係

脳信号の読み取り

中脳歩行誘発野(MLR)が活動すれば、歩行が起きる.
では、MLRの活動を読み取れば、歩行の予測が可能なのではないか.

プログラムを改修する

思いつきでガリガリ書いていたプログラムが、案外いい感じになり、リファクタリングしたくなった.
保守という概念を覚える前に書いたコードを、保守出来るようにしたい.
こんなとき、どうすりゃいいのだろう.

リファクタリング

コードの保守・機能追加をするために、コードを綺麗()にすること.
プログラムの振る舞いを変えずに、内部を書き換えること.
そのためには、プログラムの振る舞いが明確でなければならない.

プログラムの振る舞いを明確にする

プログラムの振る舞い = 入力に対する出力.
内部状態を持ってることもある.

書き直す

スパゲッティすぎて書き直した方が速いんでない?もありうる.

じゃあまずなにすりゃいいの

プログラムの振る舞いを定義すること.

脳インプラント論文

Review articles

多機能・柔軟な脳インプラント

Multifunctional soft implants to monitor and control neural activity in the central and peripheral nervous system: A review
Z. Feketea, b, , , A. Pongrácza, b
Sensors and Actuators B: Chemical, 2017.

素材科学・微細加工の発達により、様々な脳インプラントが開発されている.
その例を取り上げ、近年の発展ポイントをまとめている総説.
・今回初めて知ったこと

  • 電極基盤に微細流路加工を行い、電極記録と化学刺激を同時に実現するデバイスが存在する

10.1016/j.snb.2016.12.096

法人と実在と税金のメモ

www.google.co.jp

https://ja.m.wikipedia.org/wiki/法人本質論

会社の分類

  • 株式会社: 資本家から出資してもらった金を、経営者が使う
  • 持分会社: 自分達でお金を持ち寄って、使う

株式会社と持分会社は、所有と経営の分離に基づいて分類されてるんでないかな? たぶん.
でも、株式会社のベンチャー起業は、経営者が株主だし、従業員にストックオプションあげたりで、必ずしも分離してるわけでもないよね.

合同会社の名前由来

simplea.hatenablog.com

会社数の種別推移

面白そうだから、暇な時に作ろう

http://www.会社設立.cc/archives/188

d3.js Events version 4

d3.js version 4における、Eventの使い方・原理まとめ.

イベントリスナ

DOM living standardにおける、addEventListener()にselection.on()が対応する.

.on(typenames[, listener[, capture]])

typenames = click[.optionalName][ otherEvent]
typenameの後に、".potionalName"の形で名前を付けられる.
単一typenameイベントに対し、複数のイベントリスナをつける場合、違う名前で登録する(click.foo, click.bar)
また、同時に複数のtypenameに対しイベントリスナを付加できる。"click drag"みたいな形で、空白を入れて登録.

listenerの引数
listener(d, i, nodes)
thisはcurrent_DOM_element

being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element.

Eventはなんと、listenerへ明示的には渡されない!!
d3.Eventオブジェクトを介してアクセスする(なんとなく気持ち悪い)
d3.Eventは、eventListenerが動いている間、届いたDOMEventになっている。listenerが終了すると、リセットされる.

To access the current event within a listener, use d3.event.
...
This is set during the invocation of an event listener, and is reset after the listener terminates.

github.com

Drag

Dragビヘイビアはオブジェクトであり、関数でもある. d3.drag()がコンストラクタ.
drag(selection)またはselection.call(drag)で特定の要素へ結び付けられる.

The returned behavior, drag, is both an object and a function, and is typically applied to selected elements via selection.call. d3.js API reference

drag.on(typename[,listener])

The type must be one of the following:

  • start - after a new pointer becomes active (on mousedown or touchstart).
  • drag - after an active pointer moves (on mousemove or touchmove).
  • end - after an active pointer becomes inactive (on mouseup, touchend or touchcancel).

the current datum d and index i, with the this context as the current DOM element.

たぶん(精査してないけど)d3.dispatchを利用した、自作Eventがdragの正体.
dragがEventで、drag.onがsekection.onに相当しているはず.
referenceにもそれっぽいこと書いてあったから、暇があったら精査.
あと, 自作イベントの必要性も要精査.

配列から特定の要素を取り除く ―ver. ES2016―

配列から特定の要素を乗り除く (例. [a, b, X, d] -> [a, b, d]) 方法を複数紹介する。

一覧

  • Array.filter (ES2016)
  • Array.indexOf + Array.splice

詳細

Array.filter (ES2016)

EcmaScript2016で新登場した、Array.filterメソッドを利用する方法.

// ary配列から3を除去する.
let ary = [1,2,3,4,5];
let filtered = ary.filter((element) => element!==3);
console.log(filtered) // [1,2,4,5]

filterメソッドは関数を引数に取る.
関数は配列の要素を引数にとり、trueまたはfalseを返す関数.
trueを返した要素のみによる配列をfilterメソッドは返す.

例では、

function (element){
  return (element!==3)
}
// の省略表記である
(element) => element!==3

をfilterメソッドの引数に渡した.
elemnt!==3 は、elementが3ではないときにtrueと評価されるため、3がfilterで除かれた.

ポイント1: filterメソッドは元の配列を変化させないよ

filter は呼び出された配列を変化させません。MDN

ポイント2: 要素がオブジェクトでも、うまいことfilterできるよ

let ary = [ {name:Panda, year:20}, {name:Usagi, year:30}, {name:Gorira, year:40} ]  //オブジェクトの配列
let filtered = ary.filter((obj) => obj.year < 40);
console.log(filtered); // [ {name:Panda, year:20}, {name:Usagi, year:30} ] 年寄りゴリラが弾かれた

filterの引数が関数であるため、柔軟性がすごい.
filterメソッドでうまくfilterできないことはないんじゃないかな?

Array.indexOf + Array.splice

ES2016がなくても動く、昔ながらのやり口.
数年したら、不要なやり方になると思う、filterほど柔軟でもないし(完全一致を求められる).

Array.indexOf(): 引数と一致する要素が何番目か(index)を教えてくれる
Array.splice(): 配列をほどいて繋ぎなおす(スプライス)する関数. 除去する要素のindexを指定し、そこを除いて残りをつなぎなおす

まとめ

Array.prototype.filterを積極的に使おう!

d3.js version 4

モジュール

  1. Arrays (Statistics, Search, Transformations, Histograms)
  2. Axes
  3. Brushes
  4. Chords
  5. Collections (Objects, Maps, Sets, Nests)
  6. Colors
  7. Dispatches
  8. Dragging
  9. Delimiter-Separated Values
  10. Easings
  11. Forces
  12. Number Formats
  13. Geographies (Paths, Projections, Spherical Math, Spherical Shapes, Streams, Transforms)
  14. Hierarchies
  15. Interpolators
  16. Paths
  17. Polygons
  18. Quadtrees
  19. Queues
  20. Random Numbers
  21. Requests
  22. Scales (Continuous, Sequential, Quantize, Ordinal)
  23. Selections (Selecting, Modifying, Data, Events, Control, Local Variables, Namespaces)
  24. Shapes (Arcs, Pies, Lines, Areas, Curves, Symbols, Stacks)
  25. Time Formats
  26. Time Intervals
  27. Timers
  28. Transitions
  29. Voronoi Diagrams
  30. Zooming

メイン

ちょっと特殊用途

3 ✓, エリア選択
4 ✓, chord circular layout
9 ✓, TSV, CSV等のparseおよびstringify
13 ✓, Geographic projections, shapes and math.
14 ✓, 階層構造
17 ✓, かなり簡潔なmodule, polygonの判定系関数
18 ✓, 四分木、いまいちよくわかってない
19 ✓, 非同期 (defered, await)
20 ✓, 乱数 (一様分布, 正規分布etc)
21 ✓, XHRとTSV, CSVファイルの読み込み
24 ✓, SVGではちょっと面倒な、でもprimitiveな図形
29 ✓, ボロノイ図

source.xが便利そうだけど、どうやってんだろうね
Force-Directed Graph - bl.ocks.org

Interested in the next major release of D3, which is planned for summer 2016? See the source repository and read the new API Reference. Show your support for D3’s ongoing development by buying official stickers!

D3.js - Data-Driven Documents

The master branch currently contains the prerelease of D3 4.0. The 4.0 API is not yet frozen and may change prior to the release.

d3/README.md at master · d3/d3 · GitHub

v4 API reference

github.com