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
87bb9871
Commit
87bb9871
authored
10 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Location panel displays the displayed space for the currently selected image
parent
4e6f1818
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/data/image.py
+10
-4
10 additions, 4 deletions
fsl/data/image.py
fsl/fslview/controls/locationpanel.py
+54
-8
54 additions, 8 deletions
fsl/fslview/controls/locationpanel.py
fsl/fslview/strings.py
+7
-3
7 additions, 3 deletions
fsl/fslview/strings.py
with
71 additions
and
15 deletions
fsl/data/image.py
+
10
−
4
View file @
87bb9871
...
@@ -44,6 +44,10 @@ NIFTI_XFORM_ALIGNED_ANAT = 2
...
@@ -44,6 +44,10 @@ NIFTI_XFORM_ALIGNED_ANAT = 2
NIFTI_XFORM_TALAIRACH
=
3
NIFTI_XFORM_TALAIRACH
=
3
NIFTI_XFORM_MNI_152
=
4
NIFTI_XFORM_MNI_152
=
4
# My own code, used to indicate that the
# image is being displayed in voxel space
NIFTI_XFORM_VOXEL
=
5
def
_loadImageFile
(
filename
):
def
_loadImageFile
(
filename
):
"""
Given the name of an image file, loads it using nibabel.
"""
Given the name of an image file, loads it using nibabel.
...
@@ -395,14 +399,16 @@ class Image(props.HasProperties):
...
@@ -395,14 +399,16 @@ class Image(props.HasProperties):
# if the qform and sform codes don't
# if the qform and sform codes don't
# match, I don't know what to do
# match, I don't know what to do
if
sform_code
!=
qform_code
:
return
NIFTI_XFORM_UNKNOWN
if
sform_code
!=
qform_code
:
code
=
NIFTI_XFORM_UNKNOWN
# Invalid values
# Invalid values
elif
sform_code
>
4
:
return
NIFTI_XFORM_UNKNOWN
elif
sform_code
>
4
:
code
=
NIFTI_XFORM_UNKNOWN
elif
sform_code
<
0
:
return
NIFTI_XFORM_UNKNOWN
elif
sform_code
<
0
:
code
=
NIFTI_XFORM_UNKNOWN
# All is well
# All is well
else
:
return
sform_code
else
:
code
=
sform_code
return
int
(
code
)
def
getWorldOrientation
(
self
,
axis
):
def
getWorldOrientation
(
self
,
axis
):
...
...
This diff is collapsed.
Click to expand it.
fsl/fslview/controls/locationpanel.py
+
54
−
8
View file @
87bb9871
...
@@ -13,6 +13,7 @@ import numpy as np
...
@@ -13,6 +13,7 @@ import numpy as np
import
props
import
props
import
fsl.data.image
as
fslimage
import
fsl.fslview.controlpanel
as
controlpanel
import
fsl.fslview.controlpanel
as
controlpanel
import
imageselectpanel
as
imageselect
import
imageselectpanel
as
imageselect
...
@@ -48,12 +49,16 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
...
@@ -48,12 +49,16 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
controlpanel
.
ControlPanel
.
__init__
(
self
,
parent
,
imageList
,
displayCtx
)
controlpanel
.
ControlPanel
.
__init__
(
self
,
parent
,
imageList
,
displayCtx
)
self
.
_voxelPanel
=
wx
.
Panel
(
self
)
self
.
_voxelPanel
=
wx
.
Panel
(
self
)
self
.
_locationPanel
=
wx
.
Panel
(
self
)
self
.
_imageSelect
=
imageselect
.
ImageSelectPanel
(
self
.
_imageSelect
=
imageselect
.
ImageSelectPanel
(
self
,
imageList
,
displayCtx
)
self
,
imageList
,
displayCtx
)
self
.
_locationLabel
=
wx
.
StaticText
(
self
,
style
=
wx
.
ALIGN_LEFT
)
self
.
_locationLabel
=
wx
.
StaticText
(
self
.
_locationPanel
,
style
=
wx
.
ALIGN_LEFT
)
self
.
_spaceLabel
=
wx
.
StaticText
(
self
.
_locationPanel
,
style
=
wx
.
ALIGN_LEFT
)
self
.
_locationWidget
=
props
.
makeWidget
(
self
,
displayCtx
,
'
location
'
)
self
.
_locationWidget
=
props
.
makeWidget
(
self
,
displayCtx
,
'
location
'
)
self
.
_dividerLine1
=
wx
.
StaticLine
(
self
,
style
=
wx
.
LI_HORIZONTAL
)
self
.
_dividerLine1
=
wx
.
StaticLine
(
self
,
style
=
wx
.
LI_HORIZONTAL
)
...
@@ -69,13 +74,21 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
...
@@ -69,13 +74,21 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
style
=
wx
.
ALIGN_RIGHT
)
style
=
wx
.
ALIGN_RIGHT
)
self
.
_adjustFont
(
self
.
_locationLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_adjustFont
(
self
.
_locationLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_adjustFont
(
self
.
_spaceLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_adjustFont
(
self
.
_volumeLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_adjustFont
(
self
.
_volumeLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_adjustFont
(
self
.
_voxelLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_adjustFont
(
self
.
_voxelLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_adjustFont
(
self
.
_valueLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_adjustFont
(
self
.
_valueLabel
,
-
2
,
wx
.
FONTWEIGHT_LIGHT
)
self
.
_locationLabel
.
SetLabel
(
'
World location (mm)
'
)
self
.
_locationLabel
.
SetLabel
(
strings
.
locationPanelLocationLabel
)
self
.
_voxelLabel
.
SetLabel
(
'
Voxel coordinates
'
)
self
.
_voxelLabel
.
SetLabel
(
strings
.
locationPanelVoxelLabel
)
self
.
_volumeLabel
.
SetLabel
(
'
Volume (index)
'
)
self
.
_volumeLabel
.
SetLabel
(
strings
.
locationPanelVolumeLabel
)
self
.
_locationSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
_locationPanel
.
SetSizer
(
self
.
_locationSizer
)
self
.
_locationSizer
.
Add
(
self
.
_locationLabel
,
flag
=
wx
.
EXPAND
)
self
.
_locationSizer
.
Add
((
1
,
1
),
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
_locationSizer
.
Add
(
self
.
_spaceLabel
,
flag
=
wx
.
EXPAND
)
self
.
_voxelSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
_voxelSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
_voxelPanel
.
SetSizer
(
self
.
_voxelSizer
)
self
.
_voxelPanel
.
SetSizer
(
self
.
_voxelSizer
)
...
@@ -88,7 +101,7 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
...
@@ -88,7 +101,7 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
self
.
SetSizer
(
self
.
_sizer
)
self
.
SetSizer
(
self
.
_sizer
)
self
.
_sizer
.
Add
(
self
.
_imageSelect
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_imageSelect
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_location
Lab
el
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_location
Pan
el
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_locationWidget
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_locationWidget
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_dividerLine1
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_dividerLine1
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_voxelPanel
,
flag
=
wx
.
EXPAND
)
self
.
_sizer
.
Add
(
self
.
_voxelPanel
,
flag
=
wx
.
EXPAND
)
...
@@ -266,14 +279,22 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
...
@@ -266,14 +279,22 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
(which contains the image name), and sets the voxel location limits.
(which contains the image name), and sets the voxel location limits.
"""
"""
# Make sure that a listener is registered on the
# selected image, so that the space label can be
# updated when its transformation matrix is changed
for
i
,
img
in
enumerate
(
self
.
_imageList
):
img
.
removeListener
(
'
transform
'
,
self
.
_name
)
if
i
==
self
.
_displayCtx
.
selectedImage
:
img
.
addListener
(
'
transform
'
,
self
.
_name
,
self
.
_spaceChanged
)
self
.
_spaceChanged
()
if
len
(
self
.
_imageList
)
==
0
:
if
len
(
self
.
_imageList
)
==
0
:
self
.
_updateVoxelValue
(
''
)
self
.
_updateVoxelValue
(
''
)
self
.
_voxelPanel
.
Layout
()
self
.
_voxelPanel
.
Layout
()
return
return
image
=
self
.
_imageList
[
self
.
_displayCtx
.
selectedImage
]
image
=
self
.
_imageList
[
self
.
_displayCtx
.
selectedImage
]
self
.
_voxelPanel
.
Layout
()
oldLoc
=
self
.
_displayCtx
.
location
.
xyz
oldLoc
=
self
.
_displayCtx
.
location
.
xyz
voxLoc
=
np
.
round
(
image
.
worldToVox
([
oldLoc
]))[
0
]
voxLoc
=
np
.
round
(
image
.
worldToVox
([
oldLoc
]))[
0
]
...
@@ -289,6 +310,31 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
...
@@ -289,6 +310,31 @@ class LocationPanel(controlpanel.ControlPanel, props.HasProperties):
# coordinates.
# coordinates.
self
.
_displayCtx
.
location
.
xyz
=
oldLoc
self
.
_displayCtx
.
location
.
xyz
=
oldLoc
def
_spaceChanged
(
self
,
*
a
):
"""
Called when the transformation matrix of the currently selected
image changes. Updates the
'
space
'
label to reflect the change.
"""
if
len
(
self
.
_imageList
)
==
0
:
self
.
_spaceLabel
.
SetLabel
(
''
)
self
.
_locationPanel
.
Layout
()
return
image
=
self
.
_imageList
[
self
.
_displayCtx
.
selectedImage
]
if
image
.
transform
==
'
affine
'
:
spaceLabel
=
strings
.
imageSpaceLabels
[
image
.
getXFormCode
()]
else
:
spaceLabel
=
strings
.
imageSpaceLabels
[
fslimage
.
NIFTI_XFORM_VOXEL
]
spaceLabel
=
strings
.
locationPanelSpaceLabel
.
format
(
spaceLabel
)
self
.
_spaceLabel
.
SetLabel
(
spaceLabel
)
self
.
_locationPanel
.
Layout
()
# strings imports locationpanel, so this is
# strings imports locationpanel, so this is
# at the bottom to avoid a circular import
# at the bottom to avoid a circular import
import
fsl.fslview.strings
as
strings
import
fsl.fslview.strings
as
strings
This diff is collapsed.
Click to expand it.
fsl/fslview/strings.py
+
7
−
3
View file @
87bb9871
#!/usr/bin/env python
#!/usr/bin/env python
#
#
# strings.py - Labels used throughout FSLView.
# strings.py - Labels used throughout
various parts of
FSLView.
#
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
#
...
@@ -50,8 +50,11 @@ viewPanelConfigMenuText = {
...
@@ -50,8 +50,11 @@ viewPanelConfigMenuText = {
orthoConfigMenu
=
'
{} display
'
orthoConfigMenu
=
'
{} display
'
lightBoxConfigMenu
=
'
{} display
'
lightBoxConfigMenu
=
'
{} display
'
locationPanelOutOfBounds
=
'
Out of bounds
'
locationPanelOutOfBounds
=
'
Out of bounds
'
locationPanelSpaceLabel
=
'
{} space
'
locationPanelLocationLabel
=
'
World location (mm)
'
locationPanelVoxelLabel
=
'
Voxel coordinates
'
locationPanelVolumeLabel
=
'
Volume (index)
'
imageAxisLowLongLabels
=
{
imageAxisLowLongLabels
=
{
...
@@ -91,6 +94,7 @@ imageAxisHighShortLabels = {
...
@@ -91,6 +94,7 @@ imageAxisHighShortLabels = {
fslimage
.
ORIENT_UNKNOWN
:
'
?
'
}
fslimage
.
ORIENT_UNKNOWN
:
'
?
'
}
imageSpaceLabels
=
{
imageSpaceLabels
=
{
fslimage
.
NIFTI_XFORM_VOXEL
:
'
Voxel
'
,
fslimage
.
NIFTI_XFORM_UNKNOWN
:
'
Unknown
'
,
fslimage
.
NIFTI_XFORM_UNKNOWN
:
'
Unknown
'
,
fslimage
.
NIFTI_XFORM_SCANNER_ANAT
:
'
Scanner anatomical
'
,
fslimage
.
NIFTI_XFORM_SCANNER_ANAT
:
'
Scanner anatomical
'
,
fslimage
.
NIFTI_XFORM_ALIGNED_ANAT
:
'
Aligned anatomical
'
,
fslimage
.
NIFTI_XFORM_ALIGNED_ANAT
:
'
Aligned anatomical
'
,
...
...
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