Skip to content

REL: 2.3.1 #667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 168 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
328d3bb
RF: moved all the functionality from nib-ls under nibabel.cmdline
yarikoptic Nov 3, 2017
d293a20
ENH: added a skeleton for nib-diff command
yarikoptic Nov 3, 2017
5491af4
TODO1 attempt 1: processed data type, data shape, and data offset of …
chrispycheng Nov 6, 2017
949762c
tweaked to remove AnalyzeHeader but currently still has problems
chrispycheng Nov 16, 2017
93b5e09
added nib-diff to setup.py
chrispycheng Nov 17, 2017
22804f1
first attempt at nib-diff that doesnt work
chrispycheng Nov 17, 2017
f81a78b
removed incorrectly committed changes
chrispycheng Nov 17, 2017
fe9c052
BK: stab at the test_dict_diff
yarikoptic Nov 17, 2017
5eb4477
first attempt at diff_dicts method and diff testing file
chrispycheng Nov 28, 2017
e2defb0
Merge branch 'nf-nib-diff' of https://github.com/yarikoptic/nibabel i…
chrispycheng Nov 28, 2017
5e3a767
tried something else with header fields
chrispycheng Nov 30, 2017
7febf65
latest attempt: restructured diff_dicts() method, troubleshooting ens…
chrispycheng Nov 30, 2017
23a43ba
corrected misplacement of cmdline files and latest attempt at diff_di…
chrispycheng Dec 1, 2017
fae491d
progress! tweaked bugs, corrected rookie mistakes like cmdline placem…
chrispycheng Dec 1, 2017
3e87d81
got rid of proc file and function works at a basic level
chrispycheng Dec 2, 2017
a3b35d9
tweaked diff_dicts to be compatible with tests
chrispycheng Dec 3, 2017
1491c61
got rid of None, troubleshot tests
chrispycheng Dec 9, 2017
397bc03
introduced hypothesis to use for testing with pretty sexy results
chrispycheng Dec 15, 2017
f192f65
noted hypothesis need for tests, refactored diff_dicts name
chrispycheng Dec 16, 2017
92553a2
attempt at TODO#2: allowing specification of header fields
chrispycheng Dec 18, 2017
7a70d56
now functional for several header files.
chrispycheng Dec 21, 2017
f5e930d
tweak to make hypothesis work with a list, but problem above has not …
chrispycheng Dec 23, 2017
df82a51
tweaked names and code as suggested!
chrispycheng Dec 24, 2017
6d706f5
bug fix
chrispycheng Dec 27, 2017
774ce3b
cosmetic tweaks
chrispycheng Jan 5, 2018
911d781
cleaned up code
chrispycheng Jan 7, 2018
0458694
promoted generic programming and got test to work again
chrispycheng Jan 13, 2018
fed70e9
tried to clean code but couldnt get comprehension going
chrispycheng Jan 13, 2018
0b59dfb
comment and docstring
chrispycheng Jan 15, 2018
2920abf
added options for text, json, yaml but still have to implement
chrispycheng Jan 21, 2018
1e57409
work in progress with all outputs
chrispycheng Feb 3, 2018
fd6c474
simplified code but now bizarrely doesnt run with two files
chrispycheng Mar 14, 2018
497ad2a
beautified text output, next up json and yaml
chrispycheng Mar 16, 2018
df0aa79
modified the tests for the new diff_values
chrispycheng Mar 17, 2018
c23143c
commenting out json and yaml, cosmetic mod to ls.py
chrispycheng Mar 18, 2018
db16d85
BF: all those flags are just boolean flags and no need to repeat thei…
yarikoptic Mar 26, 2018
feca439
progress towards table formatting
chrispycheng Mar 29, 2018
acf667b
table now works and looks p good
chrispycheng Mar 29, 2018
bb3fbf0
slight tweak to table formatting
chrispycheng Mar 29, 2018
8a92010
very inefficient but successfully removed dtype when its identical
chrispycheng Apr 4, 2018
a9a572a
removed extra blank line lol
chrispycheng Apr 5, 2018
3290a66
boosting coverage
chrispycheng Apr 5, 2018
92e4ed0
Merge remote-tracking branch 'nibabel/master' into nf-nib-diff
chrispycheng Apr 5, 2018
06e8dd7
data comparison function added
chrispycheng Apr 12, 2018
8fd6995
implemented test-nib-diff
chrispycheng Apr 24, 2018
df8bc04
added another test
chrispycheng Apr 25, 2018
45d3fbf
changed travis appveyor utils per test errors
chrispycheng Apr 25, 2018
1cbf5b3
test files
chrispycheng Apr 26, 2018
45bdf64
wasnt included in last commit by accident
chrispycheng Apr 26, 2018
c600746
maybe this will work instead
chrispycheng Apr 26, 2018
e26adb5
maybe this will work instead
chrispycheng Apr 26, 2018
3802919
test fixed
chrispycheng May 5, 2018
0ce86df
Merge branch 'nf-nib-diff' of https://github.com/yarikoptic/nibabel i…
chrispycheng May 5, 2018
72bc800
fixed to be more generic
chrispycheng May 6, 2018
0cf2a8c
fixed file name issue in nib diff
chrispycheng May 24, 2018
5db2654
fixed changes as yarik requested
chrispycheng May 24, 2018
50a480e
fixed problems noted by Travis CI
chrispycheng May 31, 2018
9e155df
building in difflib to see whats going on
chrispycheng May 31, 2018
3c0c90c
Merge branch 'master' into nf-nib-diff
effigies Jun 3, 2018
a494597
MAINT: 2.4.0-dev
effigies Jun 12, 2018
89e698c
Merge branch 'maint/2.3.x' into HEAD
effigies Jun 12, 2018
30c0bc5
DOC: Update changelog with release date
effigies Jun 12, 2018
f8c32b8
latest attempt at compliance changes dict to list
chrispycheng Jun 26, 2018
51733b0
Merge branch 'nf-nib-diff' of https://github.com/yarikoptic/nibabel i…
chrispycheng Jun 26, 2018
41caade
Remove unrelated to PR difference
yarikoptic Jun 27, 2018
f1cee5f
RF+BF: report that diff if any header of data differs, return dict of…
yarikoptic Jun 27, 2018
676ac70
combined into one line
chrispycheng Jun 28, 2018
f476c48
new structure, names, tests
chrispycheng Jul 4, 2018
10c2c42
hypothesis: all my problems were due to that one test
chrispycheng Jul 5, 2018
7989563
whoops missed this
chrispycheng Jul 5, 2018
71581ca
Fix in coordinate_systems tutorial
arokem Jul 9, 2018
2a127cc
Merge pull request #646 from nipy/coordinate_systems_blooper
matthew-brett Jul 9, 2018
ae74339
i think im going to cry. code cleaned and made more pythonic
chrispycheng Jul 11, 2018
82b1457
added and fixed tests
chrispycheng Jul 11, 2018
45d0edf
fixing up appveyor and travis problems
chrispycheng Jul 11, 2018
c1f553f
fixed a fringe use case
chrispycheng Jul 12, 2018
2f89242
style tweak for travis
chrispycheng Jul 12, 2018
347eef9
BF: deterministic order of slice_time deduction, warning if multiple …
yarikoptic Jul 12, 2018
7ba14b1
DOC: minor typo
yarikoptic Jul 12, 2018
244c8cf
ENH(TST): basic test for consistent choice of slice_code in case of m…
yarikoptic Jul 13, 2018
6613522
removed duplication, made things more generic
chrispycheng Jul 16, 2018
a311d7b
moved functionality outside to test and increase coverage
chrispycheng Jul 17, 2018
748ce00
RF+NF: Use OrderedDict and OrderedSet in Recoder
yarikoptic Jul 18, 2018
a1400bd
ENH(TST): test that we issue a warning upon multiple matches
yarikoptic Jul 18, 2018
d756751
TEST: Ensure warning isn't suppressed
effigies Jul 19, 2018
bb8c6fa
Merge pull request #647 from yarikoptic/bf-sliceorder
effigies Jul 23, 2018
2cd69b5
boosting coverage by testing main
chrispycheng Jul 24, 2018
414da00
main test corrected for max coverage
chrispycheng Jul 27, 2018
7fe10e6
FIX: Allow tr=0 in mghformat
larsoner Jul 27, 2018
f1ec04c
FIX: Better messages
larsoner Jul 27, 2018
59006b0
imported StringIO from six instead of io
chrispycheng Jul 27, 2018
672661e
added a test for cmdline function
chrispycheng Jul 27, 2018
0f947a4
Merge pull request #653 from larsoner/tr
effigies Jul 27, 2018
baf6cdc
changes per Yariks comments!
chrispycheng Jul 28, 2018
370c811
Replace genfromtxt with loadtxt
MichielCottaar Aug 1, 2018
0408783
Merge pull request #617 from yarikoptic/nf-nib-diff
yarikoptic Aug 2, 2018
897eb31
Merge pull request #655 from MichielCottaar/opt_genfromtxt
effigies Aug 7, 2018
caa04e4
BF: allow for PPC64 little endian long doubles
matthew-brett Aug 17, 2018
3a13301
RF: remove redundant line
matthew-brett Aug 23, 2018
eb44d32
BF: fix missing width variable
matthew-brett Aug 23, 2018
be35aca
Merge pull request #658 from matthew-brett/ppc64le-fixes
effigies Aug 24, 2018
cd5a741
RF+ENH: nib-diff - allow to specify absolute and/or relative maximal …
yarikoptic Sep 14, 2018
018eceb
ENH: nib-diff Field/File not just Field in the header
yarikoptic Sep 14, 2018
833b4df
changed as commented out in the pull request
chrispycheng Sep 21, 2018
9b123f6
changes as commented
chrispycheng Sep 21, 2018
1e33ea7
RF: anticipated files of different shapes, fixed table display, corre…
chrispycheng Sep 25, 2018
66fe79a
CI: Test on Python 3.7 on Travis
effigies Jul 23, 2018
4b2f497
CI: Use dist xenial
effigies Jul 23, 2018
62a664e
CI: Use matrix include for Python 3.7
effigies Jul 23, 2018
0813c00
CI: Use Python 3.7-dev
effigies Jul 24, 2018
7a0e298
DOCTEST: FutureWarning repr changed in 3.7
effigies Jul 27, 2018
7c12c54
CI: Use 3.7 proper, move trusty+3.4 to matrix
effigies Sep 25, 2018
2bd256b
TEST: Catch warnings in clear_and_catch tests
effigies Sep 25, 2018
7baaf6b
CI: Add Python 3.7 to AppVeyor matrix
effigies Sep 26, 2018
b5dd5d7
FIX: Annotation labels are RGB, no alpha
effigies Sep 27, 2018
10dbdda
TEST: Update tests to use RGB only
effigies Sep 27, 2018
76ca32f
elaborated docstring, modified get_data_diff to allow direct array in…
chrispycheng Sep 27, 2018
7b59675
DOC: Update ctab documentation, comments
effigies Sep 28, 2018
25f08b7
CI: Drop extraneous 2.7 build on Travis
effigies Sep 28, 2018
0aa6370
added to diff documentation, undid executable change, took out debugg…
chrispycheng Sep 28, 2018
436df7c
Merge pull request #651 from nipy/ci/travis_py37
matthew-brett Sep 28, 2018
d057249
undid permission snafu on test_scripts
chrispycheng Sep 28, 2018
7877add
Merge pull request #666 from effigies/fix/annot_labels
effigies Oct 1, 2018
dd24b20
Merge remote-tracking branch 'upstream/master' into rel/2.3.1
effigies Oct 1, 2018
764584a
DOC: Update Changelog
effigies Oct 1, 2018
1da1ac6
MNT: .mailmap
effigies Oct 1, 2018
e493b9d
MAINT: Drop -dev
effigies Oct 1, 2018
906c6b4
MNT: Update YOH, CC initials
effigies Oct 1, 2018
13d803f
TST: Require hypothesis>=3.7
effigies Oct 2, 2018
76ee358
docstring and function name clarification, change get_data to get_fda…
chrispycheng Oct 2, 2018
034c276
corrected styles per Travis, limited fdata to float32
chrispycheng Oct 2, 2018
19fcdd5
STY: Break overly-long line
effigies Oct 3, 2018
7e03807
ENH: Add ndim to ArrayProxy protocol
effigies Oct 3, 2018
c940dea
TEST: Validate expected ndim behavior
effigies Oct 3, 2018
93c7bb6
prepared for future PR to allow modification of dtype used in diff co…
chrispycheng Oct 3, 2018
cd85e09
Merge branch 'enh-diff' of https://github.com/yarikoptic/nibabel into…
chrispycheng Oct 3, 2018
97ead00
added cmdline functionality for modifying datatype used for file data…
chrispycheng Oct 3, 2018
d2d07d4
ENH: Pass ndim through to DataobjImage
effigies Oct 4, 2018
ce210bd
TEST: Validate DataobjImage.ndim
effigies Oct 4, 2018
2340a92
added testing for dtype at cmdline, assuming cmdline functionality. c…
chrispycheng Oct 4, 2018
e8d3a4f
RF: do not use hypothesis
yarikoptic Oct 6, 2018
09cfef1
BF: properly compare NaNs and test for >2 arguments given to are_valu…
yarikoptic Oct 6, 2018
1996ead
RF: long -> large, NaN -> nan
yarikoptic Oct 8, 2018
0fb8920
BF: reintroduce try/except guarding around initial np.isnan
yarikoptic Oct 8, 2018
e4c5b52
BF: exception string matching for not implemented in numpy 1.7.1
yarikoptic Oct 8, 2018
e87d581
BF: another workaround for elderly numpy 1.7.1
yarikoptic Oct 8, 2018
f973ce4
BF(DOC): fixed damn trailing whitespaces in a docsting
yarikoptic Oct 9, 2018
7315931
storing changes for main testing
chrispycheng Oct 10, 2018
22f89e9
Merge branch 'no-hypothesis' of https://github.com/yarikoptic/nibabel…
chrispycheng Oct 10, 2018
3636c4d
added tests to fix coverage problem
chrispycheng Oct 11, 2018
974a3a9
cmdline test added for dtype access
chrispycheng Oct 11, 2018
def0364
Merge pull request #678 from yarikoptic/no-hypothesis
yarikoptic Oct 11, 2018
5361c7f
ENH: adjusted some strings etc to fit the width and avoid duplicate s…
yarikoptic Oct 11, 2018
edb72bc
Merge branch 'master' into enh-diff-dtype
effigies Oct 11, 2018
679aa5b
Merge pull request #672 from chrispycheng/enh-diff-dtype
yarikoptic Oct 12, 2018
65cb2b9
Revert "TST: Require hypothesis>=3.7"
effigies Oct 12, 2018
dd0b8ef
Merge remote-tracking branch 'upstream/master' into rel/2.3.1
effigies Oct 12, 2018
791678e
Merge pull request #674 from effigies/enh/arrayproxy_ndim
effigies Oct 12, 2018
72232e7
Merge remote-tracking branch 'upstream/master' into rel/2.3.1
effigies Oct 12, 2018
0be50ad
DOC: Update changelog
effigies Oct 12, 2018
dc04379
TEST,BK: Update arrayproxy tests to test expected behaviour more thor…
pauldmccarthy Oct 12, 2018
4efc5e3
TEST: Refactor keep_file_open tests to be more comprehensive
pauldmccarthy Oct 12, 2018
5a9b7f3
BF,RF: Fix behaviour of keep_file_open flag. Now two internal flags a…
pauldmccarthy Oct 12, 2018
f6236ac
TEST: Avoid file close errors on windows
pauldmccarthy Oct 12, 2018
9d7fb3f
TEST: Remove debug
pauldmccarthy Oct 13, 2018
a474254
Merge pull request #679 from pauldmccarthy/bf/fix_keep_file_open
effigies Oct 15, 2018
ba17006
Merge remote-tracking branch 'upstream/master' into rel/2.3.1
effigies Oct 15, 2018
5841806
Update changelog
effigies Oct 15, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Basile Pinsard <[email protected]> bpinsard <[email protected]>
Nguyen, Ly <[email protected]> lxn2 <[email protected]>
Ben Cipollini <[email protected]> Ben Cipollini <[email protected]>
Chris Markiewicz <[email protected]> Christopher J. Markiewicz <[email protected]>
Chris Markiewicz <[email protected]> Chris Markiewicz <[email protected]>
Chris Markiewicz <[email protected]> Christopher J. Markiewicz <[email protected]>
Chris Markiewicz <[email protected]> Christopher J. Markiewicz <[email protected]>
Chris Markiewicz <[email protected]> Chris Johnson <[email protected]>
Expand Down
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
# for it to be on multiple physical lines, so long as you remember: - There
# can't be any leading "-"s - All newlines will be removed, so use ";"s

dist: xenial
sudo: true
language: python

# Run jobs on container-based infrastructure, can be overridden per job
sudo: false

cache:
directories:
- $HOME/.cache/pip
Expand All @@ -22,11 +21,14 @@ env:
- EXTRA_PIP_FLAGS="--find-links=$EXTRA_WHEELS"
- PRE_PIP_FLAGS="--pre $EXTRA_PIP_FLAGS --find-links $PRE_WHEELS"
python:
- 3.4
- 3.5
- 3.6
- 3.7
matrix:
include:
- python: 3.4
dist: trusty
sudo: false
- python: 2.7
env:
- COVERAGE=1
Expand Down
52 changes: 28 additions & 24 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -121,36 +121,40 @@ Sphinx 0.6 doesn't work properly.
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

Ordereddict
OrderedSet
-----------

In ``nibabel/externals/ordereddict.py``
In ``nibabel/externals/oset.py``

Copied from: https://pypi.python.org/packages/source/o/ordereddict/ordereddict-1.1.tar.gz#md5=a0ed854ee442051b249bfad0f638bbec
Copied from: https://files.pythonhosted.org/packages/d6/b1/a49498c699a3fda5d635cc1fa222ffc686ea3b5d04b84a3166c4cab0c57b/oset-0.1.3.tar.gz

::

Copyright (c) 2009 Raymond Hettinger

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2009, Raymond Hettinger, and others All rights reserved.

Package structured based on the one developed to odict Copyright (c) 2010, BlueDynamics Alliance, Austria

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

- Neither the name of the BlueDynamics Alliance nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY BlueDynamics Alliance AS IS AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL BlueDynamics Alliance BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

mni_icbm152_t1_tal_nlin_asym_09a
--------------------------------
Expand Down
38 changes: 37 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,46 @@ Nibabel releases

Most work on NiBabel so far has been by Matthew Brett (MB), Michael Hanke (MH)
Ben Cipollini (BC), Marc-Alexandre Côté (MC), Chris Markiewicz (CM), Stephan
Gerhard (SG) and Eric Larson (EL).
Gerhard (SG), Eric Larson (EL), Yaroslav Halchenko (YOH) and Chris Cheng (CC).

References like "pr/298" refer to github pull request numbers.

Upcoming release
================

New features
------------
* ``nib-diff`` command line tool for comparing image files (pr/617, pr/672,
pr/678) (CC, reviewed by YOH, Pradeep Raamana and CM)

Enhancements
------------
* Speed up reading of numeric arrays in CIFTI2 (pr/655) (Michiel Cottaar,
reviewed by CM)
* Add ``ndim`` property to ``ArrayProxy`` and ``DataobjImage`` (pr/674) (CM,
reviewed by MB)

Bug fixes
---------
* Deterministic deduction of slice ordering in degenerate cases (pr/647)
(YOH, reviewed by CM)
* Allow 0ms TR in MGH files (pr/653) (EL, reviewed by CM)
* Allow for PPC64 little-endian long doubles (pr/658) (MB, reviewed by CM)
* Correct construction of FreeSurfer annotation labels (pr/666) (CM, reviewed
by EL, Paul D. McCarthy)
* Fix logic for persisting filehandles with indexed-gzip (pr/679) (Paul D.
McCarthy, reviewed by CM)

Maintenance
-----------
* Fix semantic error in coordinate systems documentation (pr/646) (Ariel
Rokem, reviewed by CM, MB)
* Test on Python 3.7, minor associated fixes (pr/651) (CM, reviewed by Gregory
R. Lee, MB)

API changes and deprecations
----------------------------

2.3 (Tuesday 12 June 2018)
==========================

Expand Down
5 changes: 3 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ environment:
- PYTHON: C:\Python35-x64
- PYTHON: C:\Python36
- PYTHON: C:\Python36-x64
- PYTHON: C:\Python37
- PYTHON: C:\Python37-x64

install:
# Prepend newly installed Python to the PATH of this build (this cannot be
Expand All @@ -20,8 +22,7 @@ install:
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%

# Install the dependencies of the project.
- pip install numpy scipy matplotlib nose h5py mock
- pip install pydicom
- pip install numpy scipy matplotlib nose h5py mock pydicom
- pip install .
- SET NIBABEL_DATA_DIR=%CD%\nibabel-data

Expand Down
17 changes: 17 additions & 0 deletions bin/nib-diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!python
# emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the NiBabel package for the
# copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""
Quick diff summary for a set of neuroimaging files
"""

from nibabel.cmdline.diff import main

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion doc/source/coordinate_systems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ axes *starts* on the right, anterior, superior of the subject, rather than
*ending* on the right, anterior, superior. In other words, they would use
"RAS" to refer to a coordinate system we would call "LPI". To be safe, we'll
call our interpretation of the RAS convention "RAS+", meaning that Right,
Anterior, Posterior are all positive values on these axes.
Anterior, Superior are all positive values on these axes.

Some people also use "right" to mean the right hand side when an observer
looks at the front of the scanner, from the foot the scanner bed.
Expand Down
113 changes: 88 additions & 25 deletions nibabel/arrayproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
used for the lifetime of the ``ArrayProxy``. It should be set to one of
``True``, ``False``, or ``'auto'``.

If ``True``, a single file handle is created and used. If ``False``, a new
file handle is created every time the image is accessed. For gzip files, if
``'auto'``, and the optional ``indexed_gzip`` dependency is present, a single
file handle is created and persisted. If ``indexed_gzip`` is not available,
behaviour is the same as if ``keep_file_open is False``.
Management of file handles will be performed either by ``ArrayProxy`` objects,
or by the ``indexed_gzip`` package if it is used.

If this flag is set to ``True``, a single file handle is created and used. If
``False``, a new file handle is created every time the image is accessed. For
gzip files, if ``'auto'``, and the optional ``indexed_gzip`` dependency is
present, a single file handle is created and persisted. If ``indexed_gzip`` is
not available, behaviour is the same as if ``keep_file_open is False``.

If this is set to any other value, attempts to create an ``ArrayProxy`` without
specifying the ``keep_file_open`` flag will result in a ``ValueError`` being
Expand Down Expand Up @@ -160,8 +163,10 @@ def __init__(self, file_like, spec, mmap=True, keep_file_open=None):
# Permit any specifier that can be interpreted as a numpy dtype
self._dtype = np.dtype(self._dtype)
self._mmap = mmap
self._keep_file_open = self._should_keep_file_open(file_like,
keep_file_open)
# Flags to keep track of whether a single ImageOpener is created, and
# whether a single underlying file handle is created.
self._keep_file_open, self._persist_opener = \
self._should_keep_file_open(file_like, keep_file_open)
self._lock = RLock()

def __del__(self):
Expand All @@ -184,16 +189,64 @@ def __setstate__(self, state):
self._lock = RLock()

def _should_keep_file_open(self, file_like, keep_file_open):
"""Called by ``__init__``, and used to determine the final value of
``keep_file_open``.
"""Called by ``__init__``.

This method determines how to manage ``ImageOpener`` instances,
and the underlying file handles - the behaviour depends on:

- whether ``file_like`` is an an open file handle, or a path to a
``'.gz'`` file, or a path to a non-gzip file.
- whether ``indexed_gzip`` is present (see
:attr:`.openers.HAVE_INDEXED_GZIP`).

An ``ArrayProxy`` object uses two internal flags to manage
``ImageOpener`` instances and underlying file handles.

- The ``_persist_opener`` flag controls whether a single
``ImageOpener`` should be created and used for the lifetime of
this ``ArrayProxy``, or whether separate ``ImageOpener`` instances
should be created on each file access.

- The ``_keep_file_open`` flag controls qwhether the underlying file
handle should be kept open for the lifetime of this
``ArrayProxy``, or whether the file handle should be (re-)opened
and closed on each file access.

The internal ``_keep_file_open`` flag is only relevant if
``file_like`` is a ``'.gz'`` file, and the ``indexed_gzip`` library is
present.

This method returns the values to be used for the internal
``_persist_opener`` and ``_keep_file_open`` flags; these values are
derived according to the following rules:

The return value is derived from these rules:
1. If ``file_like`` is a file(-like) object, both flags are set to
``False``.

- If ``file_like`` is a file(-like) object, ``False`` is returned.
Otherwise, ``file_like`` is assumed to be a file name.
- If ``keep_file_open`` is ``auto``, and ``indexed_gzip`` is
not available, ``False`` is returned.
- Otherwise, the value of ``keep_file_open`` is returned unchanged.
2. If ``keep_file_open`` (as passed to :meth:``__init__``) is
``True``, both internal flags are set to ``True``.

3. If ``keep_file_open`` is ``False``, but ``file_like`` is not a path
to a ``.gz`` file or ``indexed_gzip`` is not present, both flags
are set to ``False``.

4. If ``keep_file_open`` is ``False``, ``file_like`` is a path to a
``.gz`` file, and ``indexed_gzip`` is present, ``_persist_opener``
is set to ``True``, and ``_keep_file_open`` is set to ``False``.
In this case, file handle management is delegated to the
``indexed_gzip`` library.

5. If ``keep_file_open`` is ``'auto'``, ``file_like`` is a path to a
``.gz`` file, and ``indexed_gzip`` is present, both internal flags
are set to ``True``.

6. If ``keep_file_open`` is ``'auto'``, and ``file_like`` is not a
path to a ``.gz`` file, or ``indexed_gzip`` is not present, both
internal flags are set to ``False``.

Note that a value of ``'auto'`` for ``keep_file_open`` will become
deprecated behaviour in version 2.4.0, and support for ``'auto'`` will
be removed in version 3.0.0.

Parameters
----------
Expand All @@ -206,8 +259,10 @@ def _should_keep_file_open(self, file_like, keep_file_open):
Returns
-------

The value of ``keep_file_open`` that will be used by this
``ArrayProxy``, and passed through to ``ImageOpener`` instances.
A tuple containing:
- ``keep_file_open`` flag to control persistence of file handles
- ``persist_opener`` flag to control persistence of ``ImageOpener``
objects.
"""
if keep_file_open is None:
keep_file_open = KEEP_FILE_OPEN_DEFAULT
Expand All @@ -216,12 +271,15 @@ def _should_keep_file_open(self, file_like, keep_file_open):
'\'auto\', True, False}')
# file_like is a handle - keep_file_open is irrelevant
if hasattr(file_like, 'read') and hasattr(file_like, 'seek'):
return False
# don't have indexed_gzip - auto -> False
if keep_file_open == 'auto' and not (openers.HAVE_INDEXED_GZIP and
file_like.endswith('.gz')):
return False
return keep_file_open
return False, False
# if the file is a gzip file, and we have_indexed_gzip,
have_igzip = openers.HAVE_INDEXED_GZIP and file_like.endswith('.gz')
if keep_file_open == 'auto':
return have_igzip, have_igzip
elif keep_file_open:
return True, True
else:
return False, have_igzip

@property
@deprecate_with_version('ArrayProxy.header deprecated', '2.2', '3.0')
Expand All @@ -232,6 +290,10 @@ def header(self):
def shape(self):
return self._shape

@property
def ndim(self):
return len(self.shape)

@property
def dtype(self):
return self._dtype
Expand Down Expand Up @@ -265,13 +327,14 @@ def _get_fileobj(self):
A newly created ``ImageOpener`` instance, or an existing one,
which provides access to the file.
"""
if self._keep_file_open:
if self._persist_opener:
if not hasattr(self, '_opener'):
self._opener = openers.ImageOpener(
self.file_like, keep_open=self._keep_file_open)
yield self._opener
else:
with openers.ImageOpener(self.file_like) as opener:
with openers.ImageOpener(
self.file_like, keep_open=False) as opener:
yield opener

def get_unscaled(self):
Expand Down
3 changes: 3 additions & 0 deletions nibabel/casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ def type_info(np_type):
# 80) but in calculations nexp in fact appears to be 11 as for float64
ret.update(dict(width=width))
return ret
if vals == (105, 11, 16): # correctly detected double double
ret.update(dict(nmant=nmant, nexp=nexp, width=width))
return ret
# Oh dear, we don't recognize the type information. Try some known types
# and then give up. At this stage we're expecting exotic longdouble or
# their complex equivalent.
Expand Down
Loading