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
=========================
FSL-MRS can currently be installed using two methods
FSL-MRS can currently be installed using two methods.
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
pip install .
......@@ -31,3 +31,8 @@ To convert data to NIfTI install the spec2nii program from conda.
::
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
......@@ -5,4 +5,8 @@ Troubleshooting hints and tips will be added here. If you are having a problem w
mailing list <https://www.jiscmail.ac.uk/cgi-bin/webadmin?A0=FSL>`_ archives to see if somebody else has had the same problem, or send a email to the mailing list.
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 @@
import argparse
import os.path as op
from os import remove
from fsl.wrappers import fsl_anat, fslroi
from fsl.wrappers import fsl_anat
from fsl.wrappers.fnirt import applywarp
from subprocess import call
import numpy as np
from fsl.data.image import Image
......
......@@ -7,90 +7,101 @@ from fsl_mrs.utils.fitting import fit_FSLModel
from pytest import fixture
import numpy as np
# Set up some synthetic data to use
# Set up some synthetic data to use
@fixture(scope='module')
def data():
noiseCov = 0.01
amplitude = np.asarray([0.5,0.5,1.0])*10
chemshift = np.asarray([3.0,3.05,2.0])-4.65
lw = [10,10,10]
phases = [0,0,0]
g = [0,0,0]
basisNames = ['Cr','PCr','NAA']
amplitude = np.asarray([0.5, 0.5, 1.0])*10
chemshift = np.asarray([3.0, 3.05, 2.0])-4.65
lw = [10, 10, 10]
phases = [0, 0, 0]
g = [0, 0, 0]
basisNames = ['Cr', 'PCr', 'NAA']
begintime = 0.00005
basisFIDs = []
for idx,_ in enumerate(amplitude):
tmp,basisHdr = syntheticFID(noisecovariance=[[0.0]],
chemicalshift=[chemshift[idx]+0.1],
amplitude=[1.0],
linewidth=[lw[idx]/5],
phase=[phases[idx]],
g=[g[idx]],
begintime=0)
for idx, _ in enumerate(amplitude):
tmp, basisHdr = syntheticFID(noisecovariance=[[0.0]],
chemicalshift=[chemshift[idx]+0.1],
amplitude=[1.0],
linewidth=[lw[idx]/5],
phase=[phases[idx]],
g=[g[idx]],
begintime=0)
basisFIDs.append(tmp[0])
basisFIDs = np.asarray(basisFIDs)
synFID,synHdr = syntheticFID(noisecovariance=[[noiseCov]],
chemicalshift=chemshift,
amplitude=amplitude,
linewidth=lw,
phase=phases,
g=g,
begintime=begintime)
synFID, synHdr = syntheticFID(noisecovariance=[[noiseCov]],
chemicalshift=chemshift,
amplitude=amplitude,
linewidth=lw,
phase=phases,
g=g,
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
Fitargs = {'ppmlim':[0.2,4.2],
'method':'MH','baseline_order':-1,
'metab_groups':metab_groups,
'MHSamples':100,
'disable_mh_priors':True}
res = fit_FSLModel(synMRS,**Fitargs)
Fitargs = {'ppmlim': [0.2, 4.2],
'method': 'MH',
'baseline_order': -1,
'metab_groups': metab_groups,
'MHSamples': 100,
'disable_mh_priors': True}
res = fit_FSLModel(synMRS, **Fitargs)
return res, amplitude
return res,amplitude
def test_peakcombination(data):
res = data[0]
amplitudes = data[1]
res.combine([['Cr','PCr']])
res.combine([['Cr', 'PCr']])
fittedconcs = res.getConc()
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 np.allclose(fittedconcs,amplitudes,atol=1E-1)
assert np.allclose(fittedRelconcs,amplitudes/(amplitudes[0]+amplitudes[1]),atol=2E-1)
assert np.allclose(fittedconcs, amplitudes, atol=2E-1)
assert np.allclose(fittedRelconcs,
amplitudes/(amplitudes[0]+amplitudes[1]),
atol=2E-1)
def test_units(data):
res = data[0]
# Phase
p0,p1 = res.getPhaseParams(phi0='degrees',phi1='seconds')
assert np.isclose(p0,0.0,atol=1E-1)
assert np.isclose(p1,0.00005,atol=3E-5)
p0, p1 = res.getPhaseParams(phi0='degrees', phi1='seconds')
assert np.isclose(p0, 0.0, atol=1E-1)
assert np.isclose(p1, 0.00005, atol=3E-5)
# Shift
shift = res.getShiftParams(units='ppm')
shift_hz = res.getShiftParams(units='Hz')
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, 0.1, atol=1E-2)
assert np.isclose(shift_hz, 0.1*123.0, atol=1E-1)
# Linewidth
lw = res.getLineShapeParams(units='Hz')[0]
lw_ppm = res.getLineShapeParams(units='ppm')[0]
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, 8.0, atol=1E-1) # 10-2
assert np.isclose(lw_ppm, 8.0/123.0, atol=1E-1)
def test_qcOutput(data):
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
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