smart-mrs

For the simulation of commonly occurring artifacts in single voxel Gamma-Aminobutyric Acid (GABA)-edited Magnetic Resonance Spectroscopy (MRS) data.

https://github.com/harrisbrainlab/smart_mrs

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: pubmed.ncbi, ncbi.nlm.nih.gov
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.1%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

For the simulation of commonly occurring artifacts in single voxel Gamma-Aminobutyric Acid (GABA)-edited Magnetic Resonance Spectroscopy (MRS) data.

Basic Info
  • Host: GitHub
  • Owner: HarrisBrainLab
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: main
  • Size: 5.06 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created almost 2 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License Citation Support

README.md

SMART_MRS

SMART_MRS is a Python based library (toolbox) for applying simulated artifacts to edited Magnetic Resonance Spectroscopy (MRS) data.

MIT License, Copyright (c) 2024 HarrisBrainLab.

Use of SMART_MRS requires citation. Please see either CITATION.cff or GitHub's "Cite this repository".

For further information on the toolbox, please see SMART MRS Pub

Updates

Current version is 2.1. Previous version 2.0. See CHANGES.md for more details.

Module Descriptions

The SMART_MRS package contains 4 modules: * IO.py (allows for the import and export of specific data formats such as FID-A and nifti-mrs): * getFIDAmatdata() * returnFIDAmatdata() * getniftimrsdata() * returnniftimrsdata()

  • support.py (supports data manipulation for the use of other module functions):

    • to_fids()
    • to_specs()
    • interleave()
    • undo_interleave()
    • scale()
    • undo_scale()
  • artifacts.py (for the application of various artifacts):

    • addtimedomain_noise()
    • addspurecho_artifact()
    • addeddycurrent_artifact()
    • add_linebroad()
    • addnuisancepeak()
    • add_baseline()
    • addfreqdrift_linear()
    • addfreqshift_random()
    • addzeroorderphaseshift()
    • addfirstorderphaseshift()
  • applied.py (allows for specific iterations of the artifacts):

    • addprogressivemotion_artifact()
    • addsubtlemotion_artifact()
    • adddisruptivemotion_artifact()
    • addlipidartifact()

Dependencies

Each of the 4 modules have relative dependencies in addition to the following dependencies: * Nibabel (v.5.2.1) * NumPy (v.1.25.2) * SciPy (v.1.11.4)

SMART_MRS Installation Guide

Create an empty Conda environement for installation: bash conda create -n my_smart_mrs_env python=3.11.9

Activate the Conda environement: bash conda activate my_smart_mrs_env

Install pip into your Conda environement: bash conda install pip

Use pip package manager to install the SMART_MRS library as below: bash python3 -m pip install SMART_MRS

For more information on the versions of dependencies, please consult the smart_env.yml file.

Usage

Below are example uses of functions from each module in SMART_MRS. For further information on specific functions, please consult SupplementaryMaterial.pdf

```python import SMART_MRS import matplotlib.pyplot as plt

IO Functions example getniftimrs_data() - returns FIDs, time, and ppm

DIR = "C:/Users/" fids, time, ppm = SMARTMRS.IO.getniftimrsdata(dirnifti=f"{DIR}jdifferenceniftiSMARTMRS_EX.nii.gz") print(f'Data has {fids.shape[0]} FIDs with {fids.shape[1]} spectral points.')

Support Functions example scale() - returns scaled FIDs and scale factor

rawscaledfids, niftiscale = SMARTMRS.support.scale(fids) fids = np.copy(rawscaledfids)

Artifacts Functions example addnuisancepeak() - returns FIDs and artifact locations within dataset

Apply specific user values

gaussianpeakprofile = { "peaktype": "G", "amp": [0.010, 0.010], "width": [0.85, 0.85],
"res
freq": [1.5, 1.5], "phase": [0, 0], "edited": 1.02 }

When echo is True, will print non-user specified values used (in this case, the locations of the artifacts)

fids, nplocations = SMARTMRS.artifacts.addnuisancepeak(fids=fids, time=time, peakprofile=gaussianpeakprofile, locs=[0,1], cfppm=3, echo=True)

Plot nuisance peak

plt.figure(figsize=(10,5)) plt.suptitle('GABA-Edited Specs Before and After Nuisance Peak Addition')

plt.subplot(121) plt.title('Before', fontsize=10) plt.plot(ppm[::-1], (SMARTMRS.support.tospecs(rawscaledfids)[0, :]-SMARTMRS.support.tospecs(rawscaledfids)[1, :]).real, 'black') plt.xlabel('ppm') plt.xlim(0, 6) plt.gca().invert_xaxis()

plt.subplot(122) plt.title('After', fontsize=10) plt.plot(ppm[::-1], (SMARTMRS.support.tospecs(fids)[0, :]-SMARTMRS.support.tospecs(rawscaledfids)[1, :]).real, 'green') plt.xlabel('ppm') plt.xlim(0, 6) plt.gca().invert_xaxis() plt.show()

Applied Functions example adddisruptivemotion_artifact() - returns FIDs and artifact locations within dataset

use function specific values

fids, motionlocations = SMARTMRS.applied.adddisruptivemotion_artifact(fids=fids, time=time, ppm=ppm, locs=[2,3])

Plot disruptive motion

plt.figure(figsize=(10,5)) plt.suptitle('GABA-Edited Specs Before and After Disruptive Artifact')

plt.subplot(121) plt.title('Before', fontsize=10) plt.plot(ppm[::-1], (SMARTMRS.support.tospecs(rawscaledfids)[2, :]-SMARTMRS.support.tospecs(rawscaledfids)[3, :]).real, 'black') plt.xlabel('ppm') plt.xlim(0, 6) plt.gca().invert_xaxis()

plt.subplot(122) plt.title('After', fontsize=10) plt.plot(ppm[::-1], (SMARTMRS.support.tospecs(fids)[2, :]-SMARTMRS.support.tospecs(fids)[3, :]).real, 'blue') plt.xlabel('ppm') plt.xlim(0, 6) plt.gca().invert_xaxis() plt.show()

Save Fids with Artifacts as original data type

New nifti should be saved under same name "_SMART.niigz" at same location

fids = SMARTMRS.support.undoscale(fids=fids, scalefact=niftiscale) SMARTMRS.IO.returnniftimrsdata(dirnifti=f"{DIR}jdifferenceniftiSMARTMRSEX.nii.gz", fids=fids, edited=True) ``` The above code generates the following plots: _Nuisance Peak Example__ alt text

Disruptive Motion Example

alt text

Owner

  • Login: HarrisBrainLab
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "When using the SMART_MRS Toolboxe, please cite it as below."
authors:
- family-names: "Bugler"
  given-names: "Hanna"
- family-names: "Shamaei"
  given-names: "Amirmohammad"
- family-names: "Souza"
  given-names: "Roberto"
- family-names: "Harris"
  given-names: "Ashley D."
title: "SMART MRS Toolbox "
version: 2.1
doi: 10.1101/2024.09.19.612894
date-released: 2024-09-25
url: "https://github.com/HarrisBrainLab/SMART_MRS"
preferred-citation:
  type: article
  authors:
 - family-names: "Bugler"
  given-names: "Hanna"
- family-names: "Shamaei"
  given-names: "Amirmohammad"
- family-names: "Souza"
  given-names: "Roberto"
- family-names: "Harris"
  given-names: "Ashley D."
  doi: 10.1101/2024.09.19.612894		# preprint citation - peer-reviewed journal publication pending
  journal: "bioRxiv"				
  month: 9
  start: 1 					# First page number
  end: 10 					# Last page number
  title: "SMART MRS: A Simulated MEGA-PRESS Artifacts Toolbox for GABA-edited MRS "
  issue: 1
  volume: 1
  year: 2024

GitHub Events

Total
  • Push event: 8
Last Year
  • Push event: 8

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 16 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
pypi.org: smart-mrs

Simulated Artifacts for edited Magnetic Resonance Spectroscopy (MRS) data

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 16 Last month
Rankings
Dependent packages count: 10.3%
Average: 34.1%
Dependent repos count: 57.9%
Maintainers (1)
Last synced: 10 months ago