@@ -90,7 +90,7 @@ def generate_CatGT_input_json(self):
90
90
print ('run_CatGT is set to False, skipping...' )
91
91
return
92
92
93
- session_str , gate_str , _ , probe_str = self .parse_input_filename ()
93
+ session_str , gate_str , trig_str , probe_str = self .parse_input_filename ()
94
94
95
95
first_trig , last_trig = SpikeGLX_utils .ParseTrigStr (
96
96
'start,end' , probe_str , gate_str , self ._npx_input_dir .as_posix ())
@@ -111,6 +111,22 @@ def generate_CatGT_input_json(self):
111
111
112
112
input_meta_fullpath , continuous_file = self ._get_raw_data_filepaths ()
113
113
114
+ # create symbolic link to the actual data files - as CatGT expects files to follow a certain naming convention
115
+ continuous_file_symlink = (continuous_file .parent / f'{ session_str } _g{ gate_str } '
116
+ / f'{ session_str } _g{ gate_str } _imec{ probe_str } '
117
+ / f'{ session_str } _g{ gate_str } _t{ trig_str } .imec{ probe_str } .ap.bin' )
118
+ continuous_file_symlink .parent .mkdir (parents = True , exist_ok = True )
119
+ if continuous_file_symlink .exists ():
120
+ continuous_file_symlink .unlink ()
121
+ continuous_file_symlink .symlink_to (continuous_file )
122
+ input_meta_fullpath_symlink = (input_meta_fullpath .parent / f'{ session_str } _g{ gate_str } '
123
+ / f'{ session_str } _g{ gate_str } _imec{ probe_str } '
124
+ / f'{ session_str } _g{ gate_str } _t{ trig_str } .imec{ probe_str } .ap.meta' )
125
+ input_meta_fullpath_symlink .parent .mkdir (parents = True , exist_ok = True )
126
+ if input_meta_fullpath_symlink .exists ():
127
+ input_meta_fullpath_symlink .unlink ()
128
+ input_meta_fullpath_symlink .symlink_to (input_meta_fullpath )
129
+
114
130
createInputJson (self ._catGT_input_json .as_posix (),
115
131
KS2ver = self ._KS2ver ,
116
132
npx_directory = self ._npx_input_dir .as_posix (),
@@ -121,7 +137,7 @@ def generate_CatGT_input_json(self):
121
137
probe_string = probe_str ,
122
138
continuous_file = continuous_file .as_posix (),
123
139
input_meta_path = input_meta_fullpath .as_posix (),
124
- extracted_data_directory = self ._ks_output_dir .parent . as_posix (),
140
+ extracted_data_directory = self ._ks_output_dir .as_posix (),
125
141
kilosort_output_directory = self ._ks_output_dir .as_posix (),
126
142
kilosort_repository = _get_kilosort_repository (self ._KS2ver ),
127
143
** {k : v for k , v in catgt_params .items () if k in self ._input_json_args }
@@ -216,16 +232,18 @@ def _get_raw_data_filepaths(self):
216
232
session_str , gate_str , _ , probe_str = self .parse_input_filename ()
217
233
218
234
if self ._CatGT_finished :
219
- catGT_dest = self ._ks_output_dir . parent
235
+ catGT_dest = self ._ks_output_dir
220
236
run_str = session_str + '_g' + gate_str
221
237
run_folder = 'catgt_' + run_str
222
238
prb_folder = run_str + '_imec' + probe_str
223
239
data_directory = catGT_dest / run_folder / prb_folder
224
240
else :
225
241
data_directory = self ._npx_input_dir
226
-
227
- meta_fp = next (data_directory .glob (f'{ session_str } *.ap.meta' ))
228
- bin_fp = next (data_directory .glob (f'{ session_str } *.ap.bin' ))
242
+ try :
243
+ meta_fp = next (data_directory .glob (f'{ session_str } *.ap.meta' ))
244
+ bin_fp = next (data_directory .glob (f'{ session_str } *.ap.bin' ))
245
+ except StopIteration :
246
+ raise RuntimeError (f'No ap meta/bin files found in { data_directory } - CatGT error?' )
229
247
230
248
return meta_fp , bin_fp
231
249
@@ -303,7 +321,9 @@ class OpenEphysKilosortPipeline:
303
321
https://github.com/AllenInstitute/ecephys_spike_sorting
304
322
"""
305
323
306
- _modules = ['kilosort_helper' ,
324
+ _modules = ['depth_estimation' ,
325
+ 'median_subtraction' ,
326
+ 'kilosort_helper' ,
307
327
'kilosort_postprocessing' ,
308
328
'noise_templates' ,
309
329
'mean_waveforms' ,
@@ -477,7 +497,7 @@ def _update_total_duration(self):
477
497
478
498
479
499
def run_pykilosort (continuous_file , kilosort_output_directory , params ,
480
- channel_ind , x_coords , y_coords , shank_ind , connected , sample_rate ):
500
+ channel_ind , x_coords , y_coords , shank_ind , connected , sample_rate ):
481
501
dat_path = pathlib .Path (continuous_file )
482
502
483
503
probe = pykilosort .Bunch ()
0 commit comments