Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
f02bd21f
Commit
f02bd21f
authored
6 years ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
ENH: added command line support for output images (in FSL style)
parent
41461fc2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/utils/parse_data.py
+10
-0
10 additions, 0 deletions
fsl/utils/parse_data.py
tests/test_parse_data.py
+32
-1
32 additions, 1 deletion
tests/test_parse_data.py
with
42 additions
and
1 deletion
fsl/utils/parse_data.py
+
10
−
0
View file @
f02bd21f
...
@@ -40,6 +40,16 @@ def Image(filename):
...
@@ -40,6 +40,16 @@ def Image(filename):
return
image
.
Image
(
full_filename
)
return
image
.
Image
(
full_filename
)
def
ImageOut
(
basename
):
"""
Uses the FSL convention to create a complete image output filename
:param basename: filename provided by the user
:return: filename with extension
"""
return
image
.
addExt
(
basename
,
mustExist
=
False
)
def
Mesh
(
filename
):
def
Mesh
(
filename
):
"""
"""
Reads in a mesh from either a GIFTI (.surf.gii) or a VTK (.vtk) file
Reads in a mesh from either a GIFTI (.surf.gii) or a VTK (.vtk) file
...
...
This diff is collapsed.
Click to expand it.
tests/test_parse_data.py
+
32
−
1
View file @
f02bd21f
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
#
#
import
argparse
import
argparse
from
fsl.utils
import
parse_data
,
tempdir
from
fsl.utils
import
parse_data
,
tempdir
,
path
import
os.path
as
op
import
os.path
as
op
from
fsl.data.vtk
import
VTKMesh
from
fsl.data.vtk
import
VTKMesh
from
fsl.data.gifti
import
GiftiMesh
from
fsl.data.gifti
import
GiftiMesh
...
@@ -14,6 +14,7 @@ from fsl.data.image import Image
...
@@ -14,6 +14,7 @@ from fsl.data.image import Image
from
fsl.data.atlases
import
Atlas
from
fsl.data.atlases
import
Atlas
from
pytest
import
raises
from
pytest
import
raises
from
.test_image
import
make_image
from
.test_image
import
make_image
import
os
datadir
=
op
.
join
(
op
.
dirname
(
__file__
),
'
testdata
'
)
datadir
=
op
.
join
(
op
.
dirname
(
__file__
),
'
testdata
'
)
...
@@ -84,6 +85,36 @@ def test_image():
...
@@ -84,6 +85,36 @@ def test_image():
image_parser
.
parse_args
([
double_filename
])
image_parser
.
parse_args
([
double_filename
])
def
test_image_out
():
image_parser
=
argparse
.
ArgumentParser
(
"
Reads an image
"
)
image_parser
.
add_argument
(
"
image_out
"
,
type
=
parse_data
.
ImageOut
)
for
fsl_output_type
,
extension
in
(
(
'
NIFTI
'
,
'
.nii
'
),
(
'
NIFTI_PAIR
'
,
'
.img
'
),
(
'
NIFTI_GZ
'
,
'
.nii.gz
'
)
):
os
.
environ
[
'
FSLOUTPUTTYPE
'
]
=
fsl_output_type
args
=
image_parser
.
parse_args
([
'
test
'
])
assert
path
.
hasExt
(
args
.
image_out
,
extension
)
assert
args
.
image_out
==
'
test
'
+
extension
args
=
image_parser
.
parse_args
([
'
test.nii
'
])
assert
path
.
hasExt
(
args
.
image_out
,
'
.nii
'
)
assert
args
.
image_out
==
'
test.nii
'
args
=
image_parser
.
parse_args
([
'
test.nii.gz
'
])
assert
path
.
hasExt
(
args
.
image_out
,
'
.nii.gz
'
)
assert
args
.
image_out
==
'
test.nii.gz
'
args
=
image_parser
.
parse_args
([
'
test.img
'
])
assert
path
.
hasExt
(
args
.
image_out
,
'
.img
'
)
assert
args
.
image_out
==
'
test.img
'
args
=
image_parser
.
parse_args
([
'
test.surf.gii
'
])
assert
path
.
hasExt
(
args
.
image_out
,
extension
)
assert
args
.
image_out
==
'
test.surf.gii
'
+
extension
def
test_atlas
():
def
test_atlas
():
atlas_parser
=
argparse
.
ArgumentParser
(
'
reads an atlas
'
)
atlas_parser
=
argparse
.
ArgumentParser
(
'
reads an atlas
'
)
atlas_parser
.
add_argument
(
'
atlas
'
,
type
=
parse_data
.
Atlas
)
atlas_parser
.
add_argument
(
'
atlas
'
,
type
=
parse_data
.
Atlas
)
...
...
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