1212
1313
1414def call_TPrime (args ):
15-
1615 # Run TPrime on a "standard" multiprobe + NI, using NP 1.0 or 2.0, with run
1716 # folder and probe folders
1817 # inputs:
@@ -114,7 +113,7 @@ def call_TPrime(args):
114113 toStream_path = os .path .join (run_directory , prb_dir , c_name )
115114
116115 # convert events in the toStream to sec; they will not be adjusted
117- ks_outdir = 'imec' + str (toStream_prb ) + '_ks2'
116+ ks_outdir = 'imec' + str (toStream_prb ) + '_ks' + args [ 'kilosort_helper_params' ][ 'kilosort2_params' ][ 'KSver' ]
118117 st_file = os .path .join (run_directory , prb_dir , ks_outdir , 'spike_times.npy' )
119118 # convert to seconds; if bNPY = True, returned file is an npy file
120119 # otherwise, text.
@@ -151,7 +150,7 @@ def call_TPrime(args):
151150 from_list .append (os .path .join (run_directory , prb_dir , c_name ))
152151 c_index = len (from_stream_index )
153152 # build path to spike times npy file
154- ks_outdir = 'imec' + str (c_prb ) + '_ks2'
153+ ks_outdir = 'imec' + str (c_prb ) + '_ks' + args [ 'kilosort_helper_params' ][ 'kilosort2_params' ][ 'KSver' ]
155154 st_file = os .path .join (run_directory , prb_dir , ks_outdir , 'spike_times.npy' )
156155 st_file_sec = spike_times_npy_to_sec (st_file , 0 , bNPY )
157156 events_list .append (st_file_sec )
@@ -236,7 +235,7 @@ def call_TPrime(args):
236235 from_list .append (os .path .join (run_directory , prb_dir , c_name ))
237236 c_index = len (from_stream_index )
238237 # build path to spike times npy file
239- ks_outdir = 'imec' + str (c_prb ) + '_ks2'
238+ ks_outdir = 'imec' + str (c_prb ) + '_ks' + args [ 'kilosort_helper_params' ][ 'kilosort2_params' ][ 'KSver' ]
240239 st_file = os .path .join (run_directory , prb_dir , ks_outdir , 'spike_times.npy' )
241240 st_file_sec = spike_times_npy_to_sec (st_file , 0 , bNPY )
242241 events_list .append (st_file_sec )
@@ -262,25 +261,27 @@ def call_TPrime(args):
262261 # Essential in linux where TPrime executable is only callable through runit
263262 if sys .platform .startswith ('win' ):
264263 exe_path = os .path .join (args ['tPrime_helper_params' ]['tPrime_path' ], 'runit.bat' )
265- elif sys .platform .starstwith ('linux' ):
264+ elif sys .platform .startswith ('linux' ):
266265 exe_path = os .path .join (args ['tPrime_helper_params' ]['tPrime_path' ], 'runit.sh' )
267266 else :
268267 print ('unknown system, cannot run TPrime' )
269268
270269 # Print out command for help with debugging
271- tcmd = exe_path + ' -syncperiod=' + repr (sync_period ) + \
272- ' -tostream=' + toStream_path
270+ tcmd = list ()
271+ tcmd .append (exe_path )
272+ tcmd .append (' -syncperiod=' + repr (sync_period ))
273+ tcmd .append (' -tostream=' + toStream_path )
273274
274275 for i , fp in enumerate (from_list ):
275- tcmd = tcmd + ' -fromstream=' + repr (i ) + ',' + fp
276+ tcmd . append ( ' -fromstream=' + repr (i ) + ',' + fp )
276277
277278 for i , ep in enumerate (events_list ):
278- tcmd = tcmd + ' -events=' + repr (from_stream_index [i ]) + ',' + ep + ',' + out_list [i ]
279+ tcmd . append ( ' -events=' + repr (from_stream_index [i ]) + ',' + ep + ',' + out_list [i ])
279280
280281 # write out file to record the TPrime command for a record
281282 bat_path = os .path .join (run_directory , run_name + '_TPrime_cmd.txt' )
282283 with open (bat_path , 'w' ) as batfile :
283- batfile .write (tcmd )
284+ batfile .write (str ( tcmd ) )
284285
285286
286287 # make the TPrime call
@@ -347,7 +348,7 @@ def call_TPrime_3A(args):
347348 # convert events in the toStream to sec; they will not be adjusted
348349 # search the directory the edges file to get the ks2 output
349350 # get name of ks2 output dir and convert to sec
350- ks_outdir = fnmatch .filter (file_list , 'imec_*_ks2' )[0 ]
351+ ks_outdir = fnmatch .filter (file_list , 'imec_*_ks' + args [ 'kilosort_helper_params' ][ 'kilosort2_params' ][ 'KSver' ] )[0 ]
351352 st_file = os .path .join (toStream_parent , ks_outdir , 'spike_times.npy' )
352353 toStream_events_sec = spike_times_npy_to_sec (st_file , 0 , bNPY )
353354 # for later data analysis with spike times as sec, also save as npy
@@ -367,7 +368,7 @@ def call_TPrime_3A(args):
367368 return
368369 fS_name = flt_list [0 ]
369370 fS_file_list .append (os .path .join (fS_parent ,fS_name ))
370- ks_outdir = fnmatch .filter (file_list , 'imec_*_ks2' )[0 ]
371+ ks_outdir = fnmatch .filter (file_list , 'imec_*_ks' + args [ 'kilosort_helper_params' ][ 'kilosort2_params' ][ 'KSver' ] )[0 ]
371372 st_file = os .path .join (fS_parent , ks_outdir , 'spike_times.npy' )
372373 st_file_sec = spike_times_npy_to_sec (st_file , 0 , bNPY )
373374 events_list .append (st_file_sec )
0 commit comments