@@ -190,15 +190,18 @@ def get_roi_group(lims_data):
190
190
def get_sync_path (lims_data ):
191
191
ophys_session_dir = get_ophys_session_dir (lims_data )
192
192
analysis_dir = get_analysis_dir (lims_data )
193
- # try getting sync file from analysis folder first - needed for early mesoscope data where lims sync file is missing line labels
194
- try :
195
- logger .info ('using sync file from analysis directory instead of lims' )
196
- sync_file = [file for file in os .listdir (analysis_dir ) if 'sync' in file ][0 ]
197
- sync_path = os .path .join (analysis_dir , sync_file )
198
- except Exception as e :
199
- print (e )
200
- sync_file = [file for file in os .listdir (ophys_session_dir ) if 'sync' in file ][0 ]
201
- sync_path = os .path .join (ophys_session_dir , sync_file )
193
+
194
+ # First attempt
195
+ sync_file = [file for file in os .listdir (ophys_session_dir ) if 'sync' in file ]
196
+ if len (sync_file )> 0 :
197
+ sync_file = sync_file [0 ]
198
+ else :
199
+ json_path = [file for file in os .listdir (ophys_session_dir ) if '_platform.json' in file ][0 ]
200
+ with open (os .path .join (ophys_session_dir , json_path )) as pointer_json :
201
+ json_data = json .load (pointer_json )
202
+ sync_file = json_data ['sync_file' ]
203
+ sync_path = os .path .join (ophys_session_dir , sync_file )
204
+
202
205
if sync_file not in os .listdir (analysis_dir ):
203
206
logger .info ('moving %s to analysis dir' , sync_file ) # flake8: noqa: E999
204
207
shutil .copy2 (sync_path , os .path .join (analysis_dir , sync_file ))
@@ -373,7 +376,7 @@ def save_metadata(metadata, lims_data):
373
376
def get_stimulus_pkl_path (lims_data ):
374
377
ophys_session_dir = get_ophys_session_dir (lims_data )
375
378
# first try lims folder
376
- pkl_file = [file for file in os .listdir (ophys_session_dir ) if 'stim .pkl' in file ]
379
+ pkl_file = [file for file in os .listdir (ophys_session_dir ) if '.pkl' in file ]
377
380
if len (pkl_file ) > 0 :
378
381
stimulus_pkl_path = os .path .join (ophys_session_dir , pkl_file [0 ])
379
382
else : # then try behavior directory
0 commit comments