Unable to read binary slc file with VTK

Hey, I am trying to use vtkSLCReader to red binary slc file but it complains that its unable to read magic number.

ERR| vtkSLCReader (0x7fee9e404720): Error reading file: binary.slcFailed to read magic number
2023-02-26 11:41:24.544 (   0.006s) [          2CC3F4]       vtkSLCReader.cxx:235    ERR| vtkSLCReader (0x7fee9e404720): Error reading file: binary.slcFailed to read magic number

I was able to read the above file with the below python code but i am struggling with VTK libraries, can someone help?

import struct
CHUNK_SIZE = 16 # bytes

# Open the binary SLC file in read mode
with open("JR03698.slc", "rb") as binary_file:
    # Open the ASCII SLC file in write mode
    with open("ascii_file.slc", "w") as ascii_file:
        while True:
            # Read the binary data in chunks
            binary_data = binary_file.read(CHUNK_SIZE)
            if not binary_data:
                break
            length = len(binary_data)
            print(f'length {length}')
            # Unpack the binary data using the struct module
            if len(binary_data) == 16:
                x, y, z, intensity = struct.unpack("f"*4, binary_data)
                # Write the x, y, z and intensity values to the ASCII file
                ascii_file.write("{}\n".format(x, y, z, intensity))

please share your .slc file

I’m not familiar with SLC files at all, but the source for this reader indicates that it wants a “magic number” of 11111. It tests this by reading in an ASCII decimal integer using fscanf(file_handle, '%d', &magic_number). This should be the first thing in the file.

According to Paul Bourke’s page on SLC, there doesn’t seem to be a magic number? Perhaps this class was specialized to SLC files written by a particular application?

I guess if you wanted to hack your file so that vtkSLCReader would read it, just add the text:
11111 to the very beginning of the file, followed by a space, then the rest of your header?