Skip to main content

mridataPy

mridataPy is

  • a lightweight toolbox for downloading and processing mridata from mridata.org

mridataPy supports to

  • download dataset from either mridata.org or old.mridata.org
  • load mridata to NumPy arrays, which can be stored to .npy files
  • generate sampling masks that can densely sample the center region in k-space while subsample the outer region based on acceleration factor
  • provide the ground truth reconstructed by applying RSS coil-combination to fullysampled data
  • evaluate reconstructions with MSE, NMSE, PSNR, SSIM metrics

Quickstart

Download one case of Stanford Fullysampled 3D FSE Knees (totally, 20 cases) from mridata.org:

import mridatapy

mridata = mridatapy.data.MRIData()
mridata.download(num=1)

Dependencies and Installation

Package Dependencies

pip will handle all package dependencies.

Install mridataPy

$ pip install mridatapy

Documentation

Module data

MRIData

class mridatapy.data.MRIData(data_type=None, path=None)
  • urls

    Attribute: Whole lists of download URLs corresponding to mridata of the given data type.

  • filenames

    Attribute: Whole lists of download filenames corresponding to mridata of the given data type.

  • type

    Attribute: Data type of mridata.

  • dir

    Attribute: Directory to the folder "mridata/" as the default path for mridata.

  • download(num=None)

    Instance method: Downloads mridata of the given data type.

  • to_np(num=None, stack=None)

    Instance method: Loads mridata to complex-valued k-space NumPy arrays. If not exist, download first.

  • to_npy(path=None, num=None, stack=None)

    Instance method: Converts mridata to .npy files. If not exist, download first.

  • get(data_type)

    Static method: Gets whole lists of download URLs and filenames corresponding to mridata of the given data type to be downloaded.

  • fetch(url, filename, path)

    Static method: Fetches mridata given the specific pair of download URL and filename.

  • ismrmrd_to_np(file, filter=None, prewhiten=None, first_slice=None)

    Static method: Loads .h5 ISMRMRD file to complex-valued k-space NumPy array.

  • ismrmrd_to_npy(file, path=None, filter=None, prewhiten=None, first_slice=None)

    Static method: Converts .h5 ISMRMRD file to .npy file.

  • cfl_to_np(file)

    Static method: Loads .cfl file to complex-valued k-space NumPy array.

  • cfl_to_npy(file, path=None)

    Static method: Converts .cfl file to .npy file.

  • unzip(file, path=None, remove=None)

    Static method: Unzips .zip file.

  • load_npy(file)

    Static method: Loads .npy file.

RandomLine

class mridatapy.data.RandomLine(acceleration_factor, center_fraction)

Generates a sampling mask of the given shape that can densely sample the center region in k-space while subsample the outer region based on acceleration factor. The mask randomly selects a subset of columns from input k-space data.

  • __call__(shape, dtype=numpy.complex64, max_attempts=30, tolerance=0.1, seed=None)

    Magic method enables instances to behave like functions.

EquispacedLine

class mridatapy.data.EquispacedLine(acceleration_factor, center_fraction)

Generates a sampling mask of the given shape that can densely sample the center region in k-space while subsample the outer region based on acceleration factor. The mask selects a roughly equispaced subset of columns from input k-space data.

  • __call__(shape, dtype=numpy.complex64, max_attempts=30, tolerance=0.1, seed=None)

    Magic method enables instances to behave like functions.

PoissonDisk

class mridatapy.data.PoissonDisk(acceleration_factor, center_fraction)

Generates a sampling mask of the given shape that can densely sample the center region in k-space while subsample the outer region based on acceleration factor. The mask selects a subset of points from input k-space data, characterized by the Poisson disk sampling pattern.

  • __call__(shape, dtype=numpy.complex64, max_attempts=30, tolerance=0.1, seed=None)

    Magic method enables instances to behave like functions.

Module utils

fft_centered

function mridatapy.utils.fft_centered(input, shape=None, dim=None, norm=None)

Computes the centered N dimensional discrete Fourier transform (FFT) of input.

ifft_centered

function mridatapy.utils.ifft_centered(input, shape=None, dim=None, norm=None)

Computes the centered N dimensional inverse discrete Fourier transform (IFFT) of input.

root_sum_squares

function mridatapy.utils.root_sum_squares(input, dim, complex=False)

Computes the Root Sum of Squares (RSS) of input along the a given dimension (coil dimension).

Module metrics

mean_squared_error

function mridatapy.metrics.mean_squared_error(gt, pred)

Computes the Mean Squared Error (MSE) between two images.

normalized_mse

function mridatapy.metrics.normalized_mse(gt, pred)

Computes the Normalized Mean Squared Error (NMSE) between two images.

peak_signal_noise_ratio

function mridatapy.metrics.peak_signal_noise_ratio(gt, pred, data_range=None)

Computes the Peak Signal to Noise Ratio (PSNR) between two images.

structural_similarity

function mridatapy.metrics.structural_similarity(gt, pred, data_range=None)

Computes the Structural Similarity Index (SSIM) between two images.

Related Projects

Metadata

Release files for mridatapy 0.0.6

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

Source distribution (sdist)

Source distribution for mridatapy 0.0.6
File Size Uploaded
mridataPy-0.0.6.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mridatapy 0.0.6
File Interpreter ABI Platform
mridataPy-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 30.7 kB

Release files / mridataPy-0.0.6.tar.gz

Download URL mridataPy-0.0.6.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a325100a026a86ac8ca35352c6010ce0271f60f419fa9bb4baa9ef981c03ac0a
BLAKE2b-256 checksum
How to use checksums
0693a55648ff1d9eab5fe584eb1e317371400b6ca715361f7e1c88a432fc5fdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.0 importlib_metadata/3.7.3 packaging/20.8 pkginfo/1.6.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

Release files / mridataPy-0.0.6-py3-none-any.whl

Download URL mridataPy-0.0.6-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b2b5c10f1dcc9f7bacd44d25989ca49807d2c887cc035aa44fbce9278e39310
BLAKE2b-256 checksum
How to use checksums
b5cd0314ee37e68df264996556d1826f2e6b28a9e472d9743fe738fb9f0f4470
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.0 importlib_metadata/3.7.3 packaging/20.8 pkginfo/1.6.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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