[PYTHON] Introduction of library PyPhi for dealing with integrated information theory (IIT)

Preface

I read the book "When will consciousness be born-Integrated information theory that challenges the mystery of the brain-" (https://www.amazon.co.jp/dp/B01GJOQSO2) and became interested in integrated information theory. I did.

・ It cannot be said that there is consciousness just because "there is an output for the input" is the same as whether it is a nerve cell or an and circuit. -In integrated information theory, consciousness (roughly speaking) refers to "the ability to integrate diverse information." ・ This "ability to integrate various information" is called Φ. The Φ of a certain tissue can be quantified by calculation.

something like.

Even if I read a book thinking that it might be interesting, the calculation method of Φ does not come out concretely.

I couldn't help it, so I searched on the net and found a library that can calculate the value of Φ with python.

Official page https://pyphi.readthedocs.io/en/latest/index.html

The calculation method of Φ is also written properly, which one .... ↓

https://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.1006343.s001&type=supplementary (All 227 pages !!!!) The calculation method is complicated and the amount is large, so it was quite difficult, so for the time being, I will summarize only the introduction method and the actual usage example.

The specific calculation method is in another article.

Introduction

pip install pyphi

We will introduce it at. However, this is written as a library made for ** maxOS and Linux **, and when I actually tried it on my windows, I got an error.

For windows, use the conda command.

conda install -c wmayner pyphi

You can now install it.

Also, if you use google Colaboratory, you can install it from pip.

!pip install pyphi

Example of use

First, consider the following directed graph. (The figure was output using networkx)

rapture_20200422164134.jpg

Expressed as an adjacency matrix

  \boldsymbol{CM} = \left(
    \begin{array}{ccc}
      0 & 1 & 1 \\
      1 & 0 & 1 \\
      1 & 1 & 0
    \end{array}
  \right) 

That's the form.

All three of these elements have either a 1 or 0 state.

Since each has two ways, there are a total of $ 2 ^ 3 = 8 $ ways. Let's line up.

A B C
0 0 0
1 0 0
0 1 0
1 1 0
0 0 1
1 0 1
0 1 1
1 1 1

Each element has an input and an output, and its state does not change due to other factors. Suppose that as a result of input / output from the state of $ t $ (left) to the elements connected to each other, the state changes as shown in the state of $ t + 1 $ (right).

t t+1
A B C A B C
0 0 0 0 0 0
1 0 0 0 0 1
0 1 0 1 0 1
1 1 0 1 0 0
0 0 1 1 0 0
1 0 1 1 1 1
0 1 1 1 0 1
1 1 1 1 1 0

Let's represent this table in the form of a matrix. However, the left side (state at $ t $) is standardized and can be omitted.

  \boldsymbol{TPM} = \left(
    \begin{array}{ccc}
      0 & 0 & 0 \\
      0 & 0 & 1 \\
      1 & 0 & 1 \\
      1 & 0 & 0 \\
      1 & 0 & 0 \\
      1 & 1 & 1 \\      
      1 & 0 & 1 \\
      1 & 1 & 0 \\
    \end{array}
  \right) 

This is called TPM (transition probability matrix). Since this value represents the "probability" of becoming 1, it is not limited to 1 or 0, but 0.9 or another value is actually entered. In that case, it means that "the point becomes 1 with a probability of 0.9".

Now let's create this network.

import pyphi
import numpy as np
tpm = np.array([
     [0, 0, 0],
     [0, 0, 1],
     [1, 0, 1],
     [1, 0, 0],
     [1, 0, 0],
     [1, 1, 1],
     [1, 0, 1],
     [1, 1, 0]
 ])
cm = np.array([
     [0, 1, 1],
     [1, 0, 1],
     [1, 1, 0]
 ])
labels = ('A', 'B', 'C')
#In this case cm can be omitted
network = pyphi.Network(tpm, cm=cm, node_labels=labels)
```

 In the created network, set the initial states of A, B, and C, which are the starting points for calculating Φ. In this case, use (1, 0, 0).

```python
state = (1, 0, 0)
```

 Determine the subsystem (small system, infrastructure?) To be calculated. This time we will take all the elements.

```python
node_indices = (0, 1, 2)
subsystem = pyphi.Subsystem(network, state, node_indices)
#This time this is also possible
# subsystem = pyphi.Subsystem(network, state)
```

 By playing with this initial state in various ways, the information integration ability of the target is measured.

 Now let's calculate the essential Φ.

```python
pyphi.compute.phi(subsystem)
# 1.916665
```

 It's done.

 The target of this calculation is the one of [Explanatory material of calculation method](https://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.1006343.s001&type=supplementary) posted earlier. However, the same calculation result is derived on page 220.

 I would like to summarize the specific calculation method in an article later, but if you want to see the detailed procedure, please read from the official.

## reference
 Giulio Tononi "When will consciousness be born? Integrated information theory that challenges the mystery of the brain" Aki Shobo

 PyPhi official documentation
https://pyphi.readthedocs.io/en/latest/index.html


Recommended Posts

Introduction of library PyPhi for dealing with integrated information theory (IIT)
Quantification of "consciousness" in integrated information theory (IIT3.0), calculation method of Φ
Basics of Quantum Information Theory: Entropy (2)
4th night of loop with for
Record of Python introduction for newcomers