|
| 1 | +--- |
| 2 | +title: 'NiTransforms: A Python tool to read, represent, manipulate, and apply $n$-dimensional spatial transforms' |
| 3 | +tags: |
| 4 | + - Python |
| 5 | + - neuroimaging |
| 6 | + - image processing |
| 7 | + - spatial transform |
| 8 | + - nibabel |
| 9 | +authors: |
| 10 | + - name: Mathias Goncalves |
| 11 | + orcid: 0000-0002-7252-7771 |
| 12 | + affiliation: 1 |
| 13 | + - name: Christopher J. Markiewicz |
| 14 | + orcid: 0000-0002-6533-164X |
| 15 | + affiliation: "1, 2" |
| 16 | + - name: Satrajit S. Ghosh |
| 17 | + orcid: 0000-0002-5312-6729 |
| 18 | + affiliation: "2, 3" |
| 19 | + - name: Russell A. Poldrack |
| 20 | + orcid: 0000-0001-6755-0259 |
| 21 | + affiliation: 1 |
| 22 | + - name: Oscar Esteban |
| 23 | + orcid: 0000-0001-8435-6191 |
| 24 | + affiliation: 1 |
| 25 | +affiliations: |
| 26 | + - name: Department of Psychology, Stanford University, Stanford, CA, USA |
| 27 | + index: 1 |
| 28 | + - name: McGovern Institute for Brain Research, Massachusetts Institute of Technology (MIT), Cambridge, MA, USA |
| 29 | + index: 2 |
| 30 | + - name: Department of Otolaryngology, Harvard Medical School, Boston, MA, USA |
| 31 | + index: 3 |
| 32 | +date: 04 November 2019 |
| 33 | +bibliography: nt.bib |
| 34 | +--- |
| 35 | + |
| 36 | +# Summary |
| 37 | + |
| 38 | +Spatial transforms formalize mappings between coordinates of objects in biomedical images. |
| 39 | +Transforms typically are the outcome of image registration methodologies, which estimate the alignment between two images. |
| 40 | +Image registration is a prominent task present in image processing. |
| 41 | +In neuroimaging, the proliferation of image registration software implementations has resulted in a disparate collection of structures and file formats used to preserve and communicate the transformation. |
| 42 | +This assortment of formats presents the challenge of compatibility between tools and endangers the reproducibility of results. |
| 43 | + |
| 44 | +_NiTransforms_ is a Python tool capable of reading and writing tranforms produced by the most popular neuroimaging software (AFNI [@cox_software_1997], FSL [@jenkinson_fsl_2012], FreeSurfer [@fischl_freesurfer_2012], ITK via ANTs [@avants_symmetric_2008], and SPM [@friston_statistical_2006]). |
| 45 | +Additionally, the tool provides seamless conversion between these formats, as well as the ability of applying the transforms to other images. |
| 46 | +_NiTransforms_ is inspired by `NiBabel` [@brett_nibabel_2006], a Python package with a collection of tools to read, write and handle neuroimaging data, and will be included as a new module. |
| 47 | + |
| 48 | +# Spatial transforms |
| 49 | + |
| 50 | +Let $\vec{x}$ represent the coordinates of a point in the reference coordinate system $R$, and $\vec{x}'$ its projection on to another coordinate system $M$: |
| 51 | + |
| 52 | +$T\colon R \subset \mathbb{R}^n \to M \subset \mathbb{R}^n$ |
| 53 | + |
| 54 | +$\vec{x} \mapsto \vec{x}' = f(\vec{x}).$ |
| 55 | + |
| 56 | +In an image registration problem, $M$ is a moving image from which we want to sample data in order to bring the image into spatial alignment with the reference image $R$. |
| 57 | +Hence, $f$ here is the spatial transformation function that maps from coordinates in $R$ to coordinates in $M$. |
| 58 | +There are a multiplicity of image registration algorithms and corresponding image transformation models to estimate linear and nonlinear transforms. |
| 59 | + |
| 60 | +The problem has been traditionally confused by the need of _transforming_ or mapping one image (generally referred to as _moving_) into another that serves as reference, with the goal of _fusing_ the information from both. |
| 61 | +An example of image fusion application would be the alignment of functional data from one individual's brain to the same individual's corresponding anatomical MRI scan for visualization. |
| 62 | +Therefore, "applying a transform" entails two operations: first, transforming the coordinates of the samples in the reference image $R$ to find their mapping $\vec{x}'$ on $M$ via $T\{\cdot\}$, and second an interpolation step as $\vec{x}'$ will likely fall off-the-grid of the moving image $M$. |
| 63 | +These two operations are confusing because, while the spatial transformation projects from $R$ to $M$, the data flows in reversed way after the interpolation of the values of $M$ at the mapped coordinates $\vec{x}'$. |
| 64 | + |
| 65 | +# Software Architecture |
| 66 | + |
| 67 | +There are four main components within the tool: an `io` submodule to handle the structure of the various file formats, a `base` submodule where abstract classes are defined, a `linear` submodule implementing $n$-dimensional linear transforms, and a `nonlinear` submodule for both parametric and non-parametric nonlinear transforms. |
| 68 | +Furthermore, _NiTranforms_ provides a straightforward _Application Programming Interface_ (API) that allows researchers to map point sets via transforms, as well as apply transforms (i.e., mapping the coordinates and interpolating the data) to data structures with ease. |
| 69 | + |
| 70 | +To ensure the consistency and uniformity of internal operations, all transforms are defined using a left-handed coordinate system of physical coordinates. |
| 71 | +In words from the neuroimaging domain, the coordinate system of transforms is _RAS+_ (or positive directions point to the Righthand for the first axis, Anterior for the second, and Superior for the third axis). |
| 72 | +The internal representation of transform coordinates is the most relevant design decision, and implies that a conversion of coordinate system is necessary to correctly interpret transforms generated by other software. |
| 73 | +When a transform that is defined in another coordinate system is loaded, it is automatically converted into _RAS+_ space. |
| 74 | + |
| 75 | +_NiTransforms_ was developed using a test-driven development paradigm, with the |
| 76 | +battery of tests being written prior to the software implementations. |
| 77 | +Two categories of tests were used: unit tests and cross-tool comparison tests. |
| 78 | +Unit tests evaluate the formal correctness of the implementation, while cross-tool |
| 79 | +comparison tests assess the correct implementation of third-party software. |
| 80 | +The testing suite is incorporated into a continuous integration framework, which assesses the continuity of the implementation along the development life and ensures that code changes and additions do not break existing functionalities. |
| 81 | + |
| 82 | +# Examples |
| 83 | + |
| 84 | +# References |
0 commit comments