RecordEvolution / IMCtermite

Enables extraction of measurement data from binary files with extension 'raw' used by proprietary software imcFAMOS/imcSTUDIO and facilitates its storage in open source file formats
MIT License
27 stars 9 forks source link

Converting raw files from version imc STUDIO 2022 R3 (03.10.2022) not working #21

Open Danarrow opened 1 year ago

Danarrow commented 1 year ago

Error: Exception: failed to load/parse raw-file: invalid block or corrupt buffer at byte: 11

Kind regards

mario-fink commented 1 year ago

@Danarrow Can you please share an example (or at least a representative section) of the problematic raw-file?

pavijovi3 commented 1 year ago

Hi,

I am getting the same error when trying to convert .RAW file to .CSV file. I am new to python coding so couldn't figure out myself. here is the .raw file https://drive.google.com/file/d/1Mq-rWilk7zJVfb14cZh6yzjvylcVbRP5/view?usp=sharing

here is the code: import IMCtermite import os

def convert_raw_to_csv(folder_path):

Get the list of .raw files in the folder

raw_files = [file for file in os.listdir(folder_path) if file.lower().endswith('.raw')]

for raw_file in raw_files:
    raw_file_path = os.path.join(folder_path, raw_file)
    csv_file_name = os.path.splitext(raw_file)[0] + '.csv'
    csv_file_path = os.path.join(folder_path, 'converted', csv_file_name)

    # Create the 'converted' subfolder if it doesn't exist
    os.makedirs(os.path.join(folder_path, 'converted'), exist_ok=True)

    # Convert the .raw file to .csv
    try:
        imcraw = IMCtermite.imctermite(raw_file_path.encode())
        imcraw.print_table(csv_file_path.encode())
        print(f"Conversion successful: {raw_file} -> {csv_file_name}")
    except RuntimeError as e:
        print(f"Conversion failed for {raw_file}: {e}")

print("Conversion process completed.")

Test the function with a folder path

folder_path = input("Enter the folder path containing .raw files: ") convert_raw_to_csv(folder_path)

any advice would be helpful.

Thanks Pavi.