@@ -1363,14 +1363,53 @@ def create_one_file_per_signal_dict_rhd(dirname):
13631363 -------
13641364 raw_files_paths_dict: dict
13651365 A dict of all the file paths
1366+
1367+ Raises
1368+ ------
1369+ NeoReadWriteError
1370+ If any required files are missing
13661371 """
13671372
13681373 raw_file_paths_dict = {}
1374+ file_status = {}
1375+
1376+ # Check for data files and always add paths to raw_file_paths_dict
13691377 for stream_name , file_name in stream_name_to_file_name_rhd .items ():
1370- if Path (dirname / file_name ).is_file ():
1371- raw_file_paths_dict [stream_name ] = Path (dirname / file_name )
1372-
1373- raw_file_paths_dict ["timestamp" ] = Path (dirname / "time.dat" )
1378+ file_path = Path (dirname / file_name )
1379+ exists = file_path .is_file ()
1380+ file_status [stream_name ] = {"file" : file_name , "exists" : exists }
1381+ raw_file_paths_dict [stream_name ] = file_path
1382+
1383+ # Check for timestamp file (required)
1384+ time_dat_path = Path (dirname / "time.dat" )
1385+ time_dat_exists = time_dat_path .is_file ()
1386+ file_status ["timestamp" ] = {"file" : "time.dat" , "exists" : time_dat_exists }
1387+ raw_file_paths_dict ["timestamp" ] = time_dat_path
1388+
1389+ # Check if any file is missing by iterating through file_status
1390+ missing_files = any (not info ["exists" ] for info in file_status .values ())
1391+ if missing_files :
1392+ # Create a detailed error message
1393+ error_msg = (
1394+ "Missing required files for one-file-per-signal format.\n "
1395+ "Python-neo does not support loading data where the output of the acquisition system "
1396+ "has been modified. \n Please use the original, unmodified output from the Intan acquisition system.\n \n "
1397+ "File Status:\n "
1398+ "+----------------------------------+------------------+----------+\n "
1399+ "| Stream | File | Found |\n "
1400+ "+----------------------------------+------------------+----------+\n "
1401+ )
1402+
1403+ # Add timestamp first since it's required
1404+ error_msg += f"| { 'timestamp' :<32} | { 'time.dat' :<16} | { '✓' if time_dat_exists else '✗' :<8} |\n "
1405+
1406+ # Add all other streams
1407+ for stream_name , info in file_status .items ():
1408+ if stream_name != "timestamp" : # Skip timestamp as we already added it
1409+ error_msg += f"| { stream_name :<32} | { info ['file' ]:<16} | { '✓' if info ['exists' ] else '✗' :<8} |\n "
1410+
1411+ error_msg += "+----------------------------------+------------------+----------+\n "
1412+ raise NeoReadWriteError (error_msg )
13741413
13751414 return raw_file_paths_dict
13761415
@@ -1398,18 +1437,64 @@ def create_one_file_per_signal_dict_rhs(dirname):
13981437 -------
13991438 raw_files_paths_dict: dict
14001439 A dict of all the file paths
1440+
1441+ Raises
1442+ ------
1443+ NeoReadWriteError
1444+ If any required files are missing
14011445 """
14021446
14031447 raw_file_paths_dict = {}
1448+ file_status = {}
1449+
1450+ # Check for data files and always add paths to raw_file_paths_dict
14041451 for stream_name , file_name in stream_name_to_file_name_rhs .items ():
1405- if Path (dirname / file_name ).is_file ():
1406- raw_file_paths_dict [stream_name ] = Path (dirname / file_name )
1407-
1408- raw_file_paths_dict ["timestamp" ] = Path (dirname / "time.dat" )
1409- if Path (dirname / "dcamplifier.dat" ).is_file ():
1410- raw_file_paths_dict ["DC Amplifier channel" ] = Path (dirname / "dcamplifier.dat" )
1411- if Path (dirname / "stim.dat" ).is_file ():
1412- raw_file_paths_dict ["Stim channel" ] = Path (dirname / "stim.dat" )
1452+ file_path = Path (dirname / file_name )
1453+ exists = file_path .is_file ()
1454+ file_status [stream_name ] = {"file" : file_name , "exists" : exists }
1455+ raw_file_paths_dict [stream_name ] = file_path
1456+
1457+ # Check for timestamp file (required)
1458+ time_dat_path = Path (dirname / "time.dat" )
1459+ time_dat_exists = time_dat_path .is_file ()
1460+ file_status ["timestamp" ] = {"file" : "time.dat" , "exists" : time_dat_exists }
1461+ raw_file_paths_dict ["timestamp" ] = time_dat_path
1462+
1463+ # Check for optional files
1464+ dcamplifier_path = Path (dirname / "dcamplifier.dat" )
1465+ dcamplifier_exists = dcamplifier_path .is_file ()
1466+ file_status ["DC Amplifier channel" ] = {"file" : "dcamplifier.dat" , "exists" : dcamplifier_exists }
1467+ raw_file_paths_dict ["DC Amplifier channel" ] = dcamplifier_path
1468+
1469+ stim_path = Path (dirname / "stim.dat" )
1470+ stim_exists = stim_path .is_file ()
1471+ file_status ["Stim channel" ] = {"file" : "stim.dat" , "exists" : stim_exists }
1472+ raw_file_paths_dict ["Stim channel" ] = stim_path
1473+
1474+ # Check if any file is missing by iterating through file_status
1475+ missing_files = any (not info ["exists" ] for info in file_status .values ())
1476+ if missing_files :
1477+ # Create a detailed error message
1478+ error_msg = (
1479+ "Missing required files for one-file-per-signal format.\n "
1480+ "Python-neo does not support loading data where the output of the acquisition system "
1481+ "has been modified. \n Please use the original, unmodified output from the Intan acquisition system.\n \n "
1482+ "File Status:\n "
1483+ "+----------------------------------+------------------+----------+\n "
1484+ "| Stream | File | Found |\n "
1485+ "+----------------------------------+------------------+----------+\n "
1486+ )
1487+
1488+ # Add timestamp first since it's required
1489+ error_msg += f"| { 'timestamp' :<32} | { 'time.dat' :<16} | { '✓' if time_dat_exists else '✗' :<8} |\n "
1490+
1491+ # Add all other streams
1492+ for stream_name , info in file_status .items ():
1493+ if stream_name != "timestamp" : # Skip timestamp as we already added it
1494+ error_msg += f"| { stream_name :<32} | { info ['file' ]:<16} | { '✓' if info ['exists' ] else '✗' :<8} |\n "
1495+
1496+ error_msg += "+----------------------------------+------------------+----------+\n "
1497+ raise NeoReadWriteError (error_msg )
14131498
14141499 return raw_file_paths_dict
14151500
0 commit comments