Skip to content
Snippets Groups Projects
Commit 73fb2827 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
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
No related branches found
No related tags found
No related merge requests found
......@@ -173,6 +173,12 @@ test:3.8:
<<: *test_template
test:3.9:
stage: test
image: pauldmccarthy/fsleyes-py39-wxpy4-gtk3
<<: *test_template
test:build-pypi-dist:
stage: test
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3
......
......@@ -2,6 +2,29 @@ This document contains the ``fslpy`` release history in reverse chronological
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)
---------------------------------
......
Copyright 2016-2020 University of Oxford, Oxford, UK
Copyright 2016-2021 University of Oxford, Oxford, UK
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");
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
<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
......
......@@ -286,6 +286,12 @@ def _realrun(tee, logStdout, logStderr, logCmd, *args, **kwargs):
- the command's standard error as a string.
- 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)
with tempdir.tempdir(changeto=False) as td:
......@@ -403,7 +409,7 @@ def wslcmd(cmdpath, *args):
# Check if command exists in WSL (remembering that the command path may include FSLDIR which
# is a Windows path)
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:
# Form a new argument list and convert any Windows paths in it into WSL paths
wslargs = [fslpath.wslpath(arg) for arg in args]
......
......@@ -47,7 +47,7 @@ import re
import string
__version__ = '3.5.0.dev0'
__version__ = '3.6.0.dev0'
"""Current version number, as a string. """
......
......@@ -29,10 +29,10 @@ pytestmark = pytest.mark.dicomtest
@contextlib.contextmanager
def install_dcm2niix(version='1.0.20190902'):
def install_dcm2niix(version='1.0.20201102'):
filenames = {
'1.0.20201102' : 'v1.0.20201102/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.20171017' : 'v1.0.20171017/dcm2niix_18-Oct-2017_lnx.zip',
}
......@@ -128,8 +128,9 @@ def test_scanDir():
assert len(series) == 2
for s in series:
assert (s['PatientName'] == 'MCCARTHY_PAUL' or
s['PatientName'] == 'MCCARTHY_PAUL_2')
assert s['PatientName'] in ('MCCARTHY_PAUL',
'MCCARTHY^PAUL',
'MCCARTHY_PAUL_2')
def test_sersiesCRC():
......@@ -158,7 +159,7 @@ def test_sersiesCRC():
def test_loadSeries():
# 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):
......@@ -170,23 +171,23 @@ def test_loadSeries():
dcmdir = os.getcwd()
series = fsldcm.scanDir(dcmdir)
expShape = (512, 512, 1)
explens = [1, 1]
for s, explen in zip(series, explens):
for s in series:
imgs = fsldcm.loadSeries(s)
assert len(imgs) == explen
for img in imgs:
assert img.dicomDir == dcmdir
assert img.shape == expShape
assert img[:].shape == expShape
assert img.getMeta('PatientName') == 'MCCARTHY_PAUL' or \
img.getMeta('PatientName') == 'MCCARTHY_PAUL_2'
assert img.getMeta('PatientName') in ('MCCARTHY_PAUL',
'MCCARTHY^PAUL',
'MCCARTHY_PAUL_2')
assert 'PatientName' in img.metaKeys()
assert 'MCCARTHY_PAUL' in img.metaValues() or \
'MCCARTHY^PAUL' in img.metaValues() or \
'MCCARTHY_PAUL_2' in img.metaValues()
assert ('PatientName', 'MCCARTHY_PAUL') in img.metaItems() or \
('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