Commit 4e0d4e5e authored by William Clarke's avatar William Clarke
Browse files

Merge branch 'bf/dynamic_fl_report' into 'master'

BF: Dynamic first level report

See merge request fsl/fsl_mrs!64
parents d55c0cdb 2922a20a
Pipeline #15649 failed with stage
This document contains the FSL-MRS release history in reverse chronological order.
2.0.4 (Wednesday 5th October 2022)
2.0.5 (Wednesday 5th October 2022)
----------------------------------
- Added specific `--fmrs` flag to fsl_mrs_preproc. This causes more sensible handling of data that isn't averaged e.g. not using data driven phase correction for each transient.
- `fsl_mrs_proc phase` and `fsl_mrs_proc fshift` now have the `--use_avg` to mirror the changes in `fsl_mrs_preproc`.
- Fixed plotting issue in `fsl_dynmrs` report.
- Updated Windows installation instructions.
2.0.4 (Wednesday 28th September 2022)
-------------------------------------
......
......@@ -50,10 +50,14 @@ Download or clone from |fslmrs_gitlab|_. To get FSL-MRS with example data and ex
Windows Operating System
~~~~~~~~~~~~~~~~~~~~~~~~
FSL-MRS has been tested thoroughly on Mac and Linux operating systems but is not currently tested on MS Windows. However there are two routes for using FSL-MRS on Windows.
FSL-MRS has been tested thoroughly on Mac and Linux operating systems but is not currently tested on MS Windows. However there are three routes for using FSL-MRS on Windows.
The first option is to install (as above) the FSL-MRS or complete FSL package using `Windows Subsystem for Linux <https://docs.microsoft.com/en-us/windows/wsl/install-win10>`_ (or WSL2). This offers an easy way of running a linux environment on a Windows machine. To install the full FSL package in WSL, follow the `instructions online <https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FslInstallation/Windows#Windows_Subsystem_for_Linux>`_
Option A: Using WSL (recommended)
---------------------------------
The first option is to install (as above) FSL-MRS and the complete FSL package using `Windows Subsystem for Linux <https://docs.microsoft.com/en-us/windows/wsl/install-win10>`_ (or WSL2). This offers an easy way of running a linux environment on a Windows machine. To install the full FSL package in WSL, follow the `instructions online <https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FslInstallation/Windows#Windows_Subsystem_for_Linux>`_
Option B: Native windows FSL-MRS + FSL on WSL
---------------------------------------------
Alternatively, as of V1.1.13 of FSL-MRS the python-only FSL-MRS package can be run in native Windows alongside a WSL FSL installation. This can be achieved as follows:
1. Enable WSL and install FSL into WSL as described in the `FSL install instructions <https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FslInstallation/Windows#Windows_Subsystem_for_Linux>`_.
......@@ -64,6 +68,11 @@ Alternatively, as of V1.1.13 of FSL-MRS the python-only FSL-MRS package can be r
For FSL-MRS to access the FSL scripts installed on the WSL machine, it must be running.
Option C: Native windows FSL-MRS (partial function)
---------------------------------------------------
Install FSL-MRS on the native Windows machine by following the conda installation guide in Option 1. Certain features which rely on an FSL installation (e.g. the :code:`svs_segment` scripts) won't function.
Verifying the installation
~~~~~~~~~~~~~~~~~~~~~~~~~~
......
'''FSL-MRS test script
Test the dynamic MRS fitting script fsl_dynmrs
Copyright Will Clarke, University of Oxford, 2022'''
from subprocess import run
from pathlib import Path
import pytest
import numpy as np
import fsl_mrs.utils.synthetic as syn
from fsl_mrs.core.nifti_mrs import gen_new_nifti_mrs
from fsl_mrs.core import basis
testsPath = Path(__file__).parent
model_path = testsPath / 'testdata/dynamic/simple_linear_model.py'
@pytest.fixture
def fixed_ratio_data(tmp_path):
FID_basis1 = syn.syntheticFID(chemicalshift=[1, ], amplitude=[1], noisecovariance=[[0]], damping=[3])
FID_basis2 = syn.syntheticFID(chemicalshift=[3, ], amplitude=[1], noisecovariance=[[0]], damping=[3])
FID_basis1[1]['fwhm'] = 3 * np.pi
FID_basis2[1]['fwhm'] = 3 * np.pi
bset = basis.Basis(
np.stack((FID_basis1[0][0], FID_basis2[0][0]), axis=1),
['Met1', 'Met2'],
[FID_basis1[1], FID_basis2[1]])
FID1 = syn.syntheticFID(chemicalshift=[1, 3], amplitude=[1, 1], noisecovariance=[[0.01]])
FID2 = syn.syntheticFID(chemicalshift=[1, 3], amplitude=[2, 2], noisecovariance=[[0.01]])
fid1 = FID1[0][0].reshape((1, 1, 1, 2048))
fid2 = FID2[0][0].reshape((1, 1, 1, 2048))
data = np.stack((fid1, fid2), axis=-1)
data = np.conj(data)
nmrs = gen_new_nifti_mrs(
data,
FID1[1]['dwelltime'],
FID1[1]['centralFrequency'],
dim_tags=['DIM_DYN', None, None])
time_var = np.arange(2)
# Save
basis_path = tmp_path / 'basis'
data_path = tmp_path / 'data.nii.gz'
tv_path = tmp_path / 'time_var.csv'
nmrs.save(data_path)
bset.save(basis_path)
np.savetxt(tv_path, time_var, delimiter=',')
return data_path, basis_path, tv_path
def test_fixtures(fixed_ratio_data):
assert fixed_ratio_data[0].exists()
assert fixed_ratio_data[1].exists()
assert fixed_ratio_data[2].exists()
def test_fsl_dynmrs(fixed_ratio_data, tmp_path):
data_str = str(fixed_ratio_data[0])
basis_str = str(fixed_ratio_data[1])
tv_str = str(fixed_ratio_data[2])
model_str = str(model_path)
run(['fsl_dynmrs',
'--data', data_str,
'--basis', basis_str,
'--dyn_config', model_str,
'--time_variables', tv_str,
'--baseline_order', '0',
'--output', str(tmp_path / 'dyn_res'),
'--report'])
assert (tmp_path / 'dyn_res').exists()
assert (tmp_path / 'dyn_res' / 'dyn_cov.csv').exists()
assert (tmp_path / 'dyn_res' / 'init_results.csv').exists()
assert (tmp_path / 'dyn_res' / 'dyn_results.csv').exists()
assert (tmp_path / 'dyn_res' / 'mapped_parameters.csv').exists()
assert (tmp_path / 'dyn_res' / 'free_parameters.csv').exists()
assert (tmp_path / 'dyn_res' / 'options.txt').exists()
assert (tmp_path / 'dyn_res' / 'report.html').exists()
......@@ -1314,11 +1314,12 @@ def plotly_dynMRS(mrs_list,
# Add traces, one for each slider step
for name in ydata:
for i, t in enumerate(time_var):
t_str = np.array2string(t, floatmode='fixed', precision=1)
fig.add_trace(
go.Scatter(
visible=False,
line=dict(color=colors[name], width=1),
name=f"{name} - {t}",
name=f"{name} - {t_str}",
x=xaxis,
y=ydata[name][i]))
......@@ -1347,11 +1348,12 @@ def plotly_dynMRS(mrs_list,
# Create and add slider steps
steps = []
for i in range(n):
t_str = np.array2string(time_var[i], floatmode='fixed', precision=1)
step = dict(
method="restyle",
label=f"t={time_var[i]}",
label=f"t={t_str}",
args=[{"visible": [False] * len(fig.data)},
{"title": f"time_variable : {time_var[i]}"}])
{"title": f"time_variable : {t_str}"}])
for j in range(len(ydata)):
step["args"][0]["visible"][i + j * n] = True
......
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