@@ -161,7 +161,9 @@ def plot_medoid_distance_outliers(
161161 fig .savefig (plot_path , dpi = 300 )
162162
163163 plt .close ()
164- print (f"Saved keypoint distance outlier plot for { recording_name } to { plot_path } ." )
164+ logger .info (
165+ f"Saved keypoint distance outlier plot for { recording_name } to { plot_path } ."
166+ )
165167 return fig
166168
167169
@@ -345,34 +347,27 @@ def copy_pdf_to_png(project_dir, model_name):
345347
346348 Returns:
347349 bool: True if conversion was successful, False otherwise
348- """
349350
351+ Raises:
352+ FileNotFoundError: If the PDF file doesn't exist
353+ RuntimeError: If conversion fails
354+ """
350355 try :
351356 from pdf2image import convert_from_path
352357
353- # Check both possible locations for the PDF file
358+ # Construct paths for PDF and PNG files
354359 model_dir = Path (project_dir ) / model_name
355-
356- # First try the plots subdirectory
357360 pdf_path = model_dir / "fitting_progress.pdf"
358- if not pdf_path .exists ():
359- # If not found in plots/, try directly in the model directory
360- pdf_path = model_dir / "fitting_progress.pdf"
361- if not pdf_path .exists ():
362- raise FileNotFoundError (
363- f"PDF progress plot not found at { model_dir / 'fitting_progress.pdf' } or { pdf_path } "
364- )
365-
366- # Create plots directory if it doesn't exist (for PNG output)
367- model_dir .mkdir (parents = True , exist_ok = True )
368361 png_path = model_dir / "fitting_progress.png"
369362
370- logger .info (f"Converting progress plot: { pdf_path } " )
363+ # Check if PDF exists
364+ if not pdf_path .exists ():
365+ raise FileNotFoundError (f"PDF progress plot not found at { pdf_path } " )
371366
372367 # Convert PDF to PNG
373368 images = convert_from_path (pdf_path , dpi = 300 )
374369 if not images :
375- raise ValueError (f"No pages found in PDF at { pdf_path } " )
370+ raise ValueError (f"No PDF file found at { pdf_path } " )
376371
377372 images [0 ].save (png_path , "PNG" )
378373 logger .info (f"Generated PNG progress plot at { png_path } " )
0 commit comments