Commit 73fb2827 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rf/wsl-popen' into 'master'

Adjust fsl.utils.run.run to workaround Windows issue

See merge request fsl/fslpy!272
parents 57348825 1524145f
...@@ -173,6 +173,12 @@ test:3.8: ...@@ -173,6 +173,12 @@ test:3.8:
<<: *test_template <<: *test_template
test:3.9:
stage: test
image: pauldmccarthy/fsleyes-py39-wxpy4-gtk3
<<: *test_template
test:build-pypi-dist: test:build-pypi-dist:
stage: test stage: test
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3 image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3
......
...@@ -2,6 +2,29 @@ This document contains the ``fslpy`` release history in reverse chronological ...@@ -2,6 +2,29 @@ This document contains the ``fslpy`` release history in reverse chronological
order. order.
3.5.0 (Tuesday 19th January 2021)
---------------------------------
Added
^^^^^
* New ``fsl_anat.tree``, for use with the :mod:`.filetree` package (!264).
* New :func:`.fsl_prepare_fieldmap` wrapper function (!265).
* The :class:`.fslmaths` wrapper now supports the ``fslmaths -s`` option
via the :meth:`.fslmaths.smooth` method (!271).
Fixed
^^^^^
* Windows/WSL-specific workaround to the :func:`fsl.utils.run.run` function to
avoid console windows from popping up, when used from a graphical program
(!272).
3.4.0 (Tuesday 20th October 2020) 3.4.0 (Tuesday 20th October 2020)
--------------------------------- ---------------------------------
......
Copyright 2016-2020 University of Oxford, Oxford, UK Copyright 2016-2021 University of Oxford, Oxford, UK
The fslpy library The fslpy library
Copyright 2016-2020 University of Oxford, Oxford, UK. Copyright 2016-2021 University of Oxford, Oxford, UK.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -19,7 +19,7 @@ programming library written in Python. It is used by `FSLeyes ...@@ -19,7 +19,7 @@ programming library written in Python. It is used by `FSLeyes
<https://git.fmrib.ox.ac.uk/fsl/fsleyes/fsleyes/>`_. <https://git.fmrib.ox.ac.uk/fsl/fsleyes/fsleyes/>`_.
``fslpy`` is tested against Python versions 3.5, 3.6 and 3.7. ``fslpy`` is tested against Python versions 3.6, 3.7, 3.8 and 3.9.
Installation Installation
......
...@@ -286,6 +286,12 @@ def _realrun(tee, logStdout, logStderr, logCmd, *args, **kwargs): ...@@ -286,6 +286,12 @@ def _realrun(tee, logStdout, logStderr, logCmd, *args, **kwargs):
- the command's standard error as a string. - the command's standard error as a string.
- the command's exit code. - the command's exit code.
""" """
if fslplatform.fslwsl:
# On Windows this prevents opening of a popup window
startupinfo = sp.STARTUPINFO()
startupinfo.dwFlags |= sp.STARTF_USESHOWWINDOW
kwargs["startupinfo"] = startupinfo
proc = sp.Popen(args, stdout=sp.PIPE, stderr=sp.PIPE, **kwargs) proc = sp.Popen(args, stdout=sp.PIPE, stderr=sp.PIPE, **kwargs)
with tempdir.tempdir(changeto=False) as td: with tempdir.tempdir(changeto=False) as td:
...@@ -403,7 +409,7 @@ def wslcmd(cmdpath, *args): ...@@ -403,7 +409,7 @@ def wslcmd(cmdpath, *args):
# Check if command exists in WSL (remembering that the command path may include FSLDIR which # Check if command exists in WSL (remembering that the command path may include FSLDIR which
# is a Windows path) # is a Windows path)
cmdpath = fslpath.wslpath(cmdpath) cmdpath = fslpath.wslpath(cmdpath)
retcode = sp.call(["wsl", "test", "-x", cmdpath]) _stdout, _stderr, retcode = _realrun(False, None, None, None, "wsl", "test", "-x", cmdpath)
if retcode == 0: if retcode == 0:
# Form a new argument list and convert any Windows paths in it into WSL paths # Form a new argument list and convert any Windows paths in it into WSL paths
wslargs = [fslpath.wslpath(arg) for arg in args] wslargs = [fslpath.wslpath(arg) for arg in args]
......
...@@ -47,7 +47,7 @@ import re ...@@ -47,7 +47,7 @@ import re
import string import string
__version__ = '3.5.0.dev0' __version__ = '3.6.0.dev0'
"""Current version number, as a string. """ """Current version number, as a string. """
......
...@@ -29,10 +29,10 @@ pytestmark = pytest.mark.dicomtest ...@@ -29,10 +29,10 @@ pytestmark = pytest.mark.dicomtest
@contextlib.contextmanager @contextlib.contextmanager
def install_dcm2niix(version='1.0.20190902'): def install_dcm2niix(version='1.0.20201102'):
filenames = { filenames = {
'1.0.20201102' : 'v1.0.20201102/dcm2niix_lnx.zip',
'1.0.20190902' : 'v1.0.20190902/dcm2niix_lnx.zip', '1.0.20190902' : 'v1.0.20190902/dcm2niix_lnx.zip',
'1.0.20190410' : 'v1.0.20190410/dcm2niix_11-Apr-2019_lnx.zip',
'1.0.20181125' : 'v1.0.20181125/dcm2niix_25-Nov-2018_lnx.zip', '1.0.20181125' : 'v1.0.20181125/dcm2niix_25-Nov-2018_lnx.zip',
'1.0.20171017' : 'v1.0.20171017/dcm2niix_18-Oct-2017_lnx.zip', '1.0.20171017' : 'v1.0.20171017/dcm2niix_18-Oct-2017_lnx.zip',
} }
...@@ -128,8 +128,9 @@ def test_scanDir(): ...@@ -128,8 +128,9 @@ def test_scanDir():
assert len(series) == 2 assert len(series) == 2
for s in series: for s in series:
assert (s['PatientName'] == 'MCCARTHY_PAUL' or assert s['PatientName'] in ('MCCARTHY_PAUL',
s['PatientName'] == 'MCCARTHY_PAUL_2') 'MCCARTHY^PAUL',
'MCCARTHY_PAUL_2')
def test_sersiesCRC(): def test_sersiesCRC():
...@@ -158,7 +159,7 @@ def test_sersiesCRC(): ...@@ -158,7 +159,7 @@ def test_sersiesCRC():
def test_loadSeries(): def test_loadSeries():
# test a pre-CRC and a post-CRC version # test a pre-CRC and a post-CRC version
for version in ('1.0.20190410', '1.0.20190902'): for version in ('1.0.20181125', '1.0.20201102'):
with install_dcm2niix(version): with install_dcm2niix(version):
...@@ -170,23 +171,23 @@ def test_loadSeries(): ...@@ -170,23 +171,23 @@ def test_loadSeries():
dcmdir = os.getcwd() dcmdir = os.getcwd()
series = fsldcm.scanDir(dcmdir) series = fsldcm.scanDir(dcmdir)
expShape = (512, 512, 1) expShape = (512, 512, 1)
explens = [1, 1]
for s, explen in zip(series, explens): for s in series:
imgs = fsldcm.loadSeries(s) imgs = fsldcm.loadSeries(s)
assert len(imgs) == explen
for img in imgs: for img in imgs:
assert img.dicomDir == dcmdir assert img.dicomDir == dcmdir
assert img.shape == expShape assert img.shape == expShape
assert img[:].shape == expShape assert img[:].shape == expShape
assert img.getMeta('PatientName') == 'MCCARTHY_PAUL' or \ assert img.getMeta('PatientName') in ('MCCARTHY_PAUL',
img.getMeta('PatientName') == 'MCCARTHY_PAUL_2' 'MCCARTHY^PAUL',
'MCCARTHY_PAUL_2')
assert 'PatientName' in img.metaKeys() assert 'PatientName' in img.metaKeys()
assert 'MCCARTHY_PAUL' in img.metaValues() or \ assert 'MCCARTHY_PAUL' in img.metaValues() or \
'MCCARTHY^PAUL' in img.metaValues() or \
'MCCARTHY_PAUL_2' in img.metaValues() 'MCCARTHY_PAUL_2' in img.metaValues()
assert ('PatientName', 'MCCARTHY_PAUL') in img.metaItems() or \ assert ('PatientName', 'MCCARTHY_PAUL') in img.metaItems() or \
('PatientName', 'MCCARTHY^PAUL') in img.metaItems() or \
('PatientName', 'MCCARTHY_PAUL_2') in img.metaItems() ('PatientName', 'MCCARTHY_PAUL_2') in img.metaItems()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment