@@ -90,7 +90,7 @@ def generate_CatGT_input_json(self):
9090 print ('run_CatGT is set to False, skipping...' )
9191 return
9292
93- session_str , gate_str , _ , probe_str = self .parse_input_filename ()
93+ session_str , gate_str , trig_str , probe_str = self .parse_input_filename ()
9494
9595 first_trig , last_trig = SpikeGLX_utils .ParseTrigStr (
9696 'start,end' , probe_str , gate_str , self ._npx_input_dir .as_posix ())
@@ -111,6 +111,22 @@ def generate_CatGT_input_json(self):
111111
112112 input_meta_fullpath , continuous_file = self ._get_raw_data_filepaths ()
113113
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+
114130 createInputJson (self ._catGT_input_json .as_posix (),
115131 KS2ver = self ._KS2ver ,
116132 npx_directory = self ._npx_input_dir .as_posix (),
@@ -121,7 +137,7 @@ def generate_CatGT_input_json(self):
121137 probe_string = probe_str ,
122138 continuous_file = continuous_file .as_posix (),
123139 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 (),
125141 kilosort_output_directory = self ._ks_output_dir .as_posix (),
126142 kilosort_repository = _get_kilosort_repository (self ._KS2ver ),
127143 ** {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):
216232 session_str , gate_str , _ , probe_str = self .parse_input_filename ()
217233
218234 if self ._CatGT_finished :
219- catGT_dest = self ._ks_output_dir . parent
235+ catGT_dest = self ._ks_output_dir
220236 run_str = session_str + '_g' + gate_str
221237 run_folder = 'catgt_' + run_str
222238 prb_folder = run_str + '_imec' + probe_str
223239 data_directory = catGT_dest / run_folder / prb_folder
224240 else :
225241 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?' )
229247
230248 return meta_fp , bin_fp
231249
@@ -303,7 +321,9 @@ class OpenEphysKilosortPipeline:
303321 https://github.com/AllenInstitute/ecephys_spike_sorting
304322 """
305323
306- _modules = ['kilosort_helper' ,
324+ _modules = ['depth_estimation' ,
325+ 'median_subtraction' ,
326+ 'kilosort_helper' ,
307327 'kilosort_postprocessing' ,
308328 'noise_templates' ,
309329 'mean_waveforms' ,
@@ -477,7 +497,7 @@ def _update_total_duration(self):
477497
478498
479499def 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 ):
481501 dat_path = pathlib .Path (continuous_file )
482502
483503 probe = pykilosort .Bunch ()
0 commit comments