Skip to content

Commit 5c8cf70

Browse files
slimnsouroesteban
authored andcommitted
Fixed imglob's print statements in FSL (used by eddy_correct)
1 parent b46a492 commit 5c8cf70

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

.docker/fsl-6.0/bin/imglob

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/usr/bin/env python
2+
# imglob - expand list of image filenames
3+
# Stephen Smith, Mark Jenkinson and Matthew Webster FMRIB Image Analysis Group
4+
# Copyright (C) 2009 University of Oxford
5+
# Part of FSL - FMRIB's Software Library
6+
# http://www.fmrib.ox.ac.uk/fsl
7+
8+
#
9+
# Developed at FMRIB (Oxford Centre for Functional Magnetic Resonance
10+
# Imaging of the Brain), Department of Clinical Neurology, Oxford
11+
# University, Oxford, UK
12+
#
13+
#
14+
# LICENCE
15+
#
16+
# FMRIB Software Library, Release 5.0 (c) 2012, The University of
17+
# Oxford (the "Software")
18+
#
19+
# The Software remains the property of the University of Oxford ("the
20+
# University").
21+
#
22+
# The Software is distributed "AS IS" under this Licence solely for
23+
# non-commercial use in the hope that it will be useful, but in order
24+
# that the University as a charitable foundation protects its assets for
25+
# the benefit of its educational and research purposes, the University
26+
# makes clear that no condition is made or to be implied, nor is any
27+
# warranty given or to be implied, as to the accuracy of the Software,
28+
# or that it will be suitable for any particular purpose or for use
29+
# under any specific conditions. Furthermore, the University disclaims
30+
# all responsibility for the use which is made of the Software. It
31+
# further disclaims any liability for the outcomes arising from using
32+
# the Software.
33+
#
34+
# The Licensee agrees to indemnify the University and hold the
35+
# University harmless from and against any and all claims, damages and
36+
# liabilities asserted by third parties (including claims for
37+
# negligence) which arise directly or indirectly from the use of the
38+
# Software or the sale of any products based on the Software.
39+
#
40+
# No part of the Software may be reproduced, modified, transmitted or
41+
# transferred in any form or by any means, electronic or mechanical,
42+
# without the express permission of the University. The permission of
43+
# the University is not required if the said reproduction, modification,
44+
# transmission or transference is done without financial return, the
45+
# conditions of this Licence are imposed upon the receiver of the
46+
# product, and all original and amended source code is included in any
47+
# transmitted product. You may be held legally responsible for any
48+
# copyright infringement that is caused or encouraged by your failure to
49+
# abide by these terms and conditions.
50+
#
51+
# You are not permitted under this Licence to use this Software
52+
# commercially. Use for which any financial return is received shall be
53+
# defined as commercial use, and includes (1) integration of all or part
54+
# of the source code or the Software into a product for sale or license
55+
# by or on behalf of Licensee to third parties or (2) use of the
56+
# Software or any derivative of it for research with the final aim of
57+
# developing software products for sale or license to a third party or
58+
# (3) use of the Software or any derivative of it for research with the
59+
# final aim of developing non-software products for sale or license to a
60+
# third party, or (4) use of the Software to provide any service to an
61+
# external organisation for which payment is received. If you are
62+
# interested in using the Software commercially, please contact Isis
63+
# Innovation Limited ("Isis"), the technology transfer company of the
64+
# University, to negotiate a licence. Contact details are:
65+
# [email protected] quoting reference DE/9564.
66+
67+
import sys
68+
import os
69+
import glob
70+
71+
setAvailable=True
72+
if sys.version_info < (2, 4):
73+
import sets
74+
from sets import Set
75+
setAvailable=False
76+
77+
def usage():
78+
print("Usage: $0 [-extension/extensions] <list of names>")
79+
print(" -extension for one image with full extension")
80+
print(" -extensions for image list with full extensions")
81+
sys.exit(1)
82+
83+
def isImage(input,allExtensions): #Returns whether an input filename has an image extension ( and the basename and extension pair )
84+
for extension in allExtensions:
85+
if input[-len(extension):] == extension:
86+
return True, input[:-len(extension)], extension
87+
return False, input, ''
88+
89+
def removeImageExtension(input,allExtensions):
90+
return isImage(input,allExtensions)[1]
91+
92+
if len(sys.argv) <= 1:
93+
usage()
94+
95+
deleteExtensions=True
96+
primaryExtensions=['.nii.gz', '.nii', '.hdr.gz', '.hdr']
97+
secondaryExtensions=['.img.gz', '.img']
98+
allExtensions=primaryExtensions+secondaryExtensions
99+
validExtensions=primaryExtensions
100+
startingArg=1
101+
102+
if sys.argv[1] == "-extensions":
103+
validExtensions=allExtensions
104+
deleteExtensions=False
105+
startingArg=2
106+
if sys.argv[1] == "-extension":
107+
deleteExtensions=False
108+
startingArg=2
109+
110+
filelist=[]
111+
for arg in range(startingArg, len(sys.argv)):
112+
# if isImage(sys.argv[arg],allExtensions)[0]: #These enable a "pedantic" style mode currently not used
113+
# filelist.extend(glob.glob(sys.argv[arg]))
114+
# else:
115+
# for currentExtension in validExtensions:
116+
# filelist.extend(glob.glob(sys.argv[arg]+currentExtension))
117+
for currentExtension in validExtensions:
118+
filelist.extend(glob.glob(removeImageExtension(sys.argv[arg],allExtensions)+currentExtension))
119+
120+
if deleteExtensions:
121+
for file in range(0, len(filelist)):
122+
filelist[file]=removeImageExtension(filelist[file],allExtensions)
123+
if setAvailable:
124+
filelist=list(set(filelist))
125+
else:
126+
filelist=list(Set(filelist))
127+
filelist.sort()
128+
129+
for file in range(0, len(filelist)):
130+
print(filelist[file], end=' ')
131+
if file < len(filelist)-1:
132+
print(" ", end=' ')

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ ENV FSLDIR="/usr/share/fsl/5.0" \
9393
ENV PATH="/usr/lib/fsl/5.0:/usr/lib/afni/bin:$PATH"
9494

9595
COPY .docker/fsl-6.0/bin/topup /usr/share/fsl/5.0/bin/topup
96+
COPY .docker/fsl-6.0/bin/imglob /usr/share/fsl/5.0/bin/imglob
9697
COPY .docker/fsl-6.0/lib/* /usr/lib/fsl/5.0/
9798

9899
# Installing ANTs 2.3.3 (NeuroDocker build)

0 commit comments

Comments
 (0)