@@ -103,15 +103,15 @@ def __init__(self, data, affine=None, axes=None, title=None):
103
103
# | | | |
104
104
# | | | |
105
105
# +---------+ +---------+
106
- # A --> <-- R
106
+ # A --> R -->
107
107
# ^ +---------+ +---------+
108
108
# | | | | |
109
109
# | Axial | | Vol |
110
110
# A | 2 | | 3 |
111
111
# | | | |
112
112
# | | | |
113
113
# +---------+ +---------+
114
- # <-- R <-- t -->
114
+ # R --> <-- t -->
115
115
116
116
fig , axes = plt .subplots (2 , 2 )
117
117
fig .set_size_inches ((8 , 8 ), forward = True )
@@ -419,7 +419,7 @@ def _set_position(self, x, y, z, notify=True):
419
419
# deal with crosshairs
420
420
loc = self ._data_idx [ii ]
421
421
if self ._flips [ii ]:
422
- loc = self ._sizes [ii ] - loc
422
+ loc = self ._sizes [ii ] - 1 - loc
423
423
loc = [loc ] * 2
424
424
if ii == 0 :
425
425
self ._crosshairs [2 ]['vert' ].set_xdata (loc )
@@ -468,12 +468,17 @@ def _on_scroll(self, event):
468
468
dv *= 1.0 if event .button == 'up' else - 1.0
469
469
dv *= - 1 if self ._flips [ii ] else 1
470
470
val = self ._data_idx [ii ] + dv
471
+
471
472
if ii == 3 :
472
473
self ._set_volume_index (val )
473
474
else :
474
- coords = [self ._data_idx [k ] for k in range (3 )] + [ 1.0 ]
475
+ coords = [self ._data_idx [k ] for k in range (3 )]
475
476
coords [ii ] = val
476
- self ._set_position (* np .dot (self ._affine , coords )[:3 ])
477
+ coords_ordered = [0 , 0 , 0 , 1 ]
478
+ for k in range (3 ):
479
+ coords_ordered [self ._order [k ]] = coords [k ]
480
+ position = np .dot (self ._affine , coords_ordered )[:3 ]
481
+ self ._set_position (* position )
477
482
self ._draw ()
478
483
479
484
def _on_mouse (self , event ):
@@ -488,18 +493,19 @@ def _on_mouse(self, event):
488
493
self ._set_volume_index (event .xdata )
489
494
else :
490
495
# translate click xdata/ydata to physical position
491
- xax , yax = [[1 , 2 ], [0 , 2 ], [0 , 1 ]][ii ]
496
+ xax , yax = [[self ._order [1 ], self ._order [2 ]],
497
+ [self ._order [0 ], self ._order [2 ]],
498
+ [self ._order [0 ], self ._order [1 ]]][ii ]
492
499
x , y = event .xdata , event .ydata
493
- x = self ._sizes [xax ] - x if self ._flips [xax ] else x
494
- y = self ._sizes [yax ] - y if self ._flips [yax ] else y
500
+ x = self ._sizes [xax ] - x - 1 if self ._flips [xax ] else x
501
+ y = self ._sizes [yax ] - y - 1 if self ._flips [yax ] else y
495
502
idxs = np .ones (4 )
496
503
idxs [xax ] = x
497
504
idxs [yax ] = y
498
- idxs [ii ] = self ._data_idx [ii ]
499
- idxs [:3 ] = idxs [self ._order ]
500
- self ._set_position (* np .dot (self ._affine , idxs )[:3 ])
505
+ idxs [self ._order [ii ]] = self ._data_idx [ii ]
506
+ self ._set_position (* np .dot (self ._affine , idxs )[:3 ])
501
507
self ._draw ()
502
-
508
+
503
509
def _on_keypress (self , event ):
504
510
"""Handle mpl keypress events"""
505
511
if event .key is not None and 'escape' in event .key :
0 commit comments