You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> 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)!**
21
21
22
+
## Installation instructions
22
23
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
- 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
34
93
35
94
## Minimal example
36
95
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:
40
99
```Matlab
41
100
spm('defaults', 'eeg');
42
101
```
43
-
In Python:
102
+
In Python:
44
103
```Python
45
104
from spm import *
46
105
spm('defaults', 'eeg')
47
106
```
48
107
49
108
### 2. Constructing objects
50
-
In Matlab:
109
+
In Matlab:
51
110
```Matlab
52
111
S = [];
53
112
S.data = 'OPM_meg_001.cMEG';
@@ -57,22 +116,22 @@ D = spm_opm_create(S);
57
116
In Python, create a `Struct()` instead of a `struct`:
58
117
```Python
59
118
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'
62
121
D = spm_opm_create(S)
63
122
```
64
123
Here, `D` will be a `meeg` object which contains a virtual representation of the Matlab object. Class methods should work as expected, e.g.:
65
124
```Python
66
125
D.fullfile()
67
126
>>>'./OPM_meg_001.mat'
68
127
```
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.
70
129
71
130
### 3. Creating and handling figures
72
-
In Matlab:
131
+
In Matlab:
73
132
```Matlab
74
133
S = [];
75
-
S.triallength = 3000;
134
+
S.triallength = 3000;
76
135
S.plot = 1;
77
136
S.D = D;
78
137
S.channels = 'MEG';
@@ -94,7 +153,7 @@ This opens a Matlab figure, but we do not have the possibility of manipulating i
94
153
In Matlab:
95
154
```Matlab
96
155
S = [];
97
-
S.triallength = 3000;
156
+
S.triallength = 3000;
98
157
S.plot = 1;
99
158
S.D = mD;
100
159
[~,freq] = spm_opm_psd(S);
@@ -103,17 +162,17 @@ In Python, the number of output arguments must be specified by the `nargout` key
0 commit comments