Skip to content
Snippets Groups Projects
Commit fce35163 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Merge branch 'mnt/fsl_ents' into 'master'

Mnt/fsl ents

See merge request fsl/fslpy!73
parents 0384e0b4 3ac03b0c
No related branches found
No related tags found
No related merge requests found
...@@ -31,9 +31,7 @@ if [[ -f /.dockerenv ]]; then ...@@ -31,9 +31,7 @@ if [[ -f /.dockerenv ]]; then
echo "$SSH_PRIVATE_KEY_FSL_DOWNLOAD" > $HOME/.ssh/id_fsl_download; echo "$SSH_PRIVATE_KEY_FSL_DOWNLOAD" > $HOME/.ssh/id_fsl_download;
if [[ "$CI_PROJECT_PATH" == "$UPSTREAM_PROJECT" ]]; then if [[ "$CI_PROJECT_PATH" == "$UPSTREAM_PROJECT" ]]; then
echo "$SSH_PRIVATE_KEY_DOC_DEPLOY" > $HOME/.ssh/id_doc_deploy; 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;
fi; fi;
chmod go-rwx $HOME/.ssh/id_*; chmod go-rwx $HOME/.ssh/id_*;
...@@ -43,10 +41,11 @@ if [[ -f /.dockerenv ]]; then ...@@ -43,10 +41,11 @@ if [[ -f /.dockerenv ]]; then
if [[ "$CI_PROJECT_PATH" == "$UPSTREAM_PROJECT" ]]; then if [[ "$CI_PROJECT_PATH" == "$UPSTREAM_PROJECT" ]]; then
ssh-add $HOME/.ssh/id_doc_deploy; ssh-add $HOME/.ssh/id_doc_deploy;
ssh-add $HOME/.ssh/id_conda_deploy;
fi 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; touch $HOME/.ssh/config;
...@@ -59,16 +58,6 @@ if [[ -f /.dockerenv ]]; then ...@@ -59,16 +58,6 @@ if [[ -f /.dockerenv ]]; then
echo " User ${DOC_HOST%@*}" >> $HOME/.ssh/config; echo " User ${DOC_HOST%@*}" >> $HOME/.ssh/config;
echo " IdentityFile $HOME/.ssh/id_doc_deploy" >> $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 "Host fsldownload" >> $HOME/.ssh/config;
echo " HostName ${FSL_HOST##*@}" >> $HOME/.ssh/config; echo " HostName ${FSL_HOST##*@}" >> $HOME/.ssh/config;
echo " User ${FSL_HOST%@*}" >> $HOME/.ssh/config; echo " User ${FSL_HOST%@*}" >> $HOME/.ssh/config;
......
...@@ -2,6 +2,26 @@ This document contains the ``fslpy`` release history in reverse chronological ...@@ -2,6 +2,26 @@ This document contains the ``fslpy`` release history in reverse chronological
order. 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 1.11.1 (Friday September 14th 2018
---------------------------------- ----------------------------------
......
``fsl.scripts.fsl_ents``
========================
.. automodule:: fsl.scripts.fsl_ents
:members:
:undoc-members:
:show-inheritance:
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:hidden: :hidden:
fsl.scripts.atlasq fsl.scripts.atlasq
fsl.scripts.fsl_ents
fsl.scripts.imcp fsl.scripts.imcp
fsl.scripts.imglob fsl.scripts.imglob
fsl.scripts.immv fsl.scripts.immv
......
...@@ -44,6 +44,10 @@ import fsl.data.image as fslimage ...@@ -44,6 +44,10 @@ import fsl.data.image as fslimage
log = logging.getLogger(__name__) 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): class DicomImage(fslimage.Image):
"""The ``DicomImage`` is a volumetric :class:`.Image` with some associated """The ``DicomImage`` is a volumetric :class:`.Image` with some associated
DICOM metadata. DICOM metadata.
...@@ -115,13 +119,12 @@ def enabled(): ...@@ -115,13 +119,12 @@ def enabled():
""" """
cmd = 'dcm2niix -h' cmd = 'dcm2niix -h'
minimumVersion = (1, 0, 2016, 9, 30) versionPattern = re.compile(r'v'
versionPattern = re.compile('v' r'(?P<major>[0-9]+)\.'
'(?P<major>[0-9]+)\.' r'(?P<minor>[0-9]+)\.'
'(?P<minor>[0-9]+)\.' r'(?P<year>[0-9]{4})'
'(?P<year>[0-9]{4})' r'(?P<month>[0-9]{2})'
'(?P<month>[0-9]{2})' r'(?P<day>[0-9]{2})')
'(?P<day>[0-9]{2})')
try: try:
output = sp.check_output(cmd.split()).decode() output = sp.check_output(cmd.split()).decode()
...@@ -145,7 +148,7 @@ def enabled(): ...@@ -145,7 +148,7 @@ def enabled():
# make sure installed version # make sure installed version
# is equal to or newer than # is equal to or newer than
# minimum required version # minimum required version
for iv, mv in zip(installedVersion, minimumVersion): for iv, mv in zip(installedVersion, MIN_DCM2NIIX_VERSION):
if iv > mv: return True if iv > mv: return True
elif iv < mv: return False elif iv < mv: return False
...@@ -225,7 +228,7 @@ def loadSeries(series): ...@@ -225,7 +228,7 @@ def loadSeries(series):
dcmdir = series['DicomDir'] dcmdir = series['DicomDir']
snum = series['SeriesNumber'] snum = series['SeriesNumber']
desc = series['SeriesDescription'] 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: with tempdir.tempdir() as td:
......
...@@ -50,7 +50,7 @@ def getDTIFitDataPrefix(path): ...@@ -50,7 +50,7 @@ def getDTIFitDataPrefix(path):
# Gather all of the existing file # Gather all of the existing file
# prefixes into a dictionary of # prefixes into a dictionary of
# prefix : [file list] mappings. # prefix : [file list] mappings.
pattern = '^(.*)_(?:V1|V2|V3|L1|L2|L3).*$' pattern = r'^(.*)_(?:V1|V2|V3|L1|L2|L3).*$'
prefixes = {} prefixes = {}
for f in [f for flist in files for f in flist]: for f in [f for flist in files for f in flist]:
......
#!/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())
...@@ -130,7 +130,7 @@ def patchVersion(filename, newversion): ...@@ -130,7 +130,7 @@ def patchVersion(filename, newversion):
with open(filename, 'rt') as f: with open(filename, 'rt') as f:
lines = f.readlines() lines = f.readlines()
pattern = re.compile('^__version__ *= *\'.*\' *$') pattern = re.compile(r'^__version__ *= *\'.*\' *$')
for i, line in enumerate(lines): for i, line in enumerate(lines):
if pattern.match(line): if pattern.match(line):
......
...@@ -47,9 +47,13 @@ def test_enabled(): ...@@ -47,9 +47,13 @@ def test_enabled():
side_effect=Exception()): side_effect=Exception()):
assert not fsldcm.enabled() assert not fsldcm.enabled()
# test presence of different versions # test presence of different versions
tests = [(b'version v2.1.20191212', True), 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 v1.0.20160929', False),
(b'version v0.0.00000000', False), (b'version v0.0.00000000', False),
(b'version blurgh', False)] (b'version blurgh', False)]
...@@ -76,7 +80,7 @@ def test_scanDir(): ...@@ -76,7 +80,7 @@ def test_scanDir():
f.extractall() f.extractall()
series = fsldcm.scanDir(td) series = fsldcm.scanDir(td)
assert len(series) == 2 assert len(series) == 3
for s in series: for s in series:
assert (s['PatientName'] == 'MCCARTHY_PAUL' or assert (s['PatientName'] == 'MCCARTHY_PAUL' or
...@@ -104,13 +108,13 @@ def test_loadSeries(): ...@@ -104,13 +108,13 @@ def test_loadSeries():
for img in imgs: for img in imgs:
assert img.dicomDir == td assert img.dicomDir == td
assert img.shape == expShape assert img.shape == expShape
assert img[:].shape == expShape assert img[:].shape == expShape
assert img.get('PatientName') == 'MCCARTHY_PAUL' or \ assert img.getMeta('PatientName') == 'MCCARTHY_PAUL' or \
img.get('PatientName') == 'MCCARTHY_PAUL_2' img.getMeta('PatientName') == 'MCCARTHY_PAUL_2'
assert 'PatientName' in img.keys() assert 'PatientName' in img.metaKeys()
assert 'MCCARTHY_PAUL' in img.values() or \ assert 'MCCARTHY_PAUL' in img.metaValues() or \
'MCCARTHY_PAUL_2' in img.values() 'MCCARTHY_PAUL_2' in img.metaValues()
assert ('PatientName', 'MCCARTHY_PAUL') in img.items() or \ assert ('PatientName', 'MCCARTHY_PAUL') in img.metaItems() or \
('PatientName', 'MCCARTHY_PAUL_2') in img.items() ('PatientName', 'MCCARTHY_PAUL_2') in img.metaItems()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment