Skip to content

Commit

Permalink
Adding additional citation information, add final file write check.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtclarke committed Oct 2, 2022
1 parent 475c7d0 commit 23877cc
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
"orcid": "0000-0001-7159-7025",
"affiliation": "University of Oxford",
"name": "William T Clarke"
},
{
"orcid": "0000-0002-6258-1299",
"affiliation": "Aarhus Universitet, University of Oxford",
"name": "Jack J Miller"
}
],
"access_right": "open",
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
This document contains the FSL-MRS release history in reverse chronological order.

0.4.8 (Sunday 2nd October)
--------------------------
- Updated citation information with publication of NIfTI-MRS paper.
- Updated README information.
- Added check that file had been written successfully.
- Minor under the hood changes

0.4.7 (Sunday 11th September)
-----------------------------
- Add tests for previous Siemens SOP UID DICOM types from VB line scanners.
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@

A program for multi-format conversion of in vivo MRS to the [NIfTI-MRS format](https://github.com/wexeee/mrs_nifti_standard).

## About

This program was inspired by the imaging DICOM to NIfTI converter [dcm2niix](https://github.com/rordenlab/dcm2niix) developed by Chris Rorden. All MRS(I) orientations are tested with images converted using dcm2niix. I consider the combination of images converted using dcm2niix and displayed in [FSLeyes](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSLeyes) the de facto standard.

Visualisation of MRS converted by spec2nii can be carried out with a recent (>0.31.0) version of FSLeyes. A FSLeyes plugin for NIfTI-MRS is now available:
## Citing Spec2nii

If you use `spec2nii` or the [NIfTI-MRS](https://github.com/wexeee/mrs_nifti_standard) format in your work please cite:

`Clarke WT, Bell TK, Emir UE, Mikkelsen M, Oeltzschner G, Shamaei A, Soher BJ, Wilson M. NIfTI-MRS: A standard data format for magnetic resonance spectroscopy. Magn Reson Med. 2022. doi: 10.1002/mrm.29418.`

## Visualising output

Visualisation of MRS data converted by spec2nii to NIfTI-MRS can be carried out with a recent (>0.31.0) version of FSLeyes. A FSLeyes plugin for NIfTI-MRS is now available:
- [Gitlab](https://git.fmrib.ox.ac.uk/wclarke/fsleyes-plugin-mrs),
- `conda install -c conda-forge fsleyes-plugin-mrs`,
- `pip install fsleyes-plugin-mrs`.
Expand All @@ -17,7 +27,7 @@ Visualisation of MRS converted by spec2nii can be carried out with a recent (>0.
or
`pip install spec2nii`

### Installing Conda (for first option)
### Installing Conda (option #1)
Miniconda can be installed by following the instructions on the [Conda website](https://docs.conda.io/en/latest/miniconda.html). To create a suitable environment run the following three commands after installing Conda.

```
Expand Down Expand Up @@ -152,8 +162,11 @@ Overwrite the header extension in a NIfTI-MRS file using a separate json formatt
`spec2nii insert FILE JSON_FILE`

## Contributors & contributing
This program was written by Will Clarke, University of Oxford. Contributions to add new file formats or improve existing ones are very welcome. Please fork the repository and request changes using a merge (pull) request. All I ask is that test data and tests are included with any submission.
This program was written by Will Clarke, University of Oxford. Contributions to add new file formats or improve existing ones are very welcome. Please fork the repository and request changes using a merge (pull) request. I ask that test data and tests are included with any submission.

Particular thanks go to Tomáš Pšorn for contributing the Bruker interface, and to Jack Miller for the Varian interface.

Elements of the Varian reader come from [NMR glue](https://github.com/jjhelmus/nmrglue/), if you use the varian components in your research please cite J.J. Helmus, C.P. Jaroniec, Nmrglue: An open source Python package for the
analysis of multidimensional NMR data, J. Biomol. NMR 2013, 55, 355-367. doi: 10.1007/s10858-013-9718-x

Some GE test data comes from the [BIG GABA](https://www.nitrc.org/projects/biggaba/) dataset which was funded by NIH grant R01 EB016089. Please see Mikkelsen M et al. Big GABA: Edited MR spectroscopy at 24 research sites. NeuroImage 2017;159:32–45. doi: 10.1016/j.neuroimage.2017.07.021 for more information.
23 changes: 22 additions & 1 deletion spec2nii/spec2nii.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@

class spec2nii:
def __init__(self):
parser = argparse.ArgumentParser(description='Convert raw spectroscopy data to NIfTI format.')
cite_str = "Clarke WT, Bell TK, Emir UE, Mikkelsen M, Oeltzschner G, Shamaei A, Soher BJ, Wilson M. "\
"NIfTI-MRS: A standard data format for magnetic resonance spectroscopy. "\
"Magn Reson Med. 2022. doi: 10.1002/mrm.29418."
parser = argparse.ArgumentParser(
description='Convert raw spectroscopy data to NIfTI format.',
epilog=f"If you use spec2nii please cite: {cite_str}")
parser.add_argument('-v', '--version', action='version', version=spec2nii_ver)

subparsers = parser.add_subparsers(title='spec2nii subcommands')
Expand Down Expand Up @@ -279,6 +284,9 @@ def add_common_parameters(subparser):
self.implement_overrides(args)
self.validate_output()
self.write_output(args.json)
self.validate_write(args.verbose)
if args.verbose:
print(f'Please cite {cite_str}.')
elif hasattr(args, 'view') and not args.view:
print('No files to write.')

Expand Down Expand Up @@ -323,6 +331,19 @@ def write_output(self, write_json=False):
with open(out_json, 'w') as fp:
json.dump(json.loads(nifti_mrs_img.header.extensions[0].get_content()), fp, indent=4)

class NIfTIMRSWriteError(IOError):
pass

def validate_write(self, verbose):
for f_out in self.fileoutNames:
out = self.outputDir / (f_out + '.nii.gz')
if out.exists() and verbose:
print(f'Output {out.name} written to {out.parent}')
elif out.exists():
pass
else:
raise self.NIfTIMRSWriteError(f'Output {out.name} in {out.parent} not found!')

# Start of the specific format handling functions.
# Siemens twix (.dat) format
def twix(self, args):
Expand Down

0 comments on commit 23877cc

Please sign in to comment.