Skip to content

Commit 332d2ca

Browse files
committed
[enh] regenerate code with external mpython package
1 parent fb17e45 commit 332d2ca

File tree

3,993 files changed

+8129
-7313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,993 files changed

+8129
-7313
lines changed

.mpython/templates/setup.py

-28
This file was deleted.

examples/DCM_fMRI_Attention.ipynb

+21-23
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
"from spm import * \n",
1111
"\n",
1212
"import numpy as np\n",
13-
"import os.path as op\n",
14-
"import os \n",
15-
"import scipy.io as sio"
13+
"import os.path as op"
1614
]
1715
},
1816
{
@@ -120,9 +118,9 @@
120118
"source": [
121119
"DCM = Struct() \n",
122120
"\n",
123-
"xY1 = Runtime.call('load', op.join(data_path,'GLM','VOI_V1_1.mat'))['xY'];\n",
124-
"xY2 = Runtime.call('load', op.join(data_path,'GLM','VOI_V5_1.mat'))['xY'];\n",
125-
"xY3 = Runtime.call('load', op.join(data_path,'GLM','VOI_SPC_1.mat'))['xY'];\n",
121+
"xY1 = Runtime.call('load', op.join(data_path,'GLM','VOI_V1_1.mat'))['xY']\n",
122+
"xY2 = Runtime.call('load', op.join(data_path,'GLM','VOI_V5_1.mat'))['xY']\n",
123+
"xY3 = Runtime.call('load', op.join(data_path,'GLM','VOI_SPC_1.mat'))['xY']\n",
126124
"\n",
127125
"DCM.xY = StructArray(xY1, xY2, xY3)"
128126
]
@@ -134,7 +132,7 @@
134132
"metadata": {},
135133
"outputs": [],
136134
"source": [
137-
"DCM.n = 3; \n",
135+
"DCM.n = 3 \n",
138136
"DCM.v = xY1['u'].shape[0]; "
139137
]
140138
},
@@ -165,8 +163,8 @@
165163
"outputs": [],
166164
"source": [
167165
"DCM.Y = Struct()\n",
168-
"DCM.Y.dt = SPM.xY.RT;\n",
169-
"DCM.Y.X0 = xY1.X0;\n",
166+
"DCM.Y.dt = SPM.xY.RT\n",
167+
"DCM.Y.X0 = xY1.X0\n",
170168
"\n",
171169
"DCM.Y.y = np.concatenate([xY.u for xY in (xY1, xY2, xY3)], axis=1)\n",
172170
"DCM.Y.name = [xY.name for xY in (xY1, xY2, xY3)]\n",
@@ -198,8 +196,8 @@
198196
"outputs": [],
199197
"source": [
200198
"DCM.U = Struct()\n",
201-
"DCM.U.dt = SPM.Sess.U[0].dt;\n",
202-
"DCM.U.name = [u.name for u in SPM.Sess.U];\n",
199+
"DCM.U.dt = SPM.Sess.U[0].dt\n",
200+
"DCM.U.name = [u.name for u in SPM.Sess.U]\n",
203201
"DCM.U.u = np.concatenate([\n",
204202
" u.u[32:] for u in SPM.Sess.U\n",
205203
" ], axis=1);"
@@ -230,13 +228,13 @@
230228
"metadata": {},
231229
"outputs": [],
232230
"source": [
233-
"DCM.delays = np.repeat([[SPM['xY']['RT']/2]], DCM.n, 1);\n",
234-
"DCM.TE = 0.04;\n",
231+
"DCM.delays = np.repeat([[SPM['xY']['RT']/2]], DCM.n, 1)\n",
232+
"DCM.TE = 0.04\n",
235233
"\n",
236234
"DCM.options = Struct()\n",
237-
"DCM.options.nonlinear = 0;\n",
238-
"DCM.options.two_state = 0;\n",
239-
"DCM.options.stochastic = 0;\n",
235+
"DCM.options.nonlinear = 0\n",
236+
"DCM.options.two_state = 0\n",
237+
"DCM.options.stochastic = 0\n",
240238
"DCM.options.nograph = 1;"
241239
]
242240
},
@@ -265,11 +263,11 @@
265263
"outputs": [],
266264
"source": [
267265
"DCM.a = np.array([[1, 1, 0], [1, 1, 1], [0, 1, 1]])\n",
268-
"DCM.b = np.zeros((3,3,3)); \n",
269-
"DCM.b[1,0,1] = 1; \n",
270-
"DCM.b[1,2,2] = 1;\n",
266+
"DCM.b = np.zeros((3,3,3)) \n",
267+
"DCM.b[1,0,1] = 1 \n",
268+
"DCM.b[1,2,2] = 1\n",
271269
"DCM.c = np.array([[1, 0, 0], [0, 0, 0], [0, 0, 0]])\n",
272-
"DCM.d = np.zeros((3,3,0));\n",
270+
"DCM.d = np.zeros((3,3,0))\n",
273271
"\n",
274272
"DCMbwd = spm_dcm_estimate(DCM)"
275273
]
@@ -295,9 +293,9 @@
295293
"metadata": {},
296294
"outputs": [],
297295
"source": [
298-
"DCM.b = np.zeros((3,3,3)); \n",
299-
"DCM.b[1,0,1] = 1; \n",
300-
"DCM.b[1,0,2] = 1;\n",
296+
"DCM.b = np.zeros((3,3,3)) \n",
297+
"DCM.b[1,0,1] = 1 \n",
298+
"DCM.b[1,0,2] = 1\n",
301299
"\n",
302300
"DCMfwd = spm_dcm_estimate(DCM)"
303301
]

examples/DEM_demo_Maze.ipynb

+18-18
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959
"metadata": {},
6060
"outputs": [],
6161
"source": [
62-
"a = .9;\n",
63-
"A1 = np.array([[.5, .5], [.5, .5], [0, 0], [0, 0]]);\n",
64-
"A2 = np.array([[0, 0], [0, 0], [a, (1 - a)], [(1 - a), a]]);\n",
65-
"A3 = np.array([[0, 0], [0, 0], [(1 - a), a], [a, (1 - a)]]);\n",
66-
"A4 = np.array([[1, 0], [0, 1], [0, 0], [0, 0]]);\n",
62+
"a = .9\n",
63+
"A1 = np.array([[.5, .5], [.5, .5], [0, 0], [0, 0]])\n",
64+
"A2 = np.array([[0, 0], [0, 0], [a, (1 - a)], [(1 - a), a]])\n",
65+
"A3 = np.array([[0, 0], [0, 0], [(1 - a), a], [a, (1 - a)]])\n",
66+
"A4 = np.array([[1, 0], [0, 1], [0, 0], [0, 0]])\n",
6767
"A = block_diag(A1, A2, A3, A4);"
6868
]
6969
},
@@ -94,10 +94,10 @@
9494
"B = [[]]*4\n",
9595
"i = 0\n",
9696
"for i, _ in enumerate(B):\n",
97-
" B[i] = np.zeros((4,4));\n",
98-
" B[i][1:3, 1:3] = np.eye(2);\n",
99-
" B[i][i,[0, 3]] = 1;\n",
100-
" B[i] = np.kron(B[i],np.eye(2));"
97+
" B[i] = np.zeros((4,4))\n",
98+
" B[i][1:3, 1:3] = np.eye(2)\n",
99+
" B[i][i,[0, 3]] = 1\n",
100+
" B[i] = np.kron(B[i],np.eye(2))"
101101
]
102102
},
103103
{
@@ -178,16 +178,16 @@
178178
"source": [
179179
"MDP = Struct()\n",
180180
"\n",
181-
"MDP.N = 8; # number of variational iterations\n",
182-
"MDP.S = S; # true initial state\n",
183-
"MDP.A = A; # observation model\n",
184-
"MDP.B = B; # transition probabilities (priors)\n",
185-
"MDP.C = C; # terminal cost probabilities (priors)\n",
186-
"MDP.D = D; # initial state probabilities (priors)\n",
187-
"MDP.V = V; # allowable policies\n",
181+
"MDP.N = 8 # number of variational iterations\n",
182+
"MDP.S = S # true initial state\n",
183+
"MDP.A = A # observation model\n",
184+
"MDP.B = B # transition probabilities (priors)\n",
185+
"MDP.C = C # terminal cost probabilities (priors)\n",
186+
"MDP.D = D # initial state probabilities (priors)\n",
187+
"MDP.V = V # allowable policies\n",
188188
"\n",
189-
"MDP.alpha = 64; # gamma hyperparameter\n",
190-
"MDP.beta = 4; # gamma hyperparameter\n",
189+
"MDP.alpha = 64 # gamma hyperparameter\n",
190+
"MDP.beta = 4 # gamma hyperparameter\n",
191191
"MDP['lambda'] = 0.25 # precision update rate"
192192
]
193193
},

examples/SourceLevelEvokedResponse.ipynb

+44-44
Original file line numberDiff line numberDiff line change
@@ -85,48 +85,48 @@
8585
"source": [
8686
"#- read data \n",
8787
"#--------------------------------------------------------------------------\n",
88-
"S = Struct();\n",
89-
"S.data = op.join(datapath, 'OPM_meg_001.cMEG');\n",
90-
"S.positions = op.join(datapath, 'OPM_HelmConfig.tsv');\n",
91-
"D = spm_opm_create(S);\n",
88+
"S = Struct()\n",
89+
"S.data = op.join(datapath, 'OPM_meg_001.cMEG')\n",
90+
"S.positions = op.join(datapath, 'OPM_HelmConfig.tsv')\n",
91+
"D = spm_opm_create(S)\n",
9292
"\n",
9393
"#- highpass\n",
9494
"#--------------------------------------------------------------------------\n",
95-
"S = Struct();\n",
96-
"S.D = D;\n",
97-
"S.freq = 10;\n",
98-
"S.band = 'high';\n",
99-
"fD = spm_eeg_ffilter(S);\n",
100-
"fr = S.freq;\n",
95+
"S = Struct()\n",
96+
"S.D = D\n",
97+
"S.freq = 10\n",
98+
"S.band = 'high'\n",
99+
"fD = spm_eeg_ffilter(S)\n",
100+
"fr = S.freq\n",
101101
"\n",
102102
"#- lowpass\n",
103103
"#--------------------------------------------------------------------------\n",
104-
"S = Struct();\n",
105-
"S.D = fD;\n",
106-
"S.freq = 70;\n",
107-
"S.band = 'low';\n",
108-
"fD = spm_eeg_ffilter(S);\n",
104+
"S = Struct()\n",
105+
"S.D = fD\n",
106+
"S.freq = 70\n",
107+
"S.band = 'low'\n",
108+
"fD = spm_eeg_ffilter(S)\n",
109109
"\n",
110110
"#- adaptive multipole models\n",
111111
"#--------------------------------------------------------------------------\n",
112-
"S = Struct();\n",
113-
"S.D = fD;\n",
114-
"S.corrLim = .98;\n",
115-
"mD = spm_opm_amm(S);\n",
112+
"S = Struct()\n",
113+
"S.D = fD\n",
114+
"S.corrLim = .98\n",
115+
"mD = spm_opm_amm(S)\n",
116116
"\n",
117117
"#- epoch \n",
118118
"#--------------------------------------------------------------------------\n",
119-
"S = Struct();\n",
120-
"S.D = mD;\n",
121-
"S.timewin = np.array([-50, 200]);\n",
122-
"S.triggerChannels = {'Trigger 6 Z'};\n",
123-
"eD = spm_opm_epoch_trigger(S);\n",
119+
"S = Struct()\n",
120+
"S.D = mD\n",
121+
"S.timewin = np.array([-50, 200])\n",
122+
"S.triggerChannels = {'Trigger 6 Z'}\n",
123+
"eD = spm_opm_epoch_trigger(S)\n",
124124
"\n",
125125
"#- baseline correction \n",
126126
"#--------------------------------------------------------------------------\n",
127-
"S = Struct();\n",
128-
"S.D = eD;\n",
129-
"S.timewin = np.array([-50, 0]);\n",
127+
"S = Struct()\n",
128+
"S.D = eD\n",
129+
"S.timewin = np.array([-50, 0])\n",
130130
"eD = spm_eeg_bc(S);"
131131
]
132132
},
@@ -171,9 +171,9 @@
171171
"metadata": {},
172172
"outputs": [],
173173
"source": [
174-
"S = Struct();\n",
175-
"S.D = eD;\n",
176-
"S.headfile = op.join(datapath, 'head.obj');\n",
174+
"S = Struct()\n",
175+
"S.D = eD\n",
176+
"S.headfile = op.join(datapath, 'head.obj')\n",
177177
"\n",
178178
"S.helmetref = np.array(\n",
179179
" [[0,133.9,-24], \n",
@@ -220,10 +220,10 @@
220220
"metadata": {},
221221
"outputs": [],
222222
"source": [
223-
"S = Struct();\n",
224-
"S.dir = datapath;\n",
225-
"S.D = eD.fullfile();\n",
226-
"S.space = 'Head';\n",
223+
"S = Struct()\n",
224+
"S.dir = datapath\n",
225+
"S.D = eD.fullfile()\n",
226+
"S.space = 'Head'\n",
227227
"BF = bf_wizard_data(S);"
228228
]
229229
},
@@ -248,10 +248,10 @@
248248
"metadata": {},
249249
"outputs": [],
250250
"source": [
251-
"S = Struct();\n",
252-
"S.BF = BF;\n",
253-
"S.method = 'grid';\n",
254-
"S.grid = Struct(resolution=5);\n",
251+
"S = Struct()\n",
252+
"S.BF = BF\n",
253+
"S.method = 'grid'\n",
254+
"S.grid = Struct(resolution=5)\n",
255255
"BF = bf_wizard_sources(S);"
256256
]
257257
},
@@ -299,9 +299,9 @@
299299
"outputs": [],
300300
"source": [
301301
"S = Struct()\n",
302-
"S.BF = BF;\n",
303-
"S.method = 'minimumnorm';\n",
304-
"S.minimumnorm = dict(snr=10^2);\n",
302+
"S.BF = BF\n",
303+
"S.method = 'minimumnorm'\n",
304+
"S.minimumnorm = dict(snr=10^2)\n",
305305
"BF = bf_wizard_inverse(S);"
306306
]
307307
},
@@ -327,9 +327,9 @@
327327
"outputs": [],
328328
"source": [
329329
"S = Struct()\n",
330-
"S.BF = BF;\n",
331-
"S.act = 90;\n",
332-
"S.base = 1;\n",
330+
"S.BF = BF\n",
331+
"S.act = 90\n",
332+
"S.base = 1\n",
333333
"bf_stat_evoked_t(S, nargout=0);"
334334
]
335335
},

scripts/setup_matlab.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os.path as op
33
import platform
44
import subprocess
5-
import sys
65
import urllib.request
76
import zipfile
87
from itertools import product
@@ -170,7 +169,7 @@ def setup_matlab_environment(download):
170169
runtime_installed = download_and_install_matlab_runtime()
171170

172171
if not runtime_installed:
173-
raise SystemError(f'Failed to install Matlab Runtime. Please try manually.')
172+
raise SystemError('Failed to install Matlab Runtime. Please try manually.')
174173

175174
runtime_found = add_matlab_to_path('R2024b')
176175

spm/__compat/__init__.py

+23
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,26 @@
1919
from .spm_spm_ui import spm_spm_ui
2020
from .spm_tbx_config2cfg import spm_tbx_config2cfg
2121

22+
23+
__all__ = [
24+
"loadxml",
25+
"savexml",
26+
"spm_add",
27+
"spm_adjmean_fmri_ui",
28+
"spm_adjmean_ui",
29+
"spm_atranspa",
30+
"spm_chi2_plot",
31+
"spm_digamma",
32+
"spm_dirichlet",
33+
"spm_eeval",
34+
"spm_fMRI_design_show",
35+
"spm_imcalc_ui",
36+
"spm_load_float",
37+
"spm_matlab_version_chk",
38+
"spm_mean",
39+
"spm_mean_ui",
40+
"spm_read_hdr",
41+
"spm_resss",
42+
"spm_spm_ui",
43+
"spm_tbx_config2cfg"
44+
]

spm/__compat/loadxml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from spm.__wrapper__ import Runtime
1+
from mpython import Runtime
22

33

44
def loadxml(*args, **kwargs):

spm/__compat/savexml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from spm.__wrapper__ import Runtime
1+
from mpython import Runtime
22

33

44
def savexml(*args, **kwargs):

spm/__compat/spm_add.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from spm.__wrapper__ import Runtime
1+
from mpython import Runtime
22

33

44
def spm_add(*args, **kwargs):

0 commit comments

Comments
 (0)