Spatial-Jitter Model for Magnetoencephalography Sensor Arrays.
4 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.
The 6 matches
- [1] § Methods › Realistic Geometry ↔ functions.py, lines 345 to 379 · score 0.67 · dense spherical sensor, inner product, VSH coefficients · block
oscr:b:M0N91DYK9JM4R-S· Report a mismatch - [2] § Methods › Realistic Geometry ↔ BEM_analysis_MeasCov.py, lines 112 to 181 · score 0.63 · source amplitudes, noise models, white noise, covariance, Simulations, sensor · block
oscr:b:H1FNEWQDDJ2VH-H· Report a mismatch - [3] § Methods › Spherical Conductor ↔ functions.py, lines 117 to 148 · score 0.62 · uniform distribution, half sphere, drawn, inside, radius · block
oscr:b:20D7PD2MZW52B-9· Report a mismatch - [4] § Methods › Spherical Conductor ↔ functions.py, lines 345 to 379 · score 0.61 · inner product, VSH coefficients, sensor positions, magnetic field, quadrature, sphere · block
oscr:b:M0N91DYK9JM4R-S· Report a mismatch - [5] § Results › Realistic Geometry ↔ BEM_analysis_MeasCov.py, lines 112 to 181 · score 0.60 · covariance model, source amplitude, noise model, simulation, SNR, sensor · block
oscr:b:H1FNEWQDDJ2VH-H· Report a mismatch - [6] § Methods › Spherical Conductor ↔ source_depth.py, lines 30 to 75 · score 0.54 · Lebedev quadrature, spherical conductor, scalp measurements, spatial jitter, sphere, VSH · block
oscr:b:V3AKH6T1QNQYQ-N· Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Python · 457 lines · 9.7 KB · MIT · 3 matches
- import numpy as np
- #Functions that are shared across the scripts used in the spatial-jitter simulations
- def BSph(r, rq, Q):
- """
- Calculate magnetic field due to a current dipole in a spherical conductor.
- Sarvas' formula is used'
- Parameters
- ----------
- r: array (1, 3)
- the position where the field is calculated
- rq: array (1, 3)
- the position of the dipole
- Q: array (1, 3)
- the dipole monent of the current dipole
- Returns
- -------
- B: array (1, 3)
- """
- mu04pi = 1e-7
- a = r-rq
- rn = np.linalg.norm(r)
- an = np.linalg.norm(a)
- F = an*(rn*an + rn**2 - np.dot(rq,r))
- nF1 = ((1/rn)*an**2 + (1/an)*np.dot(a,r) + 2*an + 2*rn)*r
- nF2 = -(an+ 2*rn + 1/an*np.dot(a,r))*rq
- nF = nF1+nF2
- B = mu04pi*(F*np.cross(Q,rq) - (np.dot(np.cross(Q,rq),r)*(nF)))/(F**2)
- return B
- def spectra(coefs, lmax):
- """
- Calculate the energy-spectral density from the VSH coefficients
- Parameters
- ----------
- coefs: array (Ncoefs)
- the VSH coefficients
- lmax: integer
- the maximum l-degree
- Returns
- -------
- s: array (lmax, 1)
- """
- s = np.zeros(lmax)
- lind = 0
- for l in range(1,lmax+1):
- temp = 0
- for m in range(-1*l,l+1):
- c = coefs[lind]
- temp += c**2
- lind += 1
- s[l-1] = temp
- return s
- def Bdim(r, n, t1, t2, rq, Q, dim):
- """
- Calculate the sensor output to a current dipole in a spherical conductor.
- Assumes rectangular sensor. Uses Sarvas' formula. Outputs the 3D magnetic field vector.
- Parameters
- ----------
- r: array (1,3)
- the position of the sensor
- n: array (1,3)
- the normal vector of the sensor
- t1: array (1,3)
- the first tangential vector of the sensor
- t2: array (1,3)
- the second tangential vector of the sensor
- rq: array (1,3)
- the position of the dipole
- Q: array (1,3)
- the dipole monent of the current dipole
- dim: float
- the sidelength of the sensor rectangle
- Returns
- -------
- res: array (1, 3)
- """
- ropm = np.zeros((4,3))
- ropm[0] = r + dim/4*t1 + dim/4*t2
- ropm[1] = r + dim/4*t1 - dim/4*t2
- ropm[2] = r - dim/4*t1 + dim/4*t2
- ropm[3] = r - dim/4*t1 - dim/4*t2
- res = np.zeros((1,3))
- for i in range(4):
- res += BSph(ropm[i], rq, Q)
- res /= 4
- return res
- def GetRandomPointsInAsphere(dim,N):
- """
- Get uniform-distributed random points inside a half sphere (z>0).
- Parameters
- ----------
- dim: float
- the radius of the half sphere
- N: integer
- the number of random points to be produced
- Returns
- -------
- xr: array (N, 1)
- yr: array (N, 1)
- zr: array (N, 1)
- """
- u = np.random.rand(N)
- rr = dim*np.cbrt(u)
- thetar = 2*np.pi*np.random.rand(N)
- phir = np.arccos(np.random.rand(N)) #random number drawn from [0,1] to produce points in the half sphere
- xr = rr*np.cos(thetar)*np.sin(phir)
- yr = rr*np.sin(thetar)*np.sin(phir)
- zr = rr*np.cos(phir)
- return xr, yr, zr
- def GetRandomPointsInACircle(dim,N):
- """
- Get uniform-distributed random points inside a circle.
- Parameters
- ----------
- dim: float
- the radius of the circle
- N: integer
- the number of random points to be produced
- Returns
- -------
- x: array (N, 1)
- y: array (N, 1)
- """
- u = np.random.rand(N)
- r = dim*np.sqrt(u)
- theta = 2*np.pi*np.random.rand(N)
- x = r*np.cos(theta)
- y = r*np.sin(theta)
- return x, y
- def jitpos_tang(r,dim,t1,t2):
- """
- Add tangential spatial jitter to the sensor positions.
- Parameters
- ----------
- r: array (N,3)
- the sensor positions
- dim: float
- the amount of spatial jitter to be added
- t1: array (N,3)
- the first tangential vectors of the sensors
- t2: array (N,3)
- the second tangential vectors of the sensors
- Returns
- -------
- r_ret: array (N, 3)
- """
- N = r.shape[0]
- x, y = GetRandomPointsInACircle(dim,N)
- r_ret = r + x[:,None]*t1 + y[:,None]*t2
- return r_ret
- def jitpos_normal(r,dim,n):
- """
- Add normal/radial spatial jitter to the sensor positions.
- Parameters
- ----------
- r: array (N,3)
- the sensor positions
- dim: float
- the amount of spatial jitter to be added
- n: array (N,3)
- the normal vectors of the sensors
- Returns
- -------
- r_ret: array (N, 3)
- """
- N = r.shape[0]
- z = np.random.rand(N)*dim
- r_ret = r + z[:,None]*n
- return r_ret
- def jitpos_3D(r,dim,t1,t2,n):
- """
- Add 3D spatial jitter to the sensor positions.
- Parameters
- ----------
- r: array (N,3)
- the sensor positions
- dim: float
- the amount of spatial jitter to be added
- n: array (N,3)
- the normal vectors of the sensors
- t1: array (N,3)
- the first tangential vectors of the sensors
- t2: array (N,3)
- the second tangential vectors of the sensors
- Returns
- -------
- r_ret: array (N, 3)
- """
- N = r.shape[0]
- x, y, z = GetRandomPointsInAsphere(dim,N)
- r_ret = r + x[:,None]*t1 + y[:,None]*t2+ z[:,None]*n
- return r_ret
- def jitori(theta):
- """
- Add orientation jitter to the sensor orientations.
- Each of the sensor axes is rotated by theta to a random direction.
- Parameters
- ----------
- theta: float
- the amount (in radians) how much the sensor axes are perturbed
- Returns
- -------
- ret: array (3, 3)
- rotation matrix that perturbs the sensor directions
- """
- #X-axis
- phi =np.random.rand()*2*np.pi
- u = np.zeros((1,3))
- u[0] = np.array((0, -1*np.sin(phi), np.cos(phi)))
- uxu = u.T@u
- ux = np.array(((0, -1*u[0,2], u[0,1]), (u[0,2],0, -1*u[0,0]), (-1*u[0,1], u[0,0], 0)))
- th = np.random.rand()*theta
- R = np.cos(th)*np.eye((3)) + np.sin(th)*ux + (1-np.cos(th))*uxu
- x = np.zeros((3,1))
- x[0] = 1
- new_x = R@x
- #Y-axis
- phi =np.random.rand()*2*np.pi
- u = np.zeros((1,3))
- u[0] = np.array((np.sin(phi), 0, -1*np.cos(phi)))
- uxu = u.T@u
- ux = np.array(((0, -1*u[0,2], u[0,1]), (u[0,2],0, -1*u[0,0]), (-1*u[0,1], u[0,0], 0)))
- th = np.random.rand()*theta
- R = np.cos(th)*np.eye((3)) + np.sin(th)*ux + (1-np.cos(th))*uxu
- y = np.zeros((3,1))
- y[1] = 1
- new_y= R@y
- #z-axis
- phi =np.random.rand()*2*np.pi
- u = np.zeros((1,3))
- u[0] = np.array((-1*np.sin(phi), np.cos(phi),0))
- uxu = u.T@u
- ux = np.array(((0, -1*u[0,2], u[0,1]), (u[0,2],0, -1*u[0,0]), (-1*u[0,1], u[0,0], 0)))
- th = np.random.rand()*theta
- R = np.cos(th)*np.eye((3)) + np.sin(th)*ux + (1-np.cos(th))*uxu
- z = np.zeros((3,1))
- z[2] = 1
- new_z= R@z
- ret = np.zeros((3,3))
- ret[0] = new_x.T
- ret[1] = new_y.T
- ret[2] = new_z.T
- return ret
- def CalculateCoefs(b,V,Rm,Rs,w,lvalues):
- """
- Calculate VSH coefficients according to the inner product formula.
- Only works for dense spherical sensor arrays defined at quadrature points for integrating over a sphere.
- Please check the manuscript.
- Parameters
- ----------
- b: array (Nx3)
- the magnetic field at the sensor positions
- V: array (Nx3xNc)
- Nc VSH basis functions normalized to unit energy
- Rm: float
- the radius of the sphere where the sensor array is
- Rs: float
- the radius of the sphere of the VSH expansion
- w: array (N)
- the quadrature weights at the sensor positions
- lvalues: array (Nc)
- the values of l-degrees at each index
- Returns
- -------
- coeffs: array (Nc, 1)
- """
- Nc = V.shape[2]
- mu0 = 1e-7 * 4 * np.pi
- coeffs = np.zeros((Nc))
- for i in range(Nc):
- dotp = np.sum(w*np.sum(b * V[:,:,i], axis=1))
- coeffs[i] = - Rm**(2*lvalues[i]+4)*dotp/(mu0*(2*lvalues[i]+1)*Rs**(2*lvalues[i]+1))
- return coeffs
- def rand_rotation_matrix(angle):
- """
- Generate a random rotation matrix. The matrix rotates a vector to a random direction by an angle.
- Parameters
- ----------
- angle: float
- rotation angle in radians
- Returns
- -------
- R: array (3, 3)
- """
- x1 = np.random.rand()
- x2 = np.random.rand()
- theta = np.arccos(2*x1-1)
- phi= 2*np.pi*x2
- v = np.array((np.sin(theta)*np.cos(phi), np.sin(theta)*np.sin(phi),np.cos(theta)))
- cn= 1-np.cos(angle)
- c = np.cos(angle)
- s = np.sin(angle)
- R = np.zeros((3,3))
- R[0,0] = v[0]**2*cn+c
- R[0,1] = v[0]*v[1]*cn-v[2]*s
- R[0,2] = v[0]*v[2]*cn+v[1]*s
- R[1,0] = v[0]*v[1]*cn+v[2]*s
- R[1,1] = v[1]**2*cn+c
- R[1,2] = v[1]*v[2]*cn-v[0]*s
- R[2,0] = v[0]*v[2]*cn-v[1]*s
- R[2,1] = v[1]*v[2]*cn+v[0]*s
- R[2,2] = v[2]**2*cn+c
- return R
- def rand_translation(dist):
- """
- Generate a random translation vector. Translates a vector to random direction by a some distance.
- Parameters
- ----------
- dist: float
- translation distance
- Returns
- -------
- v: array (1, 3)
- """
- x1 = np.random.rand()
- x2 = np.random.rand()
- theta = np.arccos(2*x1-1)
- phi= 2*np.pi*x2
- v = np.array((np.sin(theta)*np.cos(phi), np.sin(theta)*np.sin(phi),np.cos(theta)))*dist
- return v
functions.py at commit 3ec835c, under MIT · at the source
Overview
Abstract
Sampling jitter, i.e., random deviations in the time instants when samples are taken, causes frequency-dependent noise that reduces signal-to-noise ratio (SNR). This paper generalizes the concept of jitter to magnetoencephalography (MEG) sensor arrays that spatially sample the quasistatic magnetic field due to brain activity. It is shown that spatial jitter, i.e., random deviations in MEG sensor positions, causes spatial-frequency-depend
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 6 matches between paragraphs and lines of code.
jiivana/SpatialJitter
3ec835c01f790e5a01659f8dad5846f0bfa3e11b, 31 March 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
14 files
- BEM_analysis_MeasCov.py, Python, 321 lines, 2 matches
- BEM_simulation_MeasCov.p
y , Python, 396 lines - BEM_simulation_analysis.
py , Python, 149 lines - BEM_simulation_inpieces.
py , Python, 768 lines - Bspectrasphere.py, Python, 853 lines
- Illustration.py, Python, 313 lines
- Illustration_BEM.py, Python, 560 lines
- LICENSE.py, Python, 7 lines
- PlotManyParameterResults
.py , Python, 173 lines - TransferFunctions.py, Python, 599 lines
- UniformTranslationRotati
on.py , Python, 278 lines - functions.py, Python, 457 lines, 3 matches
- source_depth.py, Python, 296 lines, 1 match
- README.md, Text, 5 lines
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 13 scripts, each with its path and the digest of its content;
- 6 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 2, 28 September 2026
- Publisher: n/a → Institute of Electrical and Electronics Engineers
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 1 author, 6 keywords, 8 MeSH terms, 5 funders, 28 references.
Cite
This paper
Iivanainen, J. (2026). Spatial-Jitter Model for Magnetoencephalography Sensor Arrays. IEEE transactions on medical imaging, 45(7), 3908-3921. https://
BibTeX
@article{iivanainen2026s
author = {Iivanainen, Joonas},
title = {{Spatial-Jitter Model for Magnetoencephalography Sensor Arrays}},
journal = {IEEE transactions on medical imaging},
year = {2026},
month = jul,
volume = {45},
number = {7},
pages = {3908--3921},
publisher = {Institute of Electrical and Electronics Engineers},
issn = {0278-0062},
doi = {10.1109/
url = {https://
pmid = {42043988},
pmcid = {PMC13503295}
}
RIS
TY - JOUR
AU - Iivanainen, Joonas
TI - Spatial-Jitter Model for Magnetoencephalography Sensor Arrays
T2 - IEEE transactions on medical imaging
J2 - IEEE Trans Med Imaging
PY - 2026
DA - 2026/
VL - 45
IS - 7
SP - 3908
EP - 3921
SN - 0278-0062
PB - Institute of Electrical and Electronics Engineers
DO - 10.1109/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1109/
"type": "article-journal",
"title": "Spatial-Jitter Model for Magnetoencephalography Sensor Arrays",
"container-title": "IEEE transactions on medical imaging",
"author": [
{
"family": "Iivanainen",
"given": "Joonas"
}
],
"container-title-short":
"volume": "45",
"issue": "7",
"page": "3908-3921",
"DOI": "10.1109/
"PMID": "42043988",
"PMCID": "PMC13503295",
"ISSN": "0278-0062",
"publisher": "Institute of Electrical and Electronics Engineers",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
1
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1088/1361-6560/ace306 [code]
- A minimum assumption approach to MEG sensor array design.Journal: Physics in medicine and biologyIn common: MNE-Python, SciPy, Matplotlib, 1 other tool, MEG, 7 references, author Joonas Iivanainen
- [2] doi:10.1016/j.jneumeth.2024.110279 [code]
- Optimizing magnetometers arrays and analysis pipelines for multivariate pattern analysis.Journal: Journal of neuroscience methodsIn common: MNE-Python, SciPy, Matplotlib, 1 other tool, MEG, 9 references
- [3] doi:10.1016/j.ynirp.2022.100093 [code]
- On-scalp magnetocorticography with optically pumped magnetometers: Simulated performance in resolving simultaneous sources.Journal: Neuroimage. ReportsIn common: MNE-Python, SciPy, Matplotlib, 1 other tool, MEG, 8 references
- [4] doi:10.1016/j.neuroimage.2021.118747
- Spatial sampling of MEG and EEG based on generalized spatial-frequency analysis and optimal design.Journal: NeuroImageIn common: MEG, 7 references, author Joonas Iivanainen
- [5] doi:10.1162/imag_a_00283 [code]
- A novel, robust, and portable platform for magnetoencephalography using optically-pumped magnetometers.Journal: Imaging neuroscience (Cambridge, Mass.)In common: MNE-Python, Matplotlib, NumPy, MEG, 8 references
- [6] doi:10.3390/s22083059
- Calibration and Localization of Optically Pumped Magnetometers Using Electromagnetic Coils.Journal: Sensors (Basel, Switzerland)In common: MEG, 6 references, author Joonas Iivanainen
- [7] doi:10.1162/imag_a_00410 [code]
- Inferring laminar origins of MEG signals with optically pumped magnetometers (OPMs): A simulation study.Journal: Imaging neuroscience (Cambridge, Mass.)In common: MEG, 9 references
- [8] doi:10.1162/imag.a.1042 [code]
- Towards a 384-channel magnetoencephalography system based on optically pumped magnetometers.Journal: Imaging neuroscience (Cambridge, Mass.)In common: MNE-Python, SciPy, Matplotlib, 1 other tool, MEG, 6 references
- [9] doi:10.1162/imag_a_00112
- Optimising the sensitivity of optically-pumped magnetometer magnetoencephalography to gamma band electrophysiological activity.Journal: Imaging neuroscience (Cambridge, Mass.)In common: MEG, 8 references
- [10] doi:10.1162/imag_a_00489 [code]
- Pushing the boundaries of MEG based on optically pumped magnetometers towards early human life.Journal: Imaging neuroscience (Cambridge, Mass.)In common: MEG, 8 references
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 13 scripts, and 6 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:ac08410c8a2a4164…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.1109/tmi.2026.3687982)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1109/tmi.2026.3687982.svg
:target: https://openscicode.org/badge/doi/10.1109/tmi.2026.3687982
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1109/tmi.2026.3687982"><img src="https://openscicode.org/badge/doi/10.1109/tmi.2026.3687982.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
