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
c24eaeca
Commit
c24eaeca
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Nifti.meta* methods are now in a base-class. Also used by TriangleMesh.
parent
52d7a125
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/data/image.py
+4
-48
4 additions, 48 deletions
fsl/data/image.py
fsl/data/mesh.py
+2
-1
2 additions, 1 deletion
fsl/data/mesh.py
fsl/utils/meta.py
+64
-0
64 additions, 0 deletions
fsl/utils/meta.py
with
70 additions
and
49 deletions
fsl/data/image.py
+
4
−
48
View file @
c24eaeca
...
@@ -46,6 +46,7 @@ import scipy.ndimage as ndimage
...
@@ -46,6 +46,7 @@ import scipy.ndimage as ndimage
import
nibabel
as
nib
import
nibabel
as
nib
import
nibabel.fileslice
as
fileslice
import
nibabel.fileslice
as
fileslice
import
fsl.utils.meta
as
meta
import
fsl.utils.transform
as
transform
import
fsl.utils.transform
as
transform
import
fsl.utils.notifier
as
notifier
import
fsl.utils.notifier
as
notifier
import
fsl.utils.memoize
as
memoize
import
fsl.utils.memoize
as
memoize
...
@@ -57,7 +58,7 @@ import fsl.data.imagewrapper as imagewrapper
...
@@ -57,7 +58,7 @@ import fsl.data.imagewrapper as imagewrapper
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
class
Nifti
(
notifier
.
Notifier
):
class
Nifti
(
notifier
.
Notifier
,
meta
.
Meta
):
"""
The ``Nifti`` class is intended to be used as a base class for
"""
The ``Nifti`` class is intended to be used as a base class for
things which either are, or are associated with, a NIFTI image.
things which either are, or are associated with, a NIFTI image.
The ``Nifti`` class is intended to represent information stored in
The ``Nifti`` class is intended to represent information stored in
...
@@ -162,19 +163,8 @@ class Nifti(notifier.Notifier):
...
@@ -162,19 +163,8 @@ class Nifti(notifier.Notifier):
**Metadata**
**Metadata**
The ``Image`` class has a handful of methods allowing you to add and access
The ``Image`` class inherits from the :class:`.Meta` class - its methods
additional metadata associated with the image. These methods are used by
can be used to store and query any meta-data associated with the image.
the :class:`.DicomImage` and :class:`.MGHImage` to store additional
meta-data that cannot be stored in the NIFTI header:
.. autosummary::
:nosignatures:
metaKeys
metaValues
metaItems
getMeta
setMeta
**Notification**
**Notification**
...
@@ -212,7 +202,6 @@ class Nifti(notifier.Notifier):
...
@@ -212,7 +202,6 @@ class Nifti(notifier.Notifier):
worldToVoxMat
=
transform
.
invert
(
voxToWorldMat
)
worldToVoxMat
=
transform
.
invert
(
voxToWorldMat
)
self
.
header
=
header
self
.
header
=
header
self
.
__meta
=
collections
.
OrderedDict
()
self
.
__shape
=
shape
self
.
__shape
=
shape
self
.
__intent
=
header
.
get
(
'
intent_code
'
,
self
.
__intent
=
header
.
get
(
'
intent_code
'
,
constants
.
NIFTI_INTENT_NONE
)
constants
.
NIFTI_INTENT_NONE
)
...
@@ -687,39 +676,6 @@ class Nifti(notifier.Notifier):
...
@@ -687,39 +676,6 @@ class Nifti(notifier.Notifier):
return
code
return
code
def
metaKeys
(
self
):
"""
Returns the keys contained in the image metadata dictionary
(``dict.keys``).
"""
return
self
.
__meta
.
keys
()
def
metaValues
(
self
):
"""
Returns the values contained in the image metadata dictionary
(``dict.values``).
"""
return
self
.
__meta
.
values
()
def
metaItems
(
self
):
"""
Returns the items contained in the image metadata dictionary
(``dict.items``).
"""
return
self
.
__meta
.
items
()
def
getMeta
(
self
,
*
args
,
**
kwargs
):
"""
Returns the metadata value with the specified key (``dict.get``).
"""
return
self
.
__meta
.
get
(
*
args
,
**
kwargs
)
def
setMeta
(
self
,
*
args
,
**
kwargs
):
"""
Add some metadata with the specified key (``dict.__setitem__``).
"""
self
.
__meta
.
__setitem__
(
*
args
,
**
kwargs
)
class
Image
(
Nifti
):
class
Image
(
Nifti
):
"""
Class which represents a NIFTI image. Internally, the image is
"""
Class which represents a NIFTI image. Internally, the image is
loaded/stored using a :mod:`nibabel.nifti1.Nifti1Image` or
loaded/stored using a :mod:`nibabel.nifti1.Nifti1Image` or
...
...
This diff is collapsed.
Click to expand it.
fsl/data/mesh.py
+
2
−
1
View file @
c24eaeca
...
@@ -27,6 +27,7 @@ import numpy as np
...
@@ -27,6 +27,7 @@ import numpy as np
import
six
import
six
import
fsl.utils.meta
as
meta
import
fsl.utils.memoize
as
memoize
import
fsl.utils.memoize
as
memoize
import
fsl.utils.transform
as
transform
import
fsl.utils.transform
as
transform
...
@@ -36,7 +37,7 @@ from . import image as fslimage
...
@@ -36,7 +37,7 @@ from . import image as fslimage
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
class
TriangleMesh
(
object
):
class
TriangleMesh
(
meta
.
Meta
):
"""
The ``TriangleMesh`` class represents a 3D model. A mesh is defined by a
"""
The ``TriangleMesh`` class represents a 3D model. A mesh is defined by a
collection of ``N`` vertices, and ``M`` triangles. The triangles are
collection of ``N`` vertices, and ``M`` triangles. The triangles are
defined by ``(M, 3)`` indices into the list of vertices.
defined by ``(M, 3)`` indices into the list of vertices.
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/meta.py
0 → 100644
+
64
−
0
View file @
c24eaeca
#!/usr/bin/env python
#
# meta.py - The Meta class/mixin.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""
This module provides the :class:`Meta` class.
"""
import
collections
class
Meta
(
object
):
"""
The ``Meta`` class is intended to be used as a mixin for other classes. It
is simply a wrapper for a dictionary of key-value pairs.
It has a handful of methods allowing you to add and access additional
metadata associated with an object.
.. autosummary::
:nosignatures:
metaKeys
metaValues
metaItems
getMeta
setMeta
"""
def
__init__
(
self
):
self
.
__meta
=
collections
.
OrderedDict
()
def
metaKeys
(
self
):
"""
Returns the keys contained in the metadata dictionary
(``dict.keys``).
"""
return
self
.
__meta
.
keys
()
def
metaValues
(
self
):
"""
Returns the values contained in the metadata dictionary
(``dict.values``).
"""
return
self
.
__meta
.
values
()
def
metaItems
(
self
):
"""
Returns the items contained in the metadata dictionary
(``dict.items``).
"""
return
self
.
__meta
.
items
()
def
getMeta
(
self
,
*
args
,
**
kwargs
):
"""
Returns the metadata value with the specified key (``dict.get``).
"""
return
self
.
__meta
.
get
(
*
args
,
**
kwargs
)
def
setMeta
(
self
,
*
args
,
**
kwargs
):
"""
Add some metadata with the specified key (``dict.__setitem__``).
"""
self
.
__meta
.
__setitem__
(
*
args
,
**
kwargs
)
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