@@ -81,9 +81,9 @@ def test_add_electrode_data_berke_probe(dummy_logger):
8181 metadata ["ephys" ] = {}
8282 metadata ["ephys" ]["impedance_file_path" ] = "tests/test_data/processed_ephys/impedance.csv"
8383 metadata ["ephys" ]["electrodes_location" ] = "Hippocampus CA1"
84- metadata ["ephys" ]["targeted_x" ] = 4.5 # AP in mm
85- metadata ["ephys" ]["targeted_y" ] = 2.2 # ML in mm
86- metadata ["ephys" ]["targeted_z" ] = 2.0 # DV in mm
84+ metadata ["ephys" ]["targeted_x" ] = 4.5 # AP in mm
85+ metadata ["ephys" ]["targeted_y" ] = 2.2 # ML in mm
86+ metadata ["ephys" ]["targeted_z" ] = - 2.0 # DV in mm
8787 metadata ["ephys" ]["probe" ] = ["256-ch Silicon Probe, 3mm length, 66um pitch" ]
8888 metadata ["ephys" ]["plug_order" ] = "chip_first"
8989
@@ -146,7 +146,7 @@ def test_add_electrode_data_berke_probe(dummy_logger):
146146 assert egroup .location == "Hippocampus CA1"
147147 assert egroup .targeted_x == 4.5
148148 assert egroup .targeted_y == 2.2
149- assert egroup .targeted_z == 2.0
149+ assert egroup .targeted_z == - 2.0
150150 assert egroup .device is probe
151151
152152 # Electrode group description should be "Electrodes on shank {shank_index}"
@@ -250,10 +250,25 @@ def test_add_raw_ephys(dummy_logger):
250250 metadata ["ephys" ]["openephys_folder_path" ] = "tests/test_data/raw_ephys/2022-07-25_15-30-00"
251251 metadata ["ephys" ]["impedance_file_path" ] = "tests/test_data/processed_ephys/impedance.csv"
252252 metadata ["ephys" ]["electrodes_location" ] = "Hippocampus CA1"
253- metadata ["ephys" ]["targeted_x" ] = 4.5 # AP in mm
254- metadata ["ephys" ]["targeted_y" ] = 2.2 # ML in mm
255- metadata ["ephys" ]["targeted_z" ] = 2.0 # DV in mm
253+ metadata ["ephys" ]["targeted_x" ] = 4.5 # AP in mm
254+ metadata ["ephys" ]["targeted_y" ] = 2.2 # ML in mm
255+ metadata ["ephys" ]["targeted_z" ] = - 2.0 # DV in mm
256256 metadata ["ephys" ]["probe" ] = ["256-ch Silicon Probe, 3mm length, 66um pitch" ]
257+
258+ # Mapping from probe electrode to channel number
259+ intan_channel_numbers = np .array ([
260+ 191 ,190 ,189 ,188 ,187 ,186 ,185 ,184 ,183 ,182 ,181 ,180 ,179 ,178 ,177 ,176 ,175 ,174 ,173 ,172 ,171 ,170 ,169 ,128 ,129 ,130 ,
261+ 131 ,132 ,133 ,134 ,135 ,136 ,137 ,138 ,139 ,140 ,141 ,142 ,143 ,144 ,145 ,146 ,147 ,148 ,149 ,150 ,151 ,152 ,153 ,154 ,155 ,156 ,
262+ 157 ,158 ,159 ,160 ,161 ,162 ,163 ,164 ,165 ,166 ,167 ,168 ,192 ,193 ,194 ,195 ,196 ,197 ,198 ,199 ,200 ,201 ,202 ,203 ,204 ,205 ,
263+ 206 ,207 ,208 ,209 ,210 ,211 ,212 ,213 ,214 ,215 ,216 ,217 ,218 ,219 ,220 ,221 ,222 ,223 ,224 ,225 ,226 ,227 ,228 ,229 ,230 ,231 ,
264+ 232 ,233 ,234 ,235 ,236 ,237 ,238 ,239 ,240 ,241 ,242 ,243 ,244 ,245 ,246 ,247 ,248 ,249 ,250 ,251 ,252 ,253 ,254 ,255 ,64 ,65 ,66 ,
265+ 67 ,68 ,69 ,70 ,71 ,72 ,73 ,74 ,75 ,76 ,77 ,78 ,79 ,80 ,81 ,82 ,83 ,84 ,85 ,86 ,87 ,88 ,89 ,90 ,91 ,92 ,93 ,94 ,95 ,96 ,97 ,98 ,99 ,100 ,
266+ 101 ,102 ,103 ,104 ,105 ,106 ,107 ,108 ,109 ,110 ,111 ,112 ,113 ,114 ,115 ,116 ,117 ,118 ,119 ,120 ,121 ,122 ,123 ,124 ,125 ,126 ,
267+ 127 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,45 ,46 ,47 ,48 ,49 ,50 ,51 ,52 ,53 ,54 ,55 ,
268+ 56 ,57 ,58 ,59 ,60 ,61 ,62 ,63 ,22 ,21 ,20 ,19 ,18 ,17 ,16 ,15 ,14 ,13 ,12 ,11 ,10 ,9 ,8 ,7 ,6 ,5 ,4 ,3 ,2 ,1 ,0
269+ ])
270+ # Reverse mapping from channel (aka row in ElectricalSeries) to row in electrode table
271+ expected_electrode_data_mapping = list (np .argsort (intan_channel_numbers ))
257272
258273 ephys_data_dict = add_raw_ephys (nwbfile = nwbfile , metadata = metadata , logger = dummy_logger )
259274
@@ -267,7 +282,7 @@ def test_add_raw_ephys(dummy_logger):
267282 )
268283 assert es .data .maxshape == (3_000 , 256 )
269284 assert es .data .dtype == np .int16
270- assert es .electrodes .data == list ( range ( 256 ))
285+ assert es .electrodes .data == expected_electrode_data_mapping
271286 assert es .timestamps .shape == (3_000 ,)
272287 assert es .conversion == 0.19499999284744263 * 1e-6
273288
@@ -354,9 +369,9 @@ def test_add_raw_ephys_complete_data():
354369 metadata ["ephys" ]["openephys_folder_path" ] = "/Users/rly/Documents/NWB/berke-lab-to-nwb/data/2022-07-25_15-30-00"
355370 metadata ["ephys" ]["impedance_file_path" ] = "tests/test_data/processed_ephys/impedance.csv"
356371 metadata ["ephys" ]["electrodes_location" ] = "Hippocampus CA1"
357- metadata ["ephys" ]["targeted_x" ] = 4.5 # AP in mm
358- metadata ["ephys" ]["targeted_y" ] = 2.2 # ML in mm
359- metadata ["ephys" ]["targeted_z" ] = 2.0 # DV in mm
372+ metadata ["ephys" ]["targeted_x" ] = 4.5 # AP in mm
373+ metadata ["ephys" ]["targeted_y" ] = 2.2 # ML in mm
374+ metadata ["ephys" ]["targeted_z" ] = - 2.0 # DV in mm
360375 metadata ["ephys" ]["probe" ] = ["256-ch Silicon Probe, 3mm length, 66um pitch" ]
361376
362377 ephys_data_dict = add_raw_ephys (nwbfile = nwbfile , metadata = metadata )
0 commit comments