ACR MRI phantom analysis based using the PumpIA framework.
Project description
Introduction
This repository contains code to analyse the ACR MRI phantoms using the PumpIA framework. It uses the subtraction SNR method and therefore expects a repeat image, however all modules except the SNR module will run with a single image.
It is in the process of being validated and is provided as is, see the license for more information.
The collection contains the following tests:
- SNR
- Uniformity
- Slice Width
- Slice Position
- Phantom Width (Geometric linearity and distortion)
- Ghosting
- Resolution (Contrast of 1mm insert)
Usage
Important: Users should make themselves familiar with the PumpIA user interface.
Installation
- Clone the repository
- Use an environment manager to install the requirements from
requirements.txtor install the requirements using the commandpip install -r requirements.txtwhen in the repository directory - Run the relevant script in /Testing
OR
install from PyPI using pip:
pip install pumpia-acr-mri
And run using the commands pumpia-acr-mri-l-old for the old large phantom (pre new geometry grid/slice 5) pumpia-acr-mri-l for the large phantom and pumpia-acr-mri-m for the medium phantom (making sure you are in the right environment if used for the pip install).
Running the Collection
- Load the folder with the relevant images
- Drag and drop the series containing the ACR images into the left viewer of the
Maintab - Drag and drop the series containing repeat images into the right viewer of the
Maintab - Generate the ROIs and run analysis. If the image has been analysed then the old ROIs may still be visible on the image, it is recommended to regenerate them as in some tests other information is loaded in this process.
- Correct the context if required (see below)
- Re-run generating ROIs
- Move any ROIs as required, this should be done through their relevant modules.
- Re-run analysis
- Copy the results in the relevant format. Horizontal is tab separated, vertical is new line separated.
SNR results are seperate from the other tests in the main results tab, this is so a single series can be ran in the left viewer (context is calculated from the image in this viewer) and relevant results for single image tests found.
Correcting Context
The context used for this collection is based on the Auto Phantom Context Manager provided with PumpIA, however it is expanded to find the rotation of the phantom. It has 3 new options:
- Inserts Slice
- Resolution Insert Side
- Circle Insert Side
The inserts slice is the slice with the resolution inserts in, this is either the first or last slice (1 or 11).
The Resolution Insert Side and Circle Insert Side options must not be on the same axis. i.e. top and bottom or left and right. The orthogonality of these options allows for the orientation and any flipping to be known.
If manual control is required then it is recommended to set the resolution insert side first as this is usually more obvious, and then set the circle insert side.
To avoid the program resetting any selected values the option Full Manual Control must be selected. This does not reset when a new image is loaded.
Modules
Subtraction SNR
Calculates SNR based on the subtraction method. The ROI size is determined from the size input as a percentage of the phantom height and width. The ROI is always centred on the phantom. The following corrections can be applied:
- Bandwidth
- Pixel Size (includes slice width)
- Number of Averages
- Number of Phase Encode Steps
A button for showing the subtraction image is included.
Uniformity
This is calculated using the integral uniformity method. The size of the ROI is determined in the same way as the SNR module.
There is the option of applying a low pass kernel convolution to the image prior to calculation, this is defaulted to on. The kernel is defined by
| 1/16 | 2/16 | 1/16 |
| 2/16 | 4/16 | 2/16 |
| 1/16 | 2/16 | 1/16 |
Ghosting
This calculate ghosting from a signal ROI in the middle of the phantom and ROIs above, below, left, and right of the phantom. ROI sizes do not follow the ACR guidance, the size of the signal ROI can be given.
Slice Width
Slice width is measured by fitting a curve to the profile of the ROIs.
This curve can be selected as either a flat top gaussian given by the following, where P is the rank:
$$A * exp\bigg(-\bigg(\frac{(x-x_0)^2}{2\sigma^2}\bigg)^P\bigg) + offset$$
or a split gaussian given by:
\left\{
\begin{array}{ c l }
A + offset & a \lt x\lt b \\
A * exp \bigg(-\frac{(x-a)^2}{2\sigma^2}\bigg) + offset & x \lt a \\
A * exp \bigg(-\frac{(x-b)^2}{2\sigma^2}\bigg) + offset & b \lt x
\end{array}
\right.
The percentage of A that the width is taken at can be provided ny the user, the default is 50%. Users can also override the $tan$ of the ramp angle, this is not recommended and is defaulted to 0.1 as defined in ACR guidance. The uniformity correction uses the profiles of ROIs directly above and below the slice width insert as a proxy for the non-uniformity across the ramps.
A button is provided to show the profiles of the ROIs used and the fits calculated using the selected method.
Slice Position
This follows the ACR guidance. A button is provided to show the profiles of the ROIs used.
Phantom Width
The phantom width is used to calculate the geometric linearity and distortion of the image. The percentage given is the percentage of the maximum pixel value at which the line profiles define the edge of the phantom. Users can select any line profiles they don't want included in the calculations (e.g. if there is a large bubble).
Resolution
The 1mm resolution insert is used. There are two methods available for calculating the resolution in the image, these are the FFT method and Contrast method, the FFT method is the default method. The results provided are the maximum calculated for each horizontal and vertical line ROI within the main ROI surrounding the insert that meets the following conditions:
- $length == floor\bigg(\frac{8}{pixel size}\bigg)$
- At least 1 pixel within 2mm of either end has $signal \gt max(box\ ROI)*\frac{resolution\ percentage}{100}$
An average of the horizontal and vertical contrasts is reported on the main tab, as well as a theoretical maximum for an 'ideal' offset.
FFT Method
The FFT method uses the fourier transform of the line ROI padded with zeros to be 10 times the length. The reported value is the $0.5mm^{-1}$ frequency normalised to the $0mm^{-1}$ frequency.
Contrast Method
- For each line the contrast is calculated by working out the contrast betwen the gaps betwen the pins and the pins either side of the gap.
- This gives 3 contrast values for each line (one for each gap between the pins), the worst case is taken as the contrast for the line.
Contrast is calculated using:
$$contrast(\%) = \frac{max-min}{max+min} * 100$$
Theoretical Maximum
The theoretical maximum resolution is provided by modelling the signal from a square wave at different x-offsets. The square wave is given by:
\left\{
\begin{array}{ c l }
1 & 0 \lt (x-offset)\mod 2 \lt 1\\
0 & 1 \lt (x-offset)\mod 2 \lt 2
\end{array}
\right.
This is integrated across pixels of an equivelant size to the image being analysed.
Important: The modeling does not take into account non-uniformities/distortions in images, it is therefore possible to measure a higher resolution than the theoretical maximum.
Calculating The Context
The context for this phantom is calculated as follows (selecting show boxes in the context menu allows some of this working to be seen):
- A profile of the slice averages is found, the minimum value is the inserts slice for the old large phantom or the geometric accuracy slice for the new large and medium phantom.
- The boundary of the phantom is found
- Four boxes are offset horizontally and vertically from the centre and their average value used to find the location of the resolution inserts (opposite the maximum value)
- Two boxes are drawn between the centre and the corners opposite the resolution inserts. The one with the minimum value is where the circle insert is.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pumpia_acr_mri-0.0.5.tar.gz.
File metadata
- Download URL: pumpia_acr_mri-0.0.5.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9bf4c1b828fe1a83c61cc8f7c0f70b19e6bfa6012ac76cb81a96feb2ec84a37
|
|
| MD5 |
ec377f51345fa81e4585bd1c0dad276b
|
|
| BLAKE2b-256 |
01fc5992fdf9eacb694afaaa482aa9c72553b30c47934b6eeed4f59f073f7d37
|
Provenance
The following attestation bundles were made for pumpia_acr_mri-0.0.5.tar.gz:
Publisher:
publish.yml on Principle-Five/pumpia-acr-mri
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pumpia_acr_mri-0.0.5.tar.gz -
Subject digest:
a9bf4c1b828fe1a83c61cc8f7c0f70b19e6bfa6012ac76cb81a96feb2ec84a37 - Sigstore transparency entry: 1817058576
- Sigstore integration time:
-
Permalink:
Principle-Five/pumpia-acr-mri@873f9a3c8c481fb7a049486c2ee429717720b493 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/Principle-Five
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@873f9a3c8c481fb7a049486c2ee429717720b493 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pumpia_acr_mri-0.0.5-py3-none-any.whl.
File metadata
- Download URL: pumpia_acr_mri-0.0.5-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c545132dc699b27033abde4267885d29ae7ad92ec918a6fd7cd6b9e6986837b
|
|
| MD5 |
927b71a3789bce603b0af9222eef8c93
|
|
| BLAKE2b-256 |
ca691fe72ca34ceba6739f08775888da4c2b2f9873e89455fbb551617a35069b
|
Provenance
The following attestation bundles were made for pumpia_acr_mri-0.0.5-py3-none-any.whl:
Publisher:
publish.yml on Principle-Five/pumpia-acr-mri
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pumpia_acr_mri-0.0.5-py3-none-any.whl -
Subject digest:
9c545132dc699b27033abde4267885d29ae7ad92ec918a6fd7cd6b9e6986837b - Sigstore transparency entry: 1817058713
- Sigstore integration time:
-
Permalink:
Principle-Five/pumpia-acr-mri@873f9a3c8c481fb7a049486c2ee429717720b493 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/Principle-Five
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@873f9a3c8c481fb7a049486c2ee429717720b493 -
Trigger Event:
release
-
Statement type: