def read_header(cine_file: Union[str, bytes, os.PathLike]) -> Header: with open(cine_file, "rb") as f: header: Header = { "cinefileheader": cine.CINEFILEHEADER(), "bitmapinfoheader": cine.BITMAPINFOHEADER(), "setup": cine.SETUP(), "pImage": [], "timestamp": np.empty(0), "exposuretime": np.empty(0), } f.readinto(header["cinefileheader"]) f.readinto(header["bitmapinfoheader"]) f.seek(header["cinefileheader"].OffSetup) f.readinto(header["setup"]) # header_length = ctypes.sizeof(header['cinefileheader']) # bitmapinfo_length = ctypes.sizeof(header['bitmapinfoheader']) f.seek(header["cinefileheader"].OffImageOffsets) header["pImage"] = struct.unpack( f"{header['cinefileheader'].ImageCount}q", f.read(header["cinefileheader"].ImageCount * 8)) header = read_tagged_block(f, header) return header
def read_chd_header(chd_file): """ read the .chd header file created when Vision Research software saves the images in a file format other than .cine """ with open(chd_file, "rb") as f: header = { "cinefileheader": cine.CINEFILEHEADER(), "bitmapinfoheader": cine.BITMAPINFOHEADER(), "setup": cine.SETUP(), } f.readinto(header["cinefileheader"]) f.readinto(header["bitmapinfoheader"]) f.readinto(header["setup"]) return header
def read_chd_header(chd_file: Union[str, bytes, os.PathLike]) -> Header: """ read the .chd header file created when Vision Research software saves the images in a file format other than .cine """ with open(chd_file, "rb") as f: header: Header = { "cinefileheader": cine.CINEFILEHEADER(), "bitmapinfoheader": cine.BITMAPINFOHEADER(), "setup": cine.SETUP(), "pImage": [], "timestamp": np.empty(0), "exposuretime": np.empty(0), } f.readinto(header["cinefileheader"]) f.readinto(header["bitmapinfoheader"]) f.seek(header["cinefileheader"].OffSetup) f.readinto(header["setup"]) return header
def read_header(cine_file): with open(cine_file, "rb") as f: header = { "cinefileheader": cine.CINEFILEHEADER(), "bitmapinfoheader": cine.BITMAPINFOHEADER(), "setup": cine.SETUP(), } f.readinto(header["cinefileheader"]) f.readinto(header["bitmapinfoheader"]) f.readinto(header["setup"]) # header_length = ctypes.sizeof(header['cinefileheader']) # bitmapinfo_length = ctypes.sizeof(header['bitmapinfoheader']) f.seek(header["cinefileheader"].OffImageOffsets) header["pImage"] = struct.unpack( "{}q".format(header["cinefileheader"].ImageCount), f.read(header["cinefileheader"].ImageCount * 8)) return header