@@ -29,6 +29,8 @@ def update_real_space_view(self, reset=False):
29
29
"Integrating" ,
30
30
"Maximum" ,
31
31
"CoM" ,
32
+ "CoM X" ,
33
+ "CoM Y" ,
32
34
"iCoM" ,
33
35
], detector_mode
34
36
@@ -50,7 +52,8 @@ def update_real_space_view(self, reset=False):
50
52
if detector_shape == "Rectangular" :
51
53
# Get slices corresponding to ROI
52
54
slices , transforms = self .virtual_detector_roi .getArraySlice (
53
- self .datacube .data [0 , 0 , :, :], self .diffraction_space_widget .getImageItem ()
55
+ self .datacube .data [0 , 0 , :, :].T ,
56
+ self .diffraction_space_widget .getImageItem (),
54
57
)
55
58
slice_y , slice_x = slices
56
59
@@ -156,6 +159,10 @@ def update_real_space_view(self, reset=False):
156
159
157
160
if detector_mode == "CoM" :
158
161
vimg = CoMx + 1.0j * CoMy
162
+ elif detector_mode == "CoM X" :
163
+ vimg = CoMx
164
+ elif detector_mode == "CoM Y" :
165
+ vimg = CoMy
159
166
elif detector_mode == "iCoM" :
160
167
dpc = py4DSTEM .process .phase .DPC (verbose = False )
161
168
dpc .preprocess (
@@ -313,7 +320,7 @@ def update_diffraction_space_view(self, reset=False):
313
320
elif detector_shape == "Rectangular" :
314
321
# Get slices corresponding to ROI
315
322
slices , _ = self .real_space_rect_selector .getArraySlice (
316
- np .zeros ((self .datacube .Rshape )), self .real_space_widget .getImageItem ()
323
+ np .zeros ((self .datacube .Rshape )). T , self .real_space_widget .getImageItem ()
317
324
)
318
325
slice_y , slice_x = slices
319
326
@@ -401,12 +408,18 @@ def update_realspace_detector(self):
401
408
)
402
409
assert detector_shape in ["Point" , "Rectangular" ], detector_shape
403
410
404
- if self .datacube is None :
405
- return
411
+ main_pen = {"color" : "g" , "width" : 6 }
412
+ handle_pen = {"color" : "r" , "width" : 9 }
413
+ hover_pen = {"color" : "c" , "width" : 6 }
414
+ hover_handle = {"color" : "c" , "width" : 9 }
406
415
407
- x , y = self .datacube .data .shape [:2 ]
408
- x0 , y0 = x // 2 , y // 2
409
- xr , yr = x / 10 , y / 10
416
+ if self .datacube is None :
417
+ x0 , y0 = 0 , 0
418
+ xr , yr = 4 , 4
419
+ else :
420
+ x , y = self .datacube .data .shape [2 :]
421
+ y0 , x0 = x // 2 , y // 2
422
+ xr , yr = (np .minimum (x , y ) / 10 ,) * 2
410
423
411
424
# Remove existing detector
412
425
if hasattr (self , "real_space_point_selector" ):
@@ -416,19 +429,27 @@ def update_realspace_detector(self):
416
429
self .real_space_widget .view .scene ().removeItem (self .real_space_rect_selector )
417
430
self .real_space_rect_selector = None
418
431
419
- # Rectangular detector
432
+ # Point detector
420
433
if detector_shape == "Point" :
421
434
self .real_space_point_selector = pg_point_roi (
422
435
self .real_space_widget .getView (),
423
436
center = (x0 - 0.5 , y0 - 0.5 ),
437
+ pen = main_pen ,
438
+ hoverPen = hover_pen ,
424
439
)
425
440
self .real_space_point_selector .sigRegionChanged .connect (
426
441
partial (self .update_diffraction_space_view , False )
427
442
)
428
443
444
+ # Rectangular detector
429
445
elif detector_shape == "Rectangular" :
430
446
self .real_space_rect_selector = pg .RectROI (
431
- [int (x0 - xr / 2 ), int (y0 - yr / 2 )], [int (xr ), int (yr )], pen = (3 , 9 )
447
+ [int (x0 - xr / 2 ), int (y0 - yr / 2 )],
448
+ [int (xr ), int (yr )],
449
+ pen = main_pen ,
450
+ handlePen = handle_pen ,
451
+ hoverPen = hover_pen ,
452
+ handleHoverPen = hover_handle ,
432
453
)
433
454
self .real_space_widget .getView ().addItem (self .real_space_rect_selector )
434
455
self .real_space_rect_selector .sigRegionChangeFinished .connect (
@@ -447,12 +468,18 @@ def update_diffraction_detector(self):
447
468
detector_shape = self .detector_shape_group .checkedAction ().text ().strip ("&" )
448
469
assert detector_shape in ["Point" , "Rectangular" , "Circle" , "Annulus" ]
449
470
450
- if self .datacube is None :
451
- return
471
+ main_pen = {"color" : "g" , "width" : 6 }
472
+ handle_pen = {"color" : "r" , "width" : 9 }
473
+ hover_pen = {"color" : "c" , "width" : 6 }
474
+ hover_handle = {"color" : "c" , "width" : 9 }
452
475
453
- x , y = self .datacube .data .shape [2 :]
454
- x0 , y0 = x // 2 , y // 2
455
- xr , yr = x / 10 , y / 10
476
+ if self .datacube is None :
477
+ x0 , y0 = 0 , 0
478
+ xr , yr = 4 , 4
479
+ else :
480
+ x , y = self .datacube .data .shape [2 :]
481
+ y0 , x0 = x // 2 , y // 2
482
+ xr , yr = (np .minimum (x , y ) / 10 ,) * 2
456
483
457
484
# Remove existing detector
458
485
if hasattr (self , "virtual_detector_point" ):
@@ -479,6 +506,8 @@ def update_diffraction_detector(self):
479
506
self .virtual_detector_point = pg_point_roi (
480
507
self .diffraction_space_widget .getView (),
481
508
center = (x0 - 0.5 , y0 - 0.5 ),
509
+ pen = main_pen ,
510
+ hoverPen = hover_pen ,
482
511
)
483
512
self .virtual_detector_point .sigRegionChanged .connect (
484
513
partial (self .update_real_space_view , False )
@@ -487,7 +516,12 @@ def update_diffraction_detector(self):
487
516
# Rectangular detector
488
517
elif detector_shape == "Rectangular" :
489
518
self .virtual_detector_roi = pg .RectROI (
490
- [int (x0 - xr / 2 ), int (y0 - yr / 2 )], [int (xr ), int (yr )], pen = (3 , 9 )
519
+ [int (x0 - xr / 2 ), int (y0 - yr / 2 )],
520
+ [int (xr ), int (yr )],
521
+ pen = main_pen ,
522
+ handlePen = handle_pen ,
523
+ hoverPen = hover_pen ,
524
+ handleHoverPen = hover_handle ,
491
525
)
492
526
self .diffraction_space_widget .getView ().addItem (self .virtual_detector_roi )
493
527
self .virtual_detector_roi .sigRegionChangeFinished .connect (
@@ -497,7 +531,12 @@ def update_diffraction_detector(self):
497
531
# Circular detector
498
532
elif detector_shape == "Circle" :
499
533
self .virtual_detector_roi = pg .CircleROI (
500
- [int (x0 - xr / 2 ), int (y0 - yr / 2 )], [int (xr ), int (yr )], pen = (3 , 9 )
534
+ [int (x0 - xr / 2 ), int (y0 - yr / 2 )],
535
+ [int (xr ), int (yr )],
536
+ pen = main_pen ,
537
+ handlePen = handle_pen ,
538
+ hoverPen = hover_pen ,
539
+ handleHoverPen = hover_handle ,
501
540
)
502
541
self .diffraction_space_widget .getView ().addItem (self .virtual_detector_roi )
503
542
self .virtual_detector_roi .sigRegionChangeFinished .connect (
@@ -508,15 +547,23 @@ def update_diffraction_detector(self):
508
547
elif detector_shape == "Annulus" :
509
548
# Make outer detector
510
549
self .virtual_detector_roi_outer = pg .CircleROI (
511
- [int (x0 - xr ), int (y0 - yr )], [int (2 * xr ), int (2 * yr )], pen = (3 , 9 )
550
+ [int (x0 - xr ), int (y0 - yr )],
551
+ [int (2 * xr ), int (2 * yr )],
552
+ pen = main_pen ,
553
+ handlePen = handle_pen ,
554
+ hoverPen = hover_pen ,
555
+ handleHoverPen = hover_handle ,
512
556
)
513
557
self .diffraction_space_widget .getView ().addItem (self .virtual_detector_roi_outer )
514
558
515
559
# Make inner detector
516
560
self .virtual_detector_roi_inner = pg .CircleROI (
517
561
[int (x0 - xr / 2 ), int (y0 - yr / 2 )],
518
562
[int (xr ), int (yr )],
519
- pen = (4 , 9 ),
563
+ pen = main_pen ,
564
+ hoverPen = hover_pen ,
565
+ handlePen = handle_pen ,
566
+ handleHoverPen = hover_handle ,
520
567
movable = False ,
521
568
)
522
569
self .diffraction_space_widget .getView ().addItem (self .virtual_detector_roi_inner )
@@ -623,8 +670,8 @@ def update_tooltip(self):
623
670
if scene .getView ().rect ().contains (pos_in_scene ):
624
671
pos_in_data = scene .view .mapSceneToView (pos_in_scene )
625
672
626
- y = int (np .clip (np .floor (pos_in_data .x ()), 0 , data .shape [0 ] - 1 ))
627
- x = int (np .clip (np .floor (pos_in_data .y ()), 0 , data .shape [1 ] - 1 ))
673
+ y = int (np .clip (np .floor (pos_in_data .x ()), 0 , data .shape [1 ] - 1 ))
674
+ x = int (np .clip (np .floor (pos_in_data .y ()), 0 , data .shape [0 ] - 1 ))
628
675
629
676
if np .isrealobj (data ):
630
677
display_text = f"[{ x } ,{ y } ]: { data [x ,y ]:.5g} "
0 commit comments