Skip to content

[ENH] spm-runtime dependency #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
26 changes: 14 additions & 12 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ on:
workflow_dispatch:
workflow_call:
push:
paths:
paths:
- tests/**
- spm/**
- setup.py
- setup.py
- pyproject.toml
pull_request:

env:
MLM_LICENSE_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN }}

jobs:
run-unit-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: False
matrix:
matlab: ["latest"]
matlab: ["R2025a"]
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
include:
Expand All @@ -41,14 +41,16 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Check out SPM Python
uses: actions/checkout@v4

- name: Install SPM Python
run: python -m pip install -e .

# Setup MATLAB and Runtime
run: |
python -m pip install mpython-core
python -m pip install -e .

# Setup MATLAB and Runtime
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
Expand All @@ -73,7 +75,7 @@ jobs:
# sometimes this step hangs when closing matlab, automatically terminating after 2 minutes solves the issue
timeout-minutes: 2
continue-on-error: true

- name: Set environment variable with MATLAB path
shell: bash # Works on Windows as well because of shell: bash
run: |
Expand All @@ -90,7 +92,7 @@ jobs:
${{ env.MATLAB_PATH }}/extern/bin/maca64"
export PYTHONHOME=${{ env.pythonLocation }}
mwpython -m unittest discover tests -v

- name: Run tests (Mac Intel)
if: matrix.os_name == 'macOS_Intel'
run: |
Expand All @@ -101,7 +103,7 @@ jobs:
${{ env.MATLAB_PATH }}/extern/bin/maci64"
export PYTHONHOME=${{ env.pythonLocation }}
mwpython -m unittest discover tests -v

- name: Run tests (Windows)
if: matrix.os_name == 'Windows'
shell: bash
Expand Down
5 changes: 3 additions & 2 deletions .mpython/templates/class_header.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from mpython import Runtime, MatlabClass
from mpython import MatlabClass
from spm._runtime import Runtime, RuntimeMixin


class <classname>(MatlabClass):
class <classname>(RuntimeMixin, MatlabClass):
def __init__(self, *args, **kwargs):
<docstring>
super().__init__()
1 change: 1 addition & 0 deletions .mpython/templates/function_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from spm._runtime import Runtime
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include README.md
include LICENSE
include AUTHORS.txt
recursive-include spm/_spm *.ctf
39 changes: 28 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,52 @@ description = "Python bindings for the SPM software."
readme = "README.md"
license = {file = "LICENSE"}
authors = [
{name = "Johan Medrano", email = "johan.medrano@ucl.ac.uk"},
{name = "Yael Balbastre", email = "y.balbastre@ucl.ac.yk"},
{name = "Johan Medrano", email = "johan.medrano@ucl.ac.uk"},
{name = "Yael Balbastre", email = "y.balbastre@ucl.ac.uk"},
{name = "Yulia Bezsudnova"},
{name = "Arthur Mitchell"},
{name = "Peter Zeidman"},
{name = "Olivia Kowalczyk"} ]
requires-python = ">=3.9,<3.13"
{name = "Arthur Mitchell"},
{name = "Peter Zeidman"},
{name = "Olivia Kowalczyk"},
]
requires-python = ">=3.6,<3.13"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"numpy",
"mpython-core<=25.4a3"
"mpython-core>=25.4rc1",
"spm-runtime-r2025a == 25.1.1 ; python_version >= '3.9'",
"spm-runtime-r2023a == 25.1.1 ; python_version == '3.8'",
"spm-runtime-r2021b == 25.1.1 ; python_version == '3.7'",
"spm-runtime-r2020b == 25.1.1 ; python_version == '3.6'",
]

[project.optional-dependencies]
latest = ["spm-runtime == 25.1.1"]
R2025a = ["spm-runtime-R2025a == 25.1.1"]
R2024b = ["spm-runtime-R2024b == 25.1.1"]
R2024a = ["spm-runtime-R2024a == 25.1.1"]
R2023b = ["spm-runtime-R2023b == 25.1.1"]
R2023a = ["spm-runtime-R2023a == 25.1.1"]
R2022b = ["spm-runtime-R2022b == 25.1.1"]
R2022a = ["spm-runtime-R2022a == 25.1.1"]
R2021b = ["spm-runtime-R2021b == 25.1.1"]
R2021a = ["spm-runtime-R2021a == 25.1.1"]
R2020b = ["spm-runtime-R2020b == 25.1.1"]

[project.urls]
Repository = "https://github.com/spm/spm-python"

[tool.setuptools.packages]
find = {}

[tool.setuptools.package-data]
spm = ["_spm/_spm.ctf"]

[tool.setuptools.dynamic]
version = {attr = "spm._version.__version__"}

Expand Down
2 changes: 1 addition & 1 deletion spm/__compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
"spm_read_hdr",
"spm_resss",
"spm_spm_ui",
"spm_tbx_config2cfg",
"spm_tbx_config2cfg"
]
48 changes: 24 additions & 24 deletions spm/__compat/loadxml.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
from mpython import Runtime
from spm._runtime import Runtime


def loadxml(*args, **kwargs):
"""
LOADXML Load workspace variables from disk (XML file).
LOADXML FILENAME retrieves all variables from a file given a full
pathname or a MATLABPATH relative partial pathname (see PARTIALPATH).
If FILENAME has no extension LOAD looks for FILENAME and FILENAME.xml
and treats it as an XML file.

LOAD, by itself, uses the XML file named 'matlab.xml'. It is an error
if 'matlab.xml' is not found.

LOAD FILENAME X loads only X.
LOAD FILENAME X Y Z ... loads just the specified variables. The
wildcard '*' loads variables that match a pattern.
Requested variables from FILENAME are created in the workspace.

S = LOAD(...) returns the contents of FILENAME in variable S. S is
a struct containing fields matching the variables retrieved.

Use the functional form of LOAD, such as LOAD('filename'), when the
file name is stored in a string, when an output argument is requested,
or if FILENAME contains spaces.

See also LOAD, XML2MAT, XMLTREE.

LOADXML Load workspace variables from disk (XML file).
LOADXML FILENAME retrieves all variables from a file given a full
pathname or a MATLABPATH relative partial pathname (see PARTIALPATH).
If FILENAME has no extension LOAD looks for FILENAME and FILENAME.xml
and treats it as an XML file.
LOAD, by itself, uses the XML file named 'matlab.xml'. It is an error
if 'matlab.xml' is not found.
LOAD FILENAME X loads only X.
LOAD FILENAME X Y Z ... loads just the specified variables. The
wildcard '*' loads variables that match a pattern.
Requested variables from FILENAME are created in the workspace.
S = LOAD(...) returns the contents of FILENAME in variable S. S is
a struct containing fields matching the variables retrieved.
Use the functional form of LOAD, such as LOAD('filename'), when the
file name is stored in a string, when an output argument is requested,
or if FILENAME contains spaces.
See also LOAD, XML2MAT, XMLTREE.

[Matlab code]( https://github.com/spm/spm/blob/main/compat/loadxml.m )

Expand Down
40 changes: 20 additions & 20 deletions spm/__compat/savexml.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
from mpython import Runtime
from spm._runtime import Runtime


def savexml(*args, **kwargs):
"""
SAVEXML Save workspace variables to disk in XML.
SAVEXML FILENAME saves all workspace variables to the XML-file
named FILENAME.xml. The data may be retrieved with LOADXML. if
FILENAME has no extension, .xml is assumed.

SAVE, by itself, creates the XML-file named 'matlab.xml'. It is
an error if 'matlab.xml' is not writable.

SAVE FILENAME X saves only X.
SAVE FILENAME X Y Z saves X, Y, and Z. The wildcard '*' can be
used to save only those variables that match a pattern.

SAVE ... -APPEND adds the variables to an existing file.

Use the functional form of SAVE, such as SAVE(filename','var1','var2'),
when the filename or variable names are stored in strings.

See also SAVE, MAT2XML, XMLTREE.

SAVEXML Save workspace variables to disk in XML.
SAVEXML FILENAME saves all workspace variables to the XML-file
named FILENAME.xml. The data may be retrieved with LOADXML. if
FILENAME has no extension, .xml is assumed.
SAVE, by itself, creates the XML-file named 'matlab.xml'. It is
an error if 'matlab.xml' is not writable.
SAVE FILENAME X saves only X.
SAVE FILENAME X Y Z saves X, Y, and Z. The wildcard '*' can be
used to save only those variables that match a pattern.
SAVE ... -APPEND adds the variables to an existing file.
Use the functional form of SAVE, such as SAVE(filename','var1','var2'),
when the filename or variable names are stored in strings.
See also SAVE, MAT2XML, XMLTREE.

[Matlab code]( https://github.com/spm/spm/blob/main/compat/savexml.m )

Expand Down
40 changes: 20 additions & 20 deletions spm/__compat/spm_add.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
from mpython import Runtime
from spm._runtime import Runtime


def spm_add(*args, **kwargs):
"""
Add a series of images - a compiled routine
FORMAT s = spm_add(VI,VO)
VI - Vector of mapped volumes (from spm_map or spm_vol).
VO - Description of output volume that gets passed to
spm_write_plane.m
flags - Flags can be:
'm' - masks the mean to zero or NaN wherever
a zero occurs in the input images.
s - Scalefactor for output image.
__________________________________________________________________________

spm_add computes a sum of a set of image volumes to produce an
integral image that is written to a named file (VI.fname).

A mean can be effected by modifying the scalefactors (and offsets) of
VI (see spm_mean_ui for an example). A weighted sum can be effected by
using different weightings for image scalefactors.
__________________________________________________________________________

Add a series of images - a compiled routine
FORMAT s = spm_add(VI,VO)
VI - Vector of mapped volumes (from spm_map or spm_vol).
VO - Description of output volume that gets passed to
spm_write_plane.m
flags - Flags can be:
'm' - masks the mean to zero or NaN wherever
a zero occurs in the input images.
s - Scalefactor for output image.
__________________________________________________________________________
spm_add computes a sum of a set of image volumes to produce an
integral image that is written to a named file (VI.fname).
A mean can be effected by modifying the scalefactors (and offsets) of
VI (see spm_mean_ui for an example). A weighted sum can be effected by
using different weightings for image scalefactors.
__________________________________________________________________________

[Matlab code]( https://github.com/spm/spm/blob/main/compat/spm_add.m )

Expand Down
Loading