Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
cafabc0f
Commit
cafabc0f
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Module/function to call a FSL command. Platform object has FSL version
parent
252cd24c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/fsl.utils.callfsl.rst
+9
-0
9 additions, 0 deletions
doc/fsl.utils.callfsl.rst
doc/fsl.utils.rst
+1
-0
1 addition, 0 deletions
doc/fsl.utils.rst
fsl/utils/callfsl.py
+49
-0
49 additions, 0 deletions
fsl/utils/callfsl.py
fsl/utils/platform.py
+17
-1
17 additions, 1 deletion
fsl/utils/platform.py
with
76 additions
and
1 deletion
doc/fsl.utils.callfsl.rst
0 → 100644
+
9
−
0
View file @
cafabc0f
:orphan:
fsl.utils.callfsl module
========================
.. automodule:: fsl.utils.callfsl
:members:
:undoc-members:
:show-inheritance:
This diff is collapsed.
Click to expand it.
doc/fsl.utils.rst
+
1
−
0
View file @
cafabc0f
...
...
@@ -6,6 +6,7 @@ fsl.utils package
fsl.utils.async
fsl.utils.cache
fsl.utils.callfsl
fsl.utils.colourbarbitmap
fsl.utils.dialog
fsl.utils.imagepanel
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/callfsl.py
0 → 100644
+
49
−
0
View file @
cafabc0f
#!/usr/bin/env python
#
# callfsl.py - The callFSL function.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""
This module provides the :func:`callFSL` function, which can be
used to call a FSL command, and retrieve the result.
"""
import
logging
import
subprocess
as
sp
import
os.path
as
op
from
fsl.utils.platform
import
platform
as
fslplatform
log
=
logging
.
getLogger
(
__name__
)
def
callFSL
(
*
args
):
"""
Call a FSL command and return the result.
You can pass the command and arguments as a single string, or as a
list/tuple.
"""
if
fslplatform
.
fsldir
is
None
:
raise
RuntimeError
(
'
FSL cannot be found!
'
)
# If we've been given a single argument,
# assume it is a string containing the
# command and its arguments. Otherwise,
# assume it is a sequence containing
# separate command and arguments.
if
len
(
args
)
==
1
:
args
=
args
.
split
()
args
=
list
(
args
)
args
[
0
]
=
op
.
join
(
fslplatform
.
fsldir
,
'
bin
'
,
args
[
0
])
log
.
debug
(
'
callfsl: {}
'
.
format
(
'
'
.
join
(
args
)))
result
=
sp
.
check_output
(
args
)
log
.
debug
(
'
result: {}
'
.
format
(
result
))
return
result
This diff is collapsed.
Click to expand it.
fsl/utils/platform.py
+
17
−
1
View file @
cafabc0f
...
...
@@ -145,11 +145,12 @@ class Platform(notifier.Notifier):
self
.
WX_GTK
=
WX_GTK
self
.
isWidgetAlive
=
isWidgetAlive
self
.
fsldir
=
os
.
environ
.
get
(
'
FSLDIR
'
,
None
)
self
.
__inSSHSession
=
False
self
.
__glVersion
=
None
self
.
__glRenderer
=
None
self
.
__glIsSoftware
=
None
self
.
__fslVersion
=
None
self
.
fsldir
=
os
.
environ
.
get
(
'
FSLDIR
'
,
None
)
# Determine if a display is available. We do
# this once at init (instead of on-demand in
...
...
@@ -293,9 +294,24 @@ class Platform(notifier.Notifier):
if
value
is
not
None
:
os
.
environ
[
'
FSLDIR
'
]
=
value
# Set the FSL version field if we can
versionFile
=
op
.
join
(
value
,
'
etc
'
,
'
fslversion
'
)
if
op
.
exists
(
versionFile
):
with
open
(
versionFile
,
'
rt
'
)
as
f
:
self
.
__fslVersion
=
f
.
read
().
strip
()
self
.
notify
()
@property
def
fslVersion
(
self
):
"""
Returns the FSL version as a string, e.g. ``
'
5.0.9
'
``. Returns
``None`` if a FSL installation could not be found.
"""
return
self
.
__fslVersion
@property
def
glVersion
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment