@@ -122,7 +122,7 @@ def make_mux_table_array(mux_information) -> np.array:
122122
123123 Returns
124124 -------
125- mux_channels_array : np.array
125+ adc_groups_array : np.array
126126 Array of which channels are in each adc group, shaped (number of `adc`s, number of channels in each `adc`).
127127 """
128128
@@ -135,12 +135,12 @@ def make_mux_table_array(mux_information) -> np.array:
135135 num_adcs , num_channels_per_adc = map (int , adc_info [1 :].split ("," ))
136136
137137 # Then remove the brackets, and split using " " to get each integer as a list
138- mux_channels = [
138+ adc_groups = [
139139 np .array (each_mux .replace ("(" , "" ).replace (")" , "" ).split (" " )).astype ("int" ) for each_mux in split_mux
140140 ]
141- mux_channels_array = np .transpose (np .array (mux_channels ))
141+ adc_groups_array = np .transpose (np .array (adc_groups ))
142142
143- return num_adcs , num_channels_per_adc , mux_channels_array
143+ return num_adcs , num_channels_per_adc , adc_groups_array
144144
145145
146146def get_probe_contour_vertices (shank_width , tip_length , probe_length ) -> list :
@@ -159,12 +159,12 @@ def get_probe_contour_vertices(shank_width, tip_length, probe_length) -> list:
159159 | |
160160 | |
161161 B +-------------------------------+ D (y = 0)
162- \ /
163- \ Tip region /
164- \ (tip_length) /
165- \ /
166- \ /
167- \ /
162+ \\ /
163+ \\ Tip region /
164+ \\ (tip_length) /
165+ \\ /
166+ \\ /
167+ \\ /
168168 +-----------------+ C (y = -tip_length)
169169
170170 This function returns the vertices in the order [A, B, C, D, E] as a list of (x, y) coordinates.
@@ -322,22 +322,29 @@ def _make_npx_probe_from_description(probe_description, model_name, elec_ids, sh
322322
323323 # set other key metadata annotations
324324 probe .annotate (
325- adc_bit_depth = probe_description ["adc_bit_depth" ],
326- num_readout_channels = probe_description ["num_readout_channels" ],
325+ adc_bit_depth = int (probe_description ["adc_bit_depth" ]),
326+ num_readout_channels = int (probe_description ["num_readout_channels" ]),
327+ ap_sample_frequency_hz = float (probe_description ["ap_sample_frequency_hz" ]),
328+ lf_sample_frequency_hz = float (probe_description ["lf_sample_frequency_hz" ]),
327329 )
328330
329331 # annotate with MUX table
330332 if mux_info is not None :
331333 # annotate each contact with its mux channel
332334 num_adcs , num_channels_per_adc , mux_table = make_mux_table_array (mux_info )
333335 num_contacts = positions .shape [0 ]
334- mux_channels = np .zeros (num_contacts , dtype = "int64" )
335- for adc_idx , mux_channels_per_adc in enumerate (mux_table ):
336- mux_channels_per_adc = mux_channels_per_adc [mux_channels_per_adc < num_contacts ]
337- mux_channels [mux_channels_per_adc ] = adc_idx
336+ # ADC group: which adc is used for each contact
337+ adc_groups = np .zeros (num_contacts , dtype = "int64" )
338+ # ADC sample order: order of sampling of the contact in the adc group
339+ adc_sample_order = np .zeros (num_contacts , dtype = "int64" )
340+ for adc_idx , adc_groups_per_adc in enumerate (mux_table ):
341+ adc_groups_per_adc = adc_groups_per_adc [adc_groups_per_adc < num_contacts ]
342+ adc_groups [adc_groups_per_adc ] = adc_idx
343+ adc_sample_order [adc_groups_per_adc ] = np .arange (len (adc_groups_per_adc ))
338344 probe .annotate (num_adcs = num_adcs )
339345 probe .annotate (num_channels_per_adc = num_channels_per_adc )
340- probe .annotate_contacts (mux_channels = mux_channels )
346+ probe .annotate_contacts (adc_group = adc_groups )
347+ probe .annotate_contacts (adc_sample_order = adc_sample_order )
341348
342349 return probe
343350
@@ -1115,23 +1122,19 @@ def read_openephys(
11151122
11161123 if probe is None :
11171124 # check if subset of channels
1118- chans_saved = get_saved_channel_indices_from_openephys_settings (settings_file , stream_name = stream_name )
11191125 shank_ids = np_probe_info ["shank_ids" ]
11201126 elec_ids = np_probe_info ["elec_ids" ]
11211127 pt_metadata = np_probe_info ["pt_metadata" ]
11221128 mux_info = np_probe_info ["mux_info" ]
11231129
1124- # if a recording state is found, slice probe
1125- if chans_saved is not None :
1126- positions = positions [chans_saved ]
1127- if shank_ids is not None :
1128- shank_ids = np .array (shank_ids )[chans_saved ]
1129- if elec_ids is not None :
1130- elec_ids = np .array (elec_ids )[chans_saved ]
1131-
11321130 probe = _make_npx_probe_from_description (
11331131 pt_metadata , probe_part_number , elec_ids , shank_ids = shank_ids , mux_info = mux_info
11341132 )
1133+
1134+ chans_saved = get_saved_channel_indices_from_openephys_settings (settings_file , stream_name = stream_name )
1135+ if chans_saved is not None :
1136+ probe = probe .get_slice (chans_saved )
1137+
11351138 probe .serial_number = np_probe_info ["serial_number" ]
11361139 probe .name = np_probe_info ["name" ]
11371140
0 commit comments