Skip to content

Commit 9f3fb8b

Browse files
committed
[DOC] up-to-date installation instructions
1 parent d40d98a commit 9f3fb8b

File tree

1 file changed

+84
-25
lines changed

1 file changed

+84
-25
lines changed

README.md

Lines changed: 84 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
```
22
___ ____ __ __
3-
/ __)( _ \( \/ )
3+
/ __)( _ \( \/ )
44
\__ \ )___/ ) ( Statistical Parametric Mapping
55
(___/(__) (_/\/\_) SPM - https://www.fil.ion.ucl.ac.uk/spm/
66
```
@@ -15,22 +15,81 @@ Copyright (C) 1991,1994-2025 Wellcome Centre for Human Neuroimaging
1515
![PyPI - Version](https://img.shields.io/pypi/v/spm-python)
1616
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/spm/spm-python/.github%2Fworkflows%2Frun_unit_tests.yml)
1717

18-
1918
> [!WARNING]
20-
> This project is **currently under construction** and might contain bugs. **If you experience any issues, please [let us know](https://github.com/spm/spm-python/issues)!**
19+
> This project is **young** and might contain bugs.
20+
> **If you experience any issues, please [let us know](https://github.com/spm/spm-python/issues)!**
2121
22+
## Installation instructions
2223

23-
## Installation instructions:
24-
0. Install Python and Pip. Python installation made from Microsoft Store on Windows will not work (raises DeclarativeService.dll not found), install it from Python website.
25-
> [!WARNING]
26-
> spm-python currently requires Python 3.12.
24+
### Important - Windows
25+
26+
Python installation made from Microsoft Store on Windows will not work
27+
(raises DeclarativeService.dll not found), install it from Python website.
28+
29+
### Important - Python/MATLAB compatibility
30+
31+
Specific versions of MATLAB are compatible with
32+
[specific versions of Python](https://uk.mathworks.com/support/requirements/python-compatibility.html).
33+
34+
By default, spm-python uses:
35+
- Python 3.6: R2020b
36+
- Python 3.7: R2021b
37+
- Python 3.8: R2023a
38+
- Python 3.9-3.12: R2025a
39+
- Python 3.13: Unsupported
40+
41+
### Option 1 - Install the MATLAB runtime on first use
2742

28-
1. Install [Matlab Runtime 2024b](https://uk.mathworks.com/products/compiler/matlab-runtime.html)
43+
1. Install SPM-Python
44+
```shell
45+
pip install spm-python
46+
```
47+
2. Run spm
48+
```shell
49+
spm
50+
```
51+
3. Follow the instructions
52+
53+
- **Advantages**
54+
- Installs the runtime that is required for your python version
55+
- Does not resintall anything if a compatible runtime already exists
56+
- **Drawbacks**
57+
- May need to be run in proviledged mode (e.g., `sudo`)
58+
- May be fiddly on Windows
59+
60+
### Option 2 - Install the MATLAB runtime manually
61+
62+
1. Install the appropriate [MATLAB Runtime](https://uk.mathworks.com/products/compiler/matlab-runtime.html)
2963
2. Install SPM:
3064
```python
3165
pip install spm-python
3266
```
33-
3. That's all!
67+
68+
- **Advantages**
69+
- Graphical interface for installing the runtime
70+
- **Drawbacks**
71+
- The correct runtime must be selected for your python version
72+
73+
### Option 3 - Install the MATLAB runtime using an installation script
74+
75+
1. Install SPM-Python
76+
```shell
77+
pip install spm-python
78+
```
79+
2. Run the installer
80+
```shell
81+
install_matlab_runtime --version R2025a --yes
82+
```
83+
84+
- **Advantages**
85+
- Exposes installation options (`install_matlab_runtime --help`)
86+
- Allows any runtime version to be installed. One may do:
87+
```shell
88+
pip install spm-python[R2023b]
89+
install_matlab_runtime --version R2023b
90+
```
91+
- **Drawbacks**
92+
- For advanced users
3493

3594
## Minimal example
3695
Here is a minimal set of examples showcasing changes to do to use existing Matlab code in Python (taken from the [OPM tutorial](https://www.fil.ion.ucl.ac.uk/spm/docs/tutorials/opm/evoked/)).
@@ -40,14 +99,14 @@ In Matlab:
4099
```Matlab
41100
spm('defaults', 'eeg');
42101
```
43-
In Python:
102+
In Python:
44103
```Python
45104
from spm import *
46105
spm('defaults', 'eeg')
47106
```
48107

49108
### 2. Constructing objects
50-
In Matlab:
109+
In Matlab:
51110
```Matlab
52111
S = [];
53112
S.data = 'OPM_meg_001.cMEG';
@@ -57,22 +116,22 @@ D = spm_opm_create(S);
57116
In Python, create a `Struct()` instead of a `struct`:
58117
```Python
59118
S = Struct()
60-
S.data='OPM_meg_001.cMEG'
61-
S.positions='OPM_HelmConfig.tsv'
119+
S.data = 'OPM_meg_001.cMEG'
120+
S.positions = 'OPM_HelmConfig.tsv'
62121
D = spm_opm_create(S)
63122
```
64123
Here, `D` will be a `meeg` object which contains a virtual representation of the Matlab object. Class methods should work as expected, e.g.:
65124
```Python
66125
D.fullfile()
67126
>>> './OPM_meg_001.mat'
68127
```
69-
Note that the alternative call that exist in Matlab (i.e., `fullfile(D)`) will not work.
128+
Note that the alternative call that exist in Matlab (i.e., `fullfile(D)`) will not work.
70129

71130
### 3. Creating and handling figures
72-
In Matlab:
131+
In Matlab:
73132
```Matlab
74133
S = [];
75-
S.triallength = 3000;
134+
S.triallength = 3000;
76135
S.plot = 1;
77136
S.D = D;
78137
S.channels = 'MEG';
@@ -94,7 +153,7 @@ This opens a Matlab figure, but we do not have the possibility of manipulating i
94153
In Matlab:
95154
```Matlab
96155
S = [];
97-
S.triallength = 3000;
156+
S.triallength = 3000;
98157
S.plot = 1;
99158
S.D = mD;
100159
[~,freq] = spm_opm_psd(S);
@@ -103,17 +162,17 @@ In Python, the number of output arguments must be specified by the `nargout` key
103162
```Python
104163
S = Struct()
105164
S.triallength = 3000
106-
S.plot=1
107-
S.D=mD
165+
S.plot = 1
166+
S.D = mD
108167
[_,freq] = spm_opm_psd(S, nargout=2)
109168
```
110169

111-
### 5. Other examples
170+
### 5. Other examples
112171
In Matlab:
113-
```Matlab
114-
S=[];
115-
S.D=D;
116-
S.freq=[10];
172+
```Matlab
173+
S = [];
174+
S.D = D;
175+
S.freq = [10];
117176
S.band = 'high';
118177
fD = spm_eeg_ffilter(S);
119178
@@ -123,7 +182,7 @@ S.freq = [70];
123182
S.band = 'low';
124183
fD = spm_eeg_ffilter(S);
125184
```
126-
In Python:
185+
In Python:
127186
```Python
128187
S = Struct()
129188
S.D = D

0 commit comments

Comments
 (0)