@@ -797,6 +797,49 @@ def test_plot_topomap_opm():
797797 assert len (fig_evoked .axes ) == 5
798798
799799
800+ def test_prepare_topomap_plot_opm_non_quspin_coils ():
801+ """Test colocated OPM handling for non-QuSpin OPM coil types."""
802+ ch_names = ["OPM001" , "OPM002" , "OPM003" , "OPM004" , "OPM005" , "OPM006" ]
803+ info = create_info (ch_names , 1000.0 , ch_types = "mag" )
804+ # Two colocated trios with different orientations.
805+ positions = np .array (
806+ [
807+ [0.03 , 0.00 , 0.05 ],
808+ [0.03 , 0.00 , 0.05 ],
809+ [0.03 , 0.00 , 0.05 ],
810+ [- 0.03 , 0.00 , 0.05 ],
811+ [- 0.03 , 0.00 , 0.05 ],
812+ [- 0.03 , 0.00 , 0.05 ],
813+ ]
814+ )
815+ orientations = np .array (
816+ [
817+ [0.5145 , 0.0000 , 0.8575 ], # radial-ish
818+ [0.0000 , 1.0000 , 0.0000 ], # tangential-ish
819+ [0.0000 , 0.0000 , 1.0000 ], # tangential-ish
820+ [- 0.5145 , 0.0000 , 0.8575 ], # radial-ish
821+ [0.0000 , 1.0000 , 0.0000 ], # tangential-ish
822+ [0.0000 , 0.0000 , 1.0000 ], # tangential-ish
823+ ]
824+ )
825+ with info ._unlock ():
826+ for idx , ch in enumerate (info ["chs" ]):
827+ ch ["coil_type" ] = FIFF .FIFFV_COIL_FIELDLINE_OPM_MAG_GEN1
828+ ch ["loc" ][:3 ] = positions [idx ]
829+ ch ["loc" ][9 :12 ] = orientations [idx ]
830+ evoked = EvokedArray (np .zeros ((len (ch_names ), 5 )), info )
831+
832+ picks , _pos , merge_channels , merged_names , * _ = topomap ._prepare_topomap_plot (
833+ evoked , "mag"
834+ )
835+
836+ assert len (picks ) == 6
837+ assert merge_channels
838+ assert len (merge_channels ) == 2
839+ assert all (len (set_ ) == 3 for set_ in merge_channels )
840+ assert sum (name .endswith ("MERGE-REMOVE" ) for name in merged_names ) == 4
841+
842+
800843def test_plot_topomap_nirs_overlap (fnirs_epochs ):
801844 """Test plotting nirs topomap with overlapping channels (gh-7414)."""
802845 fig = fnirs_epochs ["A" ].average (picks = "hbo" ).plot_topomap ()
0 commit comments