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
Pipeline #2802 canceled
......@@ -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;
......
......@@ -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
----------------------------------
......
``fsl.scripts.fsl_ents``
========================
.. automodule:: fsl.scripts.fsl_ents
:members:
:undoc-members:
:show-inheritance:
......@@ -5,6 +5,7 @@
:hidden:
fsl.scripts.atlasq
fsl.scripts.fsl_ents
fsl.scripts.imcp
fsl.scripts.imglob
fsl.scripts.immv
......
......@@ -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:
......
......@@ -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]:
......
#!/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):
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):
......
......@@ -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()
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