Skip to main content

mariepy

Electromagnetic simulation of MRI transmit coils and virtual observation points for SAR, ported from MARIE 3.0.

Tests codecov PyPI License: GPL v3+

Install

pip install mariepy

Usage

Build a coil and a body, and solve them together at the Larmor frequency of the field strength you name. Both are built in code here. A case laid out as MARIE lays it out — a simulation file in data/inputs/, its body in data/bodies/, its coil in data/coils/coil_files/ — is read whole:

from mariepy.inputs import read_case

case = read_case("data/inputs/my_case.json")
result = solve(
    case.body, case.coil, case.medium, linear=case.linear, shield=case.shield
)

VoxelBody.read_marie, SurfaceMesh.read_gmsh22 and read_lumped_elements read each file on its own.

from mariepy.body import VoxelBody
from mariepy.coil import Port, SurfaceCoil
from mariepy.constants import Medium
from mariepy.mesh import SurfaceMesh
from mariepy.solver import solve

medium = Medium(3.0)  # 1H at 3 T
body = VoxelBody.sphere(0.07, 0.005, 52.0, 0.55, padding=2)
coil = SurfaceCoil.build(
    SurfaceMesh.loop(radius=0.12, width=0.01, n_around=48, n_across=2),
    (Port(tag=1, kind="port", load="none", value=0.0, quality=1.0, voltage=1.0),),
)

result = solve(body, coil, medium)

result.impedance, result.admittance and result.scattering are the port matrices; result.fields.electric and result.fields.magnetic are each port's field over the body grid, shaped (n_ports, 3, n1, n2, n3). From there:

from mariepy.fields import absorbed_power, circular_components

watts = absorbed_power(result.operator, result.fields)
b1_plus, b1_minus = circular_components(result.operator, result.fields)

A wire coil, WireCoil.read_gmsh22 or WireCoil.loop, goes to solve in the same place, and so does a CombinedCoil of a wire coil and a surface coil; a simulation file naming a WireFile, with or without a CoilFile, reads into one of them.

linear=True gives the body the piecewise-linear basis, twelve unknowns per voxel, which carries the field's variation inside each voxel; the fields then come back as those coefficients, and fields.at_centres gives their values at the voxel centres.

The solve runs on either device: build the body and the coil with device="cuda" and everything downstream follows.

Tuning, matching and calibration

A coil's lumped elements are closed by co-simulation, as MARIE does it. Solve the coil with its tunable elements opened into ports ("TMD": 1 in the simulation file), then search their values, the matching networks' and the decoupling, and calibrate the fields to the wave driving each matched port:

from mariepy.cosim import calibrate, co_simulate

closed = co_simulate(case.network, result.admittance, case.medium.angular_frequency)
electric = calibrate(result.fields.electric, closed.transmit)

With "TMD": 0 the file's values are placed as they are. closed.transmit has a column per transmitting port and closed.receive one per receiving port, as the element file assigns Tx, Rx and TxRx; closed.scattering is the transmitting ports' reflection and coupling; cosim.sweep gives the matched ports across a band.

Field bases, SNR and figures

A body's field basis is built once from a support surface around it (basis.surface_basis) or from a shell of currents around it (basis.dipole_basis), and any coil near that support is then solved through it:

from mariepy import basis, metrics, plot
from mariepy.solver import assemble_coil

incident = basis.surface_basis(case.body, case.basis_support, case.medium)
solved = basis.solve(incident, case.body, case.medium)
system = assemble_coil(case.coil, case.medium)
reduced = basis.solve_coil(case.coil, system, solved, case.body, case.medium)
ultimate_snr, ultimate_efficiency = basis.ultimate_maps(solved, case.body, case.medium)

metrics.noise_covariance, metrics.snr, metrics.transmit_efficiency and metrics.g_factor map a coil's performance from its fields; plot.geometry, plot.coil_currents, plot.scattering, plot.sweep and plot.slices draw the model and the maps.

Head models, body coils, arrays and field maps

A segmentation that gives each voxel the fraction every tissue fills is averaged onto the solver's grid and mixed into a body; a body coil enters as the modes of an infinitely long birdcage; an array is a set of loops, one port each; and each coil's circular field components are written for a simulator:

import math
from mariepy import fields, incident, maps, tissue
from mariepy.solver import solve, solve_incident
from mariepy.wire import WireCoil

head = tissue.mix(tissue.coarsen(fractions, 5), table, medium, 5e-3)
modes = [incident.birdcage(head.body, medium, angle=a) for a in (0.0, math.pi / 2)]
body_coil = solve_incident(
    head.body,
    medium,
    torch.stack([e for e, _ in modes]),
    torch.stack([h for _, h in modes]),
)
array = solve(head.body, WireCoil.loops(centres, normals, 0.04, 36), medium)
open_ports = fields.combine(array.fields, array.impedance)  # 1 A each, the rest open
plus, minus = fields.circular_components(medium, open_ports)

examples/brainweb.py does this for BrainWeb's normal brain in a body coil and three head arrays, and writes each coil's maps with maps.write and the transmit coils' VOPs with vop.write.

Command line

mariepy solve my_case.json --data marie-tools/data --out ports.npz
mariepy vops my_case.json --data marie-tools/data --labels labels.npy \
    --table tissue.csv --out vops.npz --safety-factor 1.5 --safety-basis "..."
mariepy vops --sphere --out vops.npz --safety-factor 1 --safety-basis "demo"

solve prints the port solve, reciprocity, power balance, co-simulation and B1+ and SNR summaries, and --out keeps the admittance and scattering matrices. vops writes the file vop.read reads; without --labels and --table the case's own tissue properties are used with --density. The file carries --safety-factor, which every local SAR read from it is multiplied by, with --safety-basis stating what it covers, and optionally --transmit, the transmit configuration it is valid for. examples/tissue_gabriel.csv shows the table's columns.

Development

See CONTRIBUTING.md.

Licence

Copyright (C) 2026 Matteo Cencini. mariepy is free software under the GNU General Public License, version 3 or any later version; see LICENSE. Code it carries from other projects, and their notices, are listed in THIRD_PARTY.md.

The licence covers the program. The files it writes, such as VOP files and field maps, are the user's and carry whatever terms their body models impose (see PLAN.md), so projects under any licence can read them.

Metadata

Release files for mariepy 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mariepy 0.0.1
File Size Uploaded Provenance Actions
mariepy-0.0.1.tar.gz 438.9 kB With provenance Details for mariepy-0.0.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mariepy 0.0.1
File Actions
mariepy-0.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details for mariepy-0.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
mariepy-0.0.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for mariepy-0.0.1-cp314-cp314-macosx_11_0_arm64.whl
mariepy-0.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details for mariepy-0.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
mariepy-0.0.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for mariepy-0.0.1-cp313-cp313-macosx_11_0_arm64.whl
mariepy-0.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details for mariepy-0.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
mariepy-0.0.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for mariepy-0.0.1-cp312-cp312-macosx_11_0_arm64.whl
mariepy-0.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details for mariepy-0.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
mariepy-0.0.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for mariepy-0.0.1-cp311-cp311-macosx_11_0_arm64.whl
mariepy-0.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details for mariepy-0.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
mariepy-0.0.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for mariepy-0.0.1-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 6.0 MB

Release files / mariepy-0.0.1.tar.gz

Download URL mariepy-0.0.1.tar.gz
Size 438.9 kB
Tags Source
SHA-256 checksum
How to use checksums
19f82037a1eadb40c7fde8436122eda3babdf9e76197f2089142cae4de83ca50
BLAKE2b-256 checksum
How to use checksums
0ba77b3bb03fbf457df188fe4aa7a44172af620b550cdc7a1be44d04d21b0a1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL mariepy-0.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 635.8 kB
Tags CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7d498d2ca26c3519e32f8b902bb35f6a4d4cabc39fbe49f9adbfe73d140c19cd
BLAKE2b-256 checksum
How to use checksums
7c7ba5ed9c0f5f436f40fbc2e143fffb7ca941dedca2b0dcd3fe0b7e9c1f029f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL mariepy-0.0.1-cp314-cp314-macosx_11_0_arm64.whl
Size 470.4 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2f59fdb627aacb0c7f91dde76197780657a31fba84f9e6151b2a899a644cf06a
BLAKE2b-256 checksum
How to use checksums
ac5baa48b2f0af28a4308f40093e4d0444c0568137b01f30c11fe9c354b87e92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL mariepy-0.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 635.6 kB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b2f74ca6490fce6516fc215f22298e853a6df87b1f2bc15bdd742593c3248454
BLAKE2b-256 checksum
How to use checksums
5d73056fe4fb42f768735dfe793cae1bf09af8fda277a93c515f5010d6cc46ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL mariepy-0.0.1-cp313-cp313-macosx_11_0_arm64.whl
Size 470.2 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9b843324d16fb6396e22cc11bf8123a317395f1fc8e9fb6efaeca36891f7427f
BLAKE2b-256 checksum
How to use checksums
94ce88a89dbd1fd39b14ef8c0c5af98383bbbb129e3bd67e9a7ff500f04232f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL mariepy-0.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 635.5 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a7ace9c40ee03232568bd727bd849b75c5736dba1fcdc70df1f224857aba1479
BLAKE2b-256 checksum
How to use checksums
6150483d346bafa8503ab914b4d80acbbd831a1975b859f117f1015e68b9027b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL mariepy-0.0.1-cp312-cp312-macosx_11_0_arm64.whl
Size 470.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
01982c0691a0a83d5a2f89d67f0b57a675badc73c8238b905996783ade71c24a
BLAKE2b-256 checksum
How to use checksums
2b1840c195bd0c5d0248375ffb5f165330c7de1284483639196506cf81923890
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL mariepy-0.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 637.1 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
65750ee50ce7bece346c55b424870fef6111a1f5d2751909883c98f84059a180
BLAKE2b-256 checksum
How to use checksums
a3f235d62228b4b76db2ae6ab8308cfe7b3636096227a127ff9ebaba70ce0a5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL mariepy-0.0.1-cp311-cp311-macosx_11_0_arm64.whl
Size 466.1 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8195b393faacbaa8cdb245b102ab47ccd5d19fcea8ab0b053ce16b4211cfecde
BLAKE2b-256 checksum
How to use checksums
b2785e1fbbb2af7da37af7533d9cd9a5aa69f7791f3a6162746d3cf2657bd496
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL mariepy-0.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 632.5 kB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9972299b41442db00e1e6f0d699a817be4acfef1009ef052838e7755a667fbe9
BLAKE2b-256 checksum
How to use checksums
faa5d8727fa6ffb98b0c0d90671d48edac773bf821ba01315c53962263effb8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / mariepy-0.0.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL mariepy-0.0.1-cp310-cp310-macosx_11_0_arm64.whl
Size 463.8 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8e0ef882dbf9b7b2a2c711afb85bf7a966500437ad121b750ae31c5cfcd3a14d
BLAKE2b-256 checksum
How to use checksums
544029daa783632978d833176b43775dc7a8fd8182747d469ef37fa124676437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for mariepy 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 11 files in this release have been uploaded with provenance metadata.

Select from 11 files

Attestation for mariepy-0.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

11 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page