diff --git a/.ci/setup_ssh.sh b/.ci/setup_ssh.sh index e42264cd3032439b52363e2448937c5e928240c4..40c0c5c1ef96d9633aac885f0ba0bba4c1168ca3 100644 --- a/.ci/setup_ssh.sh +++ b/.ci/setup_ssh.sh @@ -31,9 +31,7 @@ if [[ -f /.dockerenv ]]; then echo "$SSH_PRIVATE_KEY_FSL_DOWNLOAD" > $HOME/.ssh/id_fsl_download; if [[ "$CI_PROJECT_PATH" == "$UPSTREAM_PROJECT" ]]; then - echo "$SSH_PRIVATE_KEY_DOC_DEPLOY" > $HOME/.ssh/id_doc_deploy; - echo "$SSH_PRIVATE_KEY_CONDA_DEPLOY" > $HOME/.ssh/id_conda_deploy; - echo "$SSH_PRIVATE_KEY_CONDA_INDEX" > $HOME/.ssh/id_conda_index; + echo "$SSH_PRIVATE_KEY_DOC_DEPLOY" > $HOME/.ssh/id_doc_deploy; fi; chmod go-rwx $HOME/.ssh/id_*; @@ -43,10 +41,11 @@ if [[ -f /.dockerenv ]]; then if [[ "$CI_PROJECT_PATH" == "$UPSTREAM_PROJECT" ]]; then ssh-add $HOME/.ssh/id_doc_deploy; - ssh-add $HOME/.ssh/id_conda_deploy; fi - echo "$SSH_SERVER_HOSTKEYS" > $HOME/.ssh/known_hosts; + ssh-keyscan ${UPSTREAM_URL##*@} >> $HOME/.ssh/known_hosts; + ssh-keyscan ${DOC_HOST##*@} >> $HOME/.ssh/known_hosts; + ssh-keyscan ${FSL_HOST##*@} >> $HOME/.ssh/known_hosts; touch $HOME/.ssh/config; @@ -59,16 +58,6 @@ if [[ -f /.dockerenv ]]; then echo " User ${DOC_HOST%@*}" >> $HOME/.ssh/config; echo " IdentityFile $HOME/.ssh/id_doc_deploy" >> $HOME/.ssh/config; - echo "Host condadeploy" >> $HOME/.ssh/config; - echo " HostName ${CONDA_HOST##*@}" >> $HOME/.ssh/config; - echo " User ${CONDA_HOST%@*}" >> $HOME/.ssh/config; - echo " IdentityFile $HOME/.ssh/id_conda_deploy" >> $HOME/.ssh/config; - - echo "Host condaindex" >> $HOME/.ssh/config; - echo " HostName ${CONDA_HOST##*@}" >> $HOME/.ssh/config; - echo " User ${CONDA_HOST%@*}" >> $HOME/.ssh/config; - echo " IdentityFile $HOME/.ssh/id_conda_index" >> $HOME/.ssh/config; - echo "Host fsldownload" >> $HOME/.ssh/config; echo " HostName ${FSL_HOST##*@}" >> $HOME/.ssh/config; echo " User ${FSL_HOST%@*}" >> $HOME/.ssh/config; diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2dc4299e7cc1a14d6cdc9072eb88e6006e87ddf6..40b0b8b68c63059f829d6cced064835b21180f85 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,26 @@ This document contains the ``fslpy`` release history in reverse chronological order. +1.12.0 (Under development) +-------------------------- + + +Changed +^^^^^^^ + + +* The ``extract_noise`` script has been renamed to :mod:`.fsl_ents`. +* Increased the minimum required version of ``dcm2niix`` in the + :mod:`fsl.data.dicom` module. + + +Deprecated +^^^^^^^^^^ + + +* The ``extract_noise`` script. + + 1.11.1 (Friday September 14th 2018 ---------------------------------- diff --git a/doc/fsl.scripts.fsl_ents.rst b/doc/fsl.scripts.fsl_ents.rst new file mode 100644 index 0000000000000000000000000000000000000000..373fc83b1ba94e0a6a34a318a7fefc199ef9bb29 --- /dev/null +++ b/doc/fsl.scripts.fsl_ents.rst @@ -0,0 +1,7 @@ +``fsl.scripts.fsl_ents`` +======================== + +.. automodule:: fsl.scripts.fsl_ents + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/fsl.scripts.rst b/doc/fsl.scripts.rst index 91dff4d9f3a0fca1ccd848b1255e2c8e50fb608e..2d18375d7aba2f04189ed4347cdac76c94c5358d 100644 --- a/doc/fsl.scripts.rst +++ b/doc/fsl.scripts.rst @@ -5,6 +5,7 @@ :hidden: fsl.scripts.atlasq + fsl.scripts.fsl_ents fsl.scripts.imcp fsl.scripts.imglob fsl.scripts.immv diff --git a/fsl/data/dicom.py b/fsl/data/dicom.py index 57e0a227da55527e36f3166a81379ee57fd9b72e..53b7edefe067583d0ea94aaddcc4024b5faa663e 100644 --- a/fsl/data/dicom.py +++ b/fsl/data/dicom.py @@ -44,6 +44,10 @@ import fsl.data.image as fslimage log = logging.getLogger(__name__) +MIN_DCM2NIIX_VERSION = (1, 0, 2017, 12, 15) +"""Minimum version of dcm2niix that is required for this module to work. """ + + class DicomImage(fslimage.Image): """The ``DicomImage`` is a volumetric :class:`.Image` with some associated DICOM metadata. @@ -115,13 +119,12 @@ def enabled(): """ cmd = 'dcm2niix -h' - minimumVersion = (1, 0, 2016, 9, 30) - versionPattern = re.compile('v' - '(?P<major>[0-9]+)\.' - '(?P<minor>[0-9]+)\.' - '(?P<year>[0-9]{4})' - '(?P<month>[0-9]{2})' - '(?P<day>[0-9]{2})') + versionPattern = re.compile(r'v' + r'(?P<major>[0-9]+)\.' + r'(?P<minor>[0-9]+)\.' + r'(?P<year>[0-9]{4})' + r'(?P<month>[0-9]{2})' + r'(?P<day>[0-9]{2})') try: output = sp.check_output(cmd.split()).decode() @@ -145,7 +148,7 @@ def enabled(): # make sure installed version # is equal to or newer than # minimum required version - for iv, mv in zip(installedVersion, minimumVersion): + for iv, mv in zip(installedVersion, MIN_DCM2NIIX_VERSION): if iv > mv: return True elif iv < mv: return False @@ -225,7 +228,7 @@ def loadSeries(series): dcmdir = series['DicomDir'] snum = series['SeriesNumber'] desc = series['SeriesDescription'] - cmd = 'dcm2niix -b n -f %s -z n -o . {}'.format(dcmdir) + cmd = 'dcm2niix -b n -f %s -z n -o . -n {} {}'.format(snum, dcmdir) with tempdir.tempdir() as td: diff --git a/fsl/data/dtifit.py b/fsl/data/dtifit.py index a2c36fb332661f4f030b8f0c907b6b08fdf8bf04..34948669865a86209fffb1d8851ba867f99f7d46 100644 --- a/fsl/data/dtifit.py +++ b/fsl/data/dtifit.py @@ -50,7 +50,7 @@ def getDTIFitDataPrefix(path): # Gather all of the existing file # prefixes into a dictionary of # prefix : [file list] mappings. - pattern = '^(.*)_(?:V1|V2|V3|L1|L2|L3).*$' + pattern = r'^(.*)_(?:V1|V2|V3|L1|L2|L3).*$' prefixes = {} for f in [f for flist in files for f in flist]: diff --git a/fsl/scripts/extract_noise.py b/fsl/scripts/extract_noise.py new file mode 100644 index 0000000000000000000000000000000000000000..68c10c605c2531f3630c6554c2e876e46ef15fd9 --- /dev/null +++ b/fsl/scripts/extract_noise.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# +# extract_noise.py - Deprecated - replaced by fsl_ents.py +# +# Author: Paul McCarthy <pauldmccarthy@gmail.com> +# +"""This module is deprecated - it has been replaced by :mod:`.fsl_ents`. """ + + +import sys + + +if __name__ == '__main__': + print('extract_noise is deprecated and will be removed in fslpy 2.0. ' + 'Use fsl_ents instead.') + from fsl.scripts.fsl_ents import main + sys.exit(main()) diff --git a/fsl/version.py b/fsl/version.py index 095ab8c41912ec89d5527c4977ea7375a400c895..d9f53ecd2bb4ef133db868b24045842403ea1464 100644 --- a/fsl/version.py +++ b/fsl/version.py @@ -130,7 +130,7 @@ def patchVersion(filename, newversion): with open(filename, 'rt') as f: lines = f.readlines() - pattern = re.compile('^__version__ *= *\'.*\' *$') + pattern = re.compile(r'^__version__ *= *\'.*\' *$') for i, line in enumerate(lines): if pattern.match(line): diff --git a/tests/test_dicom.py b/tests/test_dicom.py index 325a15b4a8cc94b172998e8712a4d87318a8b100..70b5117bc20019249f15cb6298b2ab45c95c222c 100644 --- a/tests/test_dicom.py +++ b/tests/test_dicom.py @@ -47,9 +47,13 @@ def test_enabled(): side_effect=Exception()): assert not fsldcm.enabled() + # test presence of different versions tests = [(b'version v2.1.20191212', True), - (b'version v1.0.20160930', True), + (b'version v1.0.20171216', True), + (b'version v1.0.20171215', True), + (b'version v1.0.20171214', False), + (b'version v1.0.20160930', False), (b'version v1.0.20160929', False), (b'version v0.0.00000000', False), (b'version blurgh', False)] @@ -76,7 +80,7 @@ def test_scanDir(): f.extractall() series = fsldcm.scanDir(td) - assert len(series) == 2 + assert len(series) == 3 for s in series: assert (s['PatientName'] == 'MCCARTHY_PAUL' or @@ -104,13 +108,13 @@ def test_loadSeries(): for img in imgs: - assert img.dicomDir == td - assert img.shape == expShape - assert img[:].shape == expShape - assert img.get('PatientName') == 'MCCARTHY_PAUL' or \ - img.get('PatientName') == 'MCCARTHY_PAUL_2' - assert 'PatientName' in img.keys() - assert 'MCCARTHY_PAUL' in img.values() or \ - 'MCCARTHY_PAUL_2' in img.values() - assert ('PatientName', 'MCCARTHY_PAUL') in img.items() or \ - ('PatientName', 'MCCARTHY_PAUL_2') in img.items() + assert img.dicomDir == td + assert img.shape == expShape + assert img[:].shape == expShape + assert img.getMeta('PatientName') == 'MCCARTHY_PAUL' or \ + img.getMeta('PatientName') == 'MCCARTHY_PAUL_2' + assert 'PatientName' in img.metaKeys() + assert 'MCCARTHY_PAUL' in img.metaValues() or \ + 'MCCARTHY_PAUL_2' in img.metaValues() + assert ('PatientName', 'MCCARTHY_PAUL') in img.metaItems() or \ + ('PatientName', 'MCCARTHY_PAUL_2') in img.metaItems()