@@ -142,14 +142,22 @@ def read_tilt_series(
142142    aligned_tilts  =  []
143143
144144    data_path  =  Path (resolve_path (parameters ["data_path" ])).parent 
145-     mdoc_path  =  Path (resolve_path (parameters ["data_path_mdoc" ])).parent  if  "data_path_mdoc"  in  parameters  else  Path () 
145+     mdoc_path  =  Path (resolve_path (parameters ["data_path_mdoc" ])).parent  if  "data_path_mdoc"  in  parameters  and   parameters [ "data_path_mdoc" ]  !=   None   else  None 
146146    project_raw_path  =  Path (filename ).parent 
147147
148148    name  =  os .path .basename (filename )
149-     mdocs  =  list (mdoc_path .glob (f"{ name }  .mdoc" )) +  list (mdoc_path .glob (f"{ name }  .mrc.mdoc" ))
149+     mdoc_pattern  =  "*.mdoc" 
150+ 
151+     mdocs  =  []
152+     if  mdoc_path  is  not   None :
153+         mdoc_pattern  =  Path (resolve_path (parameters ["data_path_mdoc" ])).name 
154+         mdocs  =  list (mdoc_path .glob (str (mdoc_pattern )))
155+         mdocs  =  [str (file ) for  file  in  mdocs  if  str (file .name ).replace (".mrc" , "" ).replace (".mdoc" , "" ) ==  name ]
156+ 
150157    if  len (mdocs ) ==  0 :
151158        # get the mdoc files from the path of raw data if it couldn't find them in mdoc path 
152-         mdocs  =  list (data_path .glob (f"{ name }  .mdoc" )) +  list (mdoc_path .glob (f"{ name }  .mrc.mdoc" ))
159+         mdocs  =  list (data_path .glob (mdoc_pattern ))
160+         mdocs  =  [str (file ) for  file  in  mdocs  if  str (file .name ).replace (".mrc" , "" ).replace (".mdoc" , "" ) ==  name ]
153161
154162    # escape special character in case it contains [ 
155163    filename  =  glob .escape (filename )
@@ -610,7 +618,7 @@ def read_tilt_series(
610618        if  metadata .get ("drift" ):
611619            for  i  in  metadata ["drift" ]:
612620                drift_metadata ["drift" ][i ] =  metadata ["drift" ][i ].to_numpy ()[:,- 2 :]
613-         elif  metadata .get ("web" ).get ("drift" ):
621+         elif  metadata .get ("web" )  and   metadata . get ( "web" ) .get ("drift" ):
614622            for  i  in  metadata .get ("web" )["drift" ]:
615623                drift_metadata ["drift" ][i ] =  metadata .get ("web" )["drift" ][i ]
616624    else :
0 commit comments