Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michiel Cottaar
fslpy
Commits
4193746d
Commit
4193746d
authored
Oct 23, 2017
by
Paul McCarthy
🚵
Browse files
Fixing important pylint issues
parent
ea38d1aa
Changes
10
Hide whitespace changes
Inline
Side-by-side
fsl/data/featanalysis.py
View file @
4193746d
...
...
@@ -64,7 +64,7 @@ def isFEATImage(path):
try
:
path
=
fslimage
.
addExt
(
path
,
mustExist
=
True
)
except
:
except
fslimage
.
PathError
:
return
False
dirname
=
op
.
dirname
(
path
)
...
...
@@ -115,7 +115,7 @@ def hasStats(featdir):
try
:
getZStatFile
(
featdir
,
0
)
return
True
except
:
except
fslimage
.
PathError
:
return
False
...
...
fsl/data/featdesign.py
View file @
4193746d
...
...
@@ -326,7 +326,8 @@ class VoxelwiseEV(NormalEV):
if
op
.
exists
(
filename
):
self
.
filename
=
filename
else
:
log
.
warning
(
'Voxelwise EV file does not exist: '
.
format
(
filename
))
log
.
warning
(
'Voxelwise EV file does not '
'exist: {}'
.
format
(
filename
))
self
.
filename
=
None
...
...
@@ -406,8 +407,8 @@ class VoxelwiseConfoundEV(EV):
if
op
.
exists
(
filename
):
self
.
filename
=
filename
else
:
log
.
warning
(
'Voxelwise confound EV file '
'
does
not exist: '
.
format
(
filename
))
log
.
warning
(
'Voxelwise confound EV file
does
'
'not exist:
{}
'
.
format
(
filename
))
self
.
filename
=
None
...
...
@@ -547,7 +548,7 @@ def getFirstLevelEVs(featDir, settings, designMat):
# Create the voxelwise confound EVs.
# We make a name for the EV from the
# file name.
for
i
,
(
f
,
l
)
in
enumerate
(
zip
(
voxConfFiles
,
voxConfLocs
)
):
for
i
,
f
in
enumerate
(
voxConfFiles
):
title
=
op
.
basename
(
fslimage
.
removeExt
(
f
))
evs
.
append
(
VoxelwiseConfoundEV
(
len
(
evs
),
i
,
title
,
f
))
...
...
fsl/data/image.py
View file @
4193746d
...
...
@@ -222,6 +222,8 @@ class Nifti(notifier.Notifier):
# qform = header.get('qform_code', -1)
# sform = header.get('sform_code', -1)
#
# TODO Change this in fslpy 2.0.0
#
if
isinstance
(
header
,
nib
.
nifti1
.
Nifti1Header
):
intent
=
header
[
'intent_code'
]
qform
=
header
[
'qform_code'
]
...
...
@@ -309,8 +311,8 @@ class Nifti(notifier.Notifier):
val
=
self
.
header
[
key
]
try
:
val
=
bytes
(
val
).
partition
(
b
'
\0
'
)[
0
]
except
:
val
=
bytes
(
val
)
try
:
val
=
bytes
(
val
).
partition
(
b
'
\0
'
)[
0
]
except
Exception
:
val
=
bytes
(
val
)
val
=
val
.
decode
(
'ascii'
)
...
...
@@ -611,12 +613,12 @@ class Nifti(notifier.Notifier):
:class:`Nifti` instance) has the same dimensions and is in the
same space as this image.
"""
return
np
.
all
(
np
.
isclose
(
self
.
__
shape
[:
3
],
other
.
__
shape
[:
3
]))
and
\
np
.
all
(
np
.
isclose
(
self
.
__
pixdim
[:
3
],
other
.
__
pixdim
[:
3
]))
and
\
np
.
all
(
np
.
isclose
(
self
.
__
voxToWorldMat
,
other
.
__
voxToWorldMat
))
return
np
.
all
(
np
.
isclose
(
self
.
shape
[:
3
],
other
.
shape
[:
3
]))
and
\
np
.
all
(
np
.
isclose
(
self
.
pixdim
[:
3
],
other
.
pixdim
[:
3
]))
and
\
np
.
all
(
np
.
isclose
(
self
.
voxToWorldMat
,
other
.
voxToWorldMat
))
def
getOrientation
(
self
,
axis
,
xform
):
...
...
@@ -1426,7 +1428,7 @@ def read_segments(fileobj, segments, n_bytes):
# actual file is available via the fobj attribute
lock
=
getattr
(
fileobj
.
fobj
,
'_arrayproxy_lock'
)
except
:
except
AttributeError
:
return
fileslice
.
orig_read_segments
(
fileobj
,
segments
,
n_bytes
)
if
len
(
segments
)
==
0
:
...
...
fsl/data/imagewrapper.py
View file @
4193746d
...
...
@@ -231,7 +231,7 @@ class ImageWrapper(notifier.Notifier):
self
.
__image
=
None
if
self
.
__taskThread
is
not
None
:
self
.
__taskThread
.
stop
()
self
.
__taskThr
a
ed
=
None
self
.
__taskThre
a
d
=
None
def
getTaskThread
(
self
):
...
...
@@ -459,7 +459,7 @@ class ImageWrapper(notifier.Notifier):
# the min/max per volume/expansion, and
# iteratively update the stored per-volume
# coverage and data range.
for
i
,
exp
in
enumerate
(
expansions
)
:
for
exp
in
expansions
:
data
=
self
.
__getData
(
exp
,
isTuple
=
True
)
data
=
data
.
squeeze
(
squeezeDims
)
...
...
@@ -750,7 +750,7 @@ def naninfrange(data):
# finite values in the array
try
:
return
data
[
finite
].
min
(),
data
[
finite
].
max
()
except
:
except
Exception
:
return
np
.
nan
,
np
.
nan
...
...
@@ -1097,7 +1097,7 @@ def calcExpansion(slices, coverage):
# 'padding' dimensions of size 1.
def
finishExpansion
(
exp
,
vol
):
exp
.
append
((
vol
,
vol
+
1
))
for
i
in
range
(
padDims
):
for
_
in
range
(
padDims
):
exp
.
append
((
0
,
1
))
return
exp
...
...
fsl/data/melodicanalysis.py
View file @
4193746d
...
...
@@ -49,7 +49,7 @@ def isMelodicImage(path):
try
:
path
=
fslimage
.
addExt
(
path
,
mustExist
=
True
)
except
:
except
fslimage
.
PathError
:
return
False
dirname
=
op
.
dirname
(
path
)
...
...
fsl/data/mesh.py
View file @
4193746d
...
...
@@ -380,7 +380,7 @@ def findReferenceImage(modelfile):
dirname
=
op
.
dirname
(
modelfile
)
prefixes
=
[
getFIRSTPrefix
(
modelfile
)]
except
:
except
ValueError
:
return
None
if
prefixes
[
0
].
endswith
(
'_first'
):
...
...
@@ -389,7 +389,7 @@ def findReferenceImage(modelfile):
for
p
in
prefixes
:
try
:
return
fslimage
.
addExt
(
op
.
join
(
dirname
,
p
),
mustExist
=
True
)
except
:
except
fslimage
.
PathError
:
continue
return
None
fsl/utils/async.py
View file @
4193746d
...
...
@@ -87,8 +87,8 @@ import functools
import
threading
import
collections
try
:
import
queue
except
:
import
Queue
as
queue
try
:
import
queue
except
ImportError
:
import
Queue
as
queue
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -142,7 +142,7 @@ def run(task, onFinish=None, onError=None, name=None):
except
Exception
as
e
:
log
.
warn
(
'Task "{}" crashed'
.
format
(
name
),
exc_info
=
True
)
log
.
warn
ing
(
'Task "{}" crashed'
.
format
(
name
),
exc_info
=
True
)
callback
(
onError
,
e
)
# If WX, run on a thread
...
...
@@ -759,7 +759,7 @@ class TaskThread(threading.Thread):
# Any other error typically indicates
# that this is a daemon thread, and
# the TaskThread object has been GC'd
except
:
except
Exception
:
break
finally
:
...
...
fsl/utils/platform.py
View file @
4193746d
...
...
@@ -146,6 +146,7 @@ class Platform(notifier.Notifier):
self
.
__glRenderer
=
None
self
.
__glIsSoftware
=
None
self
.
__fslVersion
=
None
self
.
__fsldir
=
None
self
.
fsldir
=
os
.
environ
.
get
(
'FSLDIR'
,
None
)
# Determine if a display is available. We do
...
...
@@ -239,18 +240,16 @@ class Platform(notifier.Notifier):
pi
=
[
t
.
lower
()
for
t
in
wx
.
PlatformInfo
]
for
tag
in
pi
:
if
any
([
'cocoa'
in
p
for
p
in
pi
]):
platform
=
WX_MAC_COCOA
elif
any
([
'carbon'
in
p
for
p
in
pi
]):
platform
=
WX_MAC_CARBON
elif
any
([
'gtk'
in
p
for
p
in
pi
]):
platform
=
WX_GTK
else
:
platform
=
WX_UNKNOWN
if
any
([
'cocoa'
in
p
for
p
in
pi
]):
plat
=
WX_MAC_COCOA
elif
any
([
'carbon'
in
p
for
p
in
pi
]):
plat
=
WX_MAC_CARBON
elif
any
([
'gtk'
in
p
for
p
in
pi
]):
plat
=
WX_GTK
else
:
plat
=
WX_UNKNOWN
if
platform
is
WX_UNKNOWN
:
log
.
warning
(
'Could not determine wx platform from '
'information: {}'
.
format
(
pi
))
if
platform
is
WX_UNKNOWN
:
log
.
warning
(
'Could not determine wx platform from '
'information: {}'
.
format
(
pi
))
return
plat
form
return
plat
@
property
...
...
fsl/utils/settings.py
View file @
4193746d
...
...
@@ -341,7 +341,7 @@ class Settings(object):
if
not
op
.
exists
(
cfgdir
):
try
:
os
.
makedirs
(
cfgdir
)
except
:
except
OSError
:
log
.
warning
(
'Unable to create {} configuration '
'directory: {}'
.
format
(
cid
,
cfgdir
),
...
...
@@ -372,7 +372,7 @@ class Settings(object):
try
:
with
open
(
configFile
,
'rb'
)
as
f
:
return
pickle
.
load
(
f
)
except
:
except
(
IOError
,
pickle
.
UnpicklingError
)
:
log
.
debug
(
'Unable to load stored {} configuration file '
'{}'
.
format
(
self
.
__configID
,
configFile
),
exc_info
=
True
)
...
...
@@ -391,7 +391,7 @@ class Settings(object):
try
:
with
open
(
configFile
,
'wb'
)
as
f
:
pickle
.
dump
(
config
,
f
)
except
:
except
(
IOError
,
pickle
.
PicklingError
)
:
log
.
warning
(
'Unable to save {} configuration file '
'{}'
.
format
(
self
.
__configID
,
configFile
),
exc_info
=
True
)
fsl/utils/weakfuncref.py
View file @
4193746d
...
...
@@ -148,9 +148,9 @@ class WeakFunctionRef(object):
obj
=
self
.
obj
()
# Return the bound method object
try
:
return
getattr
(
obj
,
self
.
funcName
)
try
:
return
getattr
(
obj
,
self
.
funcName
)
# If the function is a bound private method,
# its name on the instance will have been
# mangled, so we need to search for it
except
:
return
self
.
__findPrivateMethod
()
except
AttributeError
:
return
self
.
__findPrivateMethod
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment