Commit 692edc85 authored by William Clarke's avatar William Clarke
Browse files

Merge branch 'master' into 'master'

Version 1.0.0

See merge request !4
parents 0b90dd77 86c61b43
This document contains the FSL-MRS release history in reverse chronological order.
1.0.0 (Wednesday 17th June 2020)
--------------------------------
- First public release of package.
Changelog FSL-MRS Release History
========= =======================
.. include:: ../../CHANGELOG.rst
Installation Instructions Installation Instructions
========================= =========================
FSL-MRS can currently be installed using two methods FSL-MRS can currently be installed using two methods.
1. From GitLab 1. From GitLab
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Download or clone from |fslmrs_gitlab|_. `Git LFS <https://git-lfs.github.com/>`_ must be installed to download package data. Download or clone from |fslmrs_gitlab|_. To get FSL-MRS with example data and example Jupyter notebooks, download the full package from gitlab. `Git LFS <https://git-lfs.github.com/>`_ must be installed to download package data.
:: ::
git clone --recurse-submodules https://git.fmrib.ox.ac.uk/saad/fsl_mrs.git git clone --recurse-submodules https://git.fmrib.ox.ac.uk/fsl/fsl_mrs.git
cd fsl_mrs cd fsl_mrs
pip install . pip install .
...@@ -31,3 +31,8 @@ To convert data to NIfTI install the spec2nii program from conda. ...@@ -31,3 +31,8 @@ To convert data to NIfTI install the spec2nii program from conda.
:: ::
conda install -c conda-forge spec2nii conda install -c conda-forge spec2nii
Operating systems
~~~~~~~~~~~~~~~~~
FSL-MRS has been tested throughly on Mac and Linux operating systems. FSL-MRS dependencies and FSL-MRS is availible on native Windows installations, but has not currently been tested. `Windows Subsytem for Linux <https://docs.microsoft.com/en-us/windows/wsl/install-win10>`_ (or WSL2) offers a Linux interface on Windows. FSL-MRS has been tested on WSL.
\ No newline at end of file
...@@ -6,3 +6,7 @@ mailing list <https://www.jiscmail.ac.uk/cgi-bin/webadmin?A0=FSL>`_ archives to ...@@ -6,3 +6,7 @@ mailing list <https://www.jiscmail.ac.uk/cgi-bin/webadmin?A0=FSL>`_ archives to
MRS specific questions may be better answered on the `MRSHub forums <https://forum.mrshub.org/>`_. MRS specific questions may be better answered on the `MRSHub forums <https://forum.mrshub.org/>`_.
1. Unable to find example data
If you installed FSL-MRS through conda the example data can be downloaded directly from the GitLab repository `folder <https://git.fmrib.ox.ac.uk/fsl/fsl_mrs/-/tree/master/example_usage>`_.
\ No newline at end of file
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
import argparse import argparse
import os.path as op import os.path as op
from os import remove from os import remove
from fsl.wrappers import fsl_anat, fslroi from fsl.wrappers import fsl_anat
from fsl.wrappers.fnirt import applywarp from fsl.wrappers.fnirt import applywarp
from subprocess import call
import numpy as np import numpy as np
from fsl.data.image import Image from fsl.data.image import Image
......
...@@ -7,21 +7,22 @@ from fsl_mrs.utils.fitting import fit_FSLModel ...@@ -7,21 +7,22 @@ from fsl_mrs.utils.fitting import fit_FSLModel
from pytest import fixture from pytest import fixture
import numpy as np import numpy as np
# Set up some synthetic data to use # Set up some synthetic data to use
@fixture(scope='module') @fixture(scope='module')
def data(): def data():
noiseCov = 0.01 noiseCov = 0.01
amplitude = np.asarray([0.5,0.5,1.0])*10 amplitude = np.asarray([0.5, 0.5, 1.0])*10
chemshift = np.asarray([3.0,3.05,2.0])-4.65 chemshift = np.asarray([3.0, 3.05, 2.0])-4.65
lw = [10,10,10] lw = [10, 10, 10]
phases = [0,0,0] phases = [0, 0, 0]
g = [0,0,0] g = [0, 0, 0]
basisNames = ['Cr','PCr','NAA'] basisNames = ['Cr', 'PCr', 'NAA']
begintime = 0.00005 begintime = 0.00005
basisFIDs = [] basisFIDs = []
for idx,_ in enumerate(amplitude): for idx, _ in enumerate(amplitude):
tmp,basisHdr = syntheticFID(noisecovariance=[[0.0]], tmp, basisHdr = syntheticFID(noisecovariance=[[0.0]],
chemicalshift=[chemshift[idx]+0.1], chemicalshift=[chemshift[idx]+0.1],
amplitude=[1.0], amplitude=[1.0],
linewidth=[lw[idx]/5], linewidth=[lw[idx]/5],
...@@ -31,7 +32,7 @@ def data(): ...@@ -31,7 +32,7 @@ def data():
basisFIDs.append(tmp[0]) basisFIDs.append(tmp[0])
basisFIDs = np.asarray(basisFIDs) basisFIDs = np.asarray(basisFIDs)
synFID,synHdr = syntheticFID(noisecovariance=[[noiseCov]], synFID, synHdr = syntheticFID(noisecovariance=[[noiseCov]],
chemicalshift=chemshift, chemicalshift=chemshift,
amplitude=amplitude, amplitude=amplitude,
linewidth=lw, linewidth=lw,
...@@ -39,58 +40,68 @@ def data(): ...@@ -39,58 +40,68 @@ def data():
g=g, g=g,
begintime=begintime) begintime=begintime)
synMRS = MRS(FID =synFID[0],header=synHdr,basis =basisFIDs,basis_hdr=basisHdr,names=basisNames) synMRS = MRS(FID=synFID[0],
header=synHdr,
basis=basisFIDs,
basis_hdr=basisHdr,
names=basisNames)
metab_groups = [0]*synMRS.numBasis metab_groups = [0]*synMRS.numBasis
Fitargs = {'ppmlim':[0.2,4.2], Fitargs = {'ppmlim': [0.2, 4.2],
'method':'MH','baseline_order':-1, 'method': 'MH',
'metab_groups':metab_groups, 'baseline_order': -1,
'MHSamples':100, 'metab_groups': metab_groups,
'disable_mh_priors':True} 'MHSamples': 100,
'disable_mh_priors': True}
res = fit_FSLModel(synMRS, **Fitargs)
res = fit_FSLModel(synMRS,**Fitargs) return res, amplitude
return res,amplitude
def test_peakcombination(data): def test_peakcombination(data):
res = data[0] res = data[0]
amplitudes = data[1] amplitudes = data[1]
res.combine([['Cr','PCr']]) res.combine([['Cr', 'PCr']])
fittedconcs = res.getConc() fittedconcs = res.getConc()
fittedRelconcs = res.getConc(scaling='internal') fittedRelconcs = res.getConc(scaling='internal')
amplitudes = np.append(amplitudes,amplitudes[0]+amplitudes[1]) amplitudes = np.append(amplitudes, amplitudes[0]+amplitudes[1])
assert 'Cr+PCr' in res.metabs assert 'Cr+PCr' in res.metabs
assert np.allclose(fittedconcs,amplitudes,atol=1E-1) assert np.allclose(fittedconcs, amplitudes, atol=2E-1)
assert np.allclose(fittedRelconcs,amplitudes/(amplitudes[0]+amplitudes[1]),atol=2E-1) assert np.allclose(fittedRelconcs,
amplitudes/(amplitudes[0]+amplitudes[1]),
atol=2E-1)
def test_units(data): def test_units(data):
res = data[0] res = data[0]
# Phase # Phase
p0,p1 = res.getPhaseParams(phi0='degrees',phi1='seconds') p0, p1 = res.getPhaseParams(phi0='degrees', phi1='seconds')
assert np.isclose(p0,0.0,atol=1E-1) assert np.isclose(p0, 0.0, atol=1E-1)
assert np.isclose(p1,0.00005,atol=3E-5) assert np.isclose(p1, 0.00005, atol=3E-5)
# Shift # Shift
shift = res.getShiftParams(units='ppm') shift = res.getShiftParams(units='ppm')
shift_hz = res.getShiftParams(units='Hz') shift_hz = res.getShiftParams(units='Hz')
assert np.isclose(shift,0.1,atol=1E-2) assert np.isclose(shift, 0.1, atol=1E-2)
assert np.isclose(shift_hz,0.1*123.0,atol=1E-1) assert np.isclose(shift_hz, 0.1*123.0, atol=1E-1)
# Linewidth # Linewidth
lw = res.getLineShapeParams(units='Hz')[0] lw = res.getLineShapeParams(units='Hz')[0]
lw_ppm = res.getLineShapeParams(units='ppm')[0] lw_ppm = res.getLineShapeParams(units='ppm')[0]
assert np.isclose(lw,8.0,atol=1E-1) #10-2 assert np.isclose(lw, 8.0, atol=1E-1) # 10-2
assert np.isclose(lw_ppm,8.0/123.0,atol=1E-1) assert np.isclose(lw_ppm, 8.0/123.0, atol=1E-1)
def test_qcOutput(data): def test_qcOutput(data):
res = data[0] res = data[0]
SNR,FWHM = res.getQCParams() SNR, FWHM = res.getQCParams()
assert np.allclose(FWHM,10.0,atol=1E0) assert np.allclose(FWHM, 10.0, atol=1E0)
assert SNR.size == 3 assert SNR.size == 3
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment