Skip to content

Commit

Permalink
Handle temporary bruker numpy issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtclarke committed Jan 11, 2023
1 parent 2d6f8c4 commit f57bed2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This document contains the Spec2nii release history in reverse chronological ord
- Modified repository structure. Siemens and Philips files now have dedicated directories.
- Support Python 3.11
- Enable automatic Pypi upload and move to pyproject.toml file build.
- Bruker conversion currently limited to numpy installations <1.20.0. Awaiting brukerapi package update.

0.4.9 (Friday 4th November 2022)
--------------------------------
Expand Down
15 changes: 14 additions & 1 deletion spec2nii/spec2nii.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
# There are case specific imports below


class Spec2niiError(Exception):
pass


class spec2nii:
def __init__(self):
cite_str = "Clarke WT, Bell TK, Emir UE, Mikkelsen M, Oeltzschner G, Shamaei A, Soher BJ, Wilson M. "\
Expand Down Expand Up @@ -521,7 +525,16 @@ def raw(self, args):
# Bruker 2dseq files with FG_COMPLEX
def bruker(self, args):
from spec2nii.bruker import read_bruker
self.imageOut, self.fileoutNames = read_bruker(args)
from warnings import warn
from brukerapi.exceptions import MissingProperty
warn('Bruker conversion must currently be run with numpy<1.20.0')

try:
self.imageOut, self.fileoutNames = read_bruker(args)
except MissingProperty:
raise Spec2niiError(
'Bruker conversion must currently be run with numpy<1.20.0. '
'The underlying brukerapi package requires updating for ongoing compatibility.')

# Varian parser
def varian(self, args):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_bruker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import json

import numpy as np
import pytest

from .io_for_tests import read_nifti_mrs

Expand All @@ -17,6 +18,7 @@
data_path = bruker_path / '20201208_105201_lego_rod_1_3'


@pytest.mark.skip(reason="Awaiting fix of brukerapi package")
def test_fid(tmp_path):

subprocess.check_call(['spec2nii', 'bruker',
Expand Down Expand Up @@ -94,6 +96,7 @@ def test_fid(tmp_path):
assert 'acqp' in hdr_ext


@pytest.mark.skip(reason="Awaiting fix of brukerapi package")
def test_2dseq(tmp_path):

subprocess.check_call(['spec2nii', 'bruker',
Expand Down

0 comments on commit f57bed2

Please sign in to comment.