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
cf1b038a
Commit
cf1b038a
authored
4 years ago
by
Evan Edmond
Browse files
Options
Downloads
Patches
Plain Diff
ENH: accept pathlib objects for Image
parent
35fae740
No related branches found
Branches containing commit
Tags
2202.0
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/image.py
+9
-0
9 additions, 0 deletions
fsl/data/image.py
with
9 additions
and
0 deletions
fsl/data/image.py
+
9
−
0
View file @
cf1b038a
...
...
@@ -46,6 +46,8 @@ import numpy as np
import
nibabel
as
nib
import
nibabel.fileslice
as
fileslice
from
pathlib
import
Path
import
fsl.utils.meta
as
meta
import
fsl.transform.affine
as
affine
import
fsl.utils.notifier
as
notifier
...
...
@@ -1088,6 +1090,11 @@ class Image(Nifti):
nibImage
=
nib
.
load
(
image
,
**
kwargs
)
dataSource
=
image
saved
=
True
# The image parameter may be the name of an image file
if
isinstance
(
image
,
Path
):
nibImage
=
nib
.
load
(
image
,
**
kwargs
)
dataSource
=
str
(
image
)
saved
=
True
# Or a numpy array - we wrap it in a nibabel image,
# with an identity transformation (each voxel maps
...
...
@@ -1140,6 +1147,8 @@ class Image(Nifti):
# from disk, use the file name.
if
isinstance
(
image
,
six
.
string_types
):
name
=
removeExt
(
op
.
basename
(
image
))
if
isinstance
(
image
,
Path
):
name
=
image
.
name
# Or the image was created from a numpy array
elif
isinstance
(
image
,
np
.
ndarray
):
...
...
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