22import sys
33import subprocess
44import json
5+ from dotenv import load_dotenv
56
7+ sys .path .append (os .path .dirname (__file__ ))
68from helpers import SpikeGLX_utils
79from helpers import log_from_json
810from helpers import run_one_probe
@@ -22,6 +24,14 @@ def run_probe(prb, json_directory, npx_directory,
2224 catGT_loccar_min_um , catGT_loccar_max_um ,
2325 catGT_cmd_string ,
2426 ks_Th , refPerMS ,
27+ ecephys_directory = None ,
28+ kilosort_repository = None ,
29+ KS2ver = None ,
30+ npy_matlab_repository = None ,
31+ catGTPath = None ,
32+ tPrime_path = None ,
33+ cWaves_path = None ,
34+ kilosort_output_tmp = None ,
2535 ks_remDup = 0 ,
2636 ks_saveRez = 1 ,
2737 ks_copy_fproc = 0 ,
@@ -31,6 +41,19 @@ def run_probe(prb, json_directory, npx_directory,
3141 c_Waves_snr_um = 160 ,
3242 ni_present = True ,
3343 ni_extract_string = None ):
44+ # load external tool path from .env if not given from .json
45+ dot_env_path = "config/sglx_process_probe.json"
46+ if os .path .exists (dot_env_path ):
47+ load_dotenv (dot_env_path )
48+ ecephys_directory = ecephys_directory or os .getenv ('ecephys_directory' )
49+ kilosort_repository = kilosort_repository or os .getenv ('kilosort_repository' )
50+ KS2ver = KS2ver or os .getenv ('KS2ver' )
51+ npy_matlab_repository = npy_matlab_repository or os .getenv ('npy_matlab_repository' )
52+ catGTPath = catGTPath or os .getenv ('catGTPath' )
53+ tPrime_path = tPrime_path or os .getenv ('tPrime_path' )
54+ cWaves_path = cWaves_path or os .getenv ('cWaves_path' )
55+ kilosort_output_tmp = kilosort_output_tmp or os .getenv ('kilosort_output_tmp' )
56+
3457 # build path to the first probe folder; look into that folder
3558 # to determine the range of trials if the user specified t limits as
3659 # start and end
@@ -69,6 +92,14 @@ def run_probe(prb, json_directory, npx_directory,
6992 input_meta_fullpath = os .path .join (input_data_directory , metaName )
7093 print (input_meta_fullpath )
7194 createInputJson (catGT_input_json ,
95+ ecephys_directory = ecephys_directory ,
96+ kilosort_repository = kilosort_repository ,
97+ KS2ver = KS2ver ,
98+ npy_matlab_repository = npy_matlab_repository ,
99+ catGTPath = catGTPath ,
100+ tPrime_path = tPrime_path ,
101+ cWaves_path = cWaves_path ,
102+ kilosort_output_tmp = kilosort_output_tmp ,
72103 npx_directory = npx_directory ,
73104 continuous_file = continuous_file ,
74105 kilosort_output_directory = catGT_dest ,
@@ -105,6 +136,14 @@ def run_probe(prb, json_directory, npx_directory,
105136 print (continuous_file )
106137 print ('ks_Th: ' + repr (ks_Th ) + ' ,refPerMS: ' + repr (refPerMS ))
107138 createInputJson (module_input_json ,
139+ ecephys_directory = ecephys_directory ,
140+ kilosort_repository = kilosort_repository ,
141+ KS2ver = KS2ver ,
142+ npy_matlab_repository = npy_matlab_repository ,
143+ catGTPath = catGTPath ,
144+ tPrime_path = tPrime_path ,
145+ cWaves_path = cWaves_path ,
146+ kilosort_output_tmp = kilosort_output_tmp ,
108147 npx_directory = npx_directory ,
109148 continuous_file = continuous_file ,
110149 spikeGLX_data = True ,
@@ -149,10 +188,11 @@ def run_probe(prb, json_directory, npx_directory,
149188 logFullPath )
150189
151190
152- if __name__ == '__main__' :
191+ #if __name__ == '__main__':
192+ def main ():
153193 json_fp = sys .argv [1 ]
154194
155195 with open (json_fp ) as f :
156196 kwargs = json .load (f )
157197
158- run_one_probe (** kwargs )
198+ run_probe (** kwargs )
0 commit comments