# NumPy: Exercises and Solutions

## Activity in the left vs right brain

### Exercise

- Read this dataset, which has been adapted from the StudyForrest project. It is an
`.npy`

file, which you can read with`np.load()`

. - This will give you a 4D array with the following dimensions: left-to-right, back-to-front, bottom-to-top, time (1 sample per 2 s). Values in the array correspond to BOLD values (an indirect measure of brain activity).
- First, inspect the shape of the array to see how big each dimension is.
- Next, print out the average BOLD value separately for the left and the right side of the brain!

### Solution

```
import numpy as np
a = np.load('data/fmri-data.npy')
print(a.shape)
m_left = a[:34].mean()
m_right= a[34:].mean()
print('M(left) = {:.2f}'.format(m_left))
print('M(right) = {:.2f}'.format(m_right))
```

**Output:**

```
(68, 84, 58, 90)
M(left) = 117.86
M(right) = 117.74
```