@@ -118,6 +118,51 @@ def _mgh_or_standard(basename, head_size, coord_frame="unknown"):
118118 )
119119
120120
121+ def _meg (basename , head_size ):
122+ fname = op .join (MONTAGE_PATH , basename )
123+ # Create a simple class instance instead of a list
124+ class CustomMontage :
125+ pass
126+
127+ montage = CustomMontage ()
128+
129+ # Read the file
130+ with open (fname ) as f :
131+ # Skip header line
132+ header = f .readline ().strip ().split ()
133+
134+ ch_names = []
135+ ch_types = []
136+ pos = []
137+ ori = []
138+
139+ for line in f :
140+ parts = line .strip ().split ()
141+ ch_names .append (parts [0 ])
142+ ch_types .append (parts [1 ])
143+ pos .append ([float (parts [2 ]), float (parts [3 ]), float (parts [4 ])])
144+ ori .append ([float (parts [5 ]), float (parts [6 ]), float (parts [7 ])])
145+
146+ pos = np .array (pos )
147+
148+ montage .ch_names = ch_names
149+
150+ # # Create a dictionary mapping channel names to positions
151+ # montage.ch_pos = dict(zip(ch_names, pos))
152+ montage .ch_pos = pos
153+ # # TODO - make_dig_montage():
154+ # For custom montages without fiducials, this parameter must be set
155+ # to ``'head'``. ->
156+ # "kind": FIFF.FIFFV_POINT_EEG, ->
157+ # dig names each chennel as EEG #1 ...
158+
159+ # These aren't standard DigMontage attributes but can be useful
160+ montage .ch_types = ch_types
161+ montage .ori = ori
162+
163+ return montage
164+
165+
121166standard_montage_look_up_table = {
122167 "EGI_256" : _egi_256 ,
123168 "easycap-M1" : partial (_easycap , basename = "easycap-M1.txt" ),
@@ -165,6 +210,8 @@ def _mgh_or_standard(basename, head_size, coord_frame="unknown"):
165210 "brainproducts-RNP-BA-128" : partial (
166211 _easycap , basename = "brainproducts-RNP-BA-128.txt"
167212 ),
213+ "ctf275" : partial (_meg , basename = "ctf275.txt" ),
214+ "neuromag306" : partial (_meg , basename = "neuromag306.txt" ),
168215}
169216
170217
0 commit comments