I was surprised to find out that Gwyddion handled .vk4 files as I've never seen any other open-source microscopy programs that worked with any of Keyence's file formats. How similar are .vk6 files to the .vk4 file extension? I could not find any documentation on the .vk6 files and there's no real information about it online. Could .vk6 file support be implemented in future releases of Gwyddion and does anyone know where to get any information about it?
I am trying to find a way to convert .vk6 files into .jpeg through Python, but I am unsure of where to begin as there is so little information about it. Does anyone have any experience with converting .vk6 using ImageJ or Python?
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Would it help if the image was of something specific or could I just take a picture of a piece of paper and share it with you? Would any of those factors matter in conducting analysis of the file format?
Thank you for your help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It does not matter for checking if the file structure resembles something we know and/or seems accessible to analysis (the VK4 format consists of large binary structs and is not easy to analyse, so I do not have extra high hopes…). It is always good to have some idea what data are in the file though – see also here.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the file sample. It is definitely quite different. However, it is easy to begin picking it apart.
It starts with a 7-byte header, V, K, 6, f, 0xc2, 0x01, 0x00 (not sure about the meaning of the last 3 bytes).
Then there is an embedded Windows 3.x BMP file. You can easily extracting using the size specified in the BMP header.
Immediately after that follows an embedded ZIP archive. It contains files
Vk4File – a VK4 file you can open in Gwyddion
Vk4MeasureCondition – some binary
VK6MeasureCondition – another ZIP file, containing some information in text files inside
Vk6ImageData – another ZIP file (they just love nesting files, don't they?), with some binary files inside; these seem to be mostly raw data, but I do not know the format yet
I will not get to more analysis over the weekend now, but I am cautiously optimistic about implementation in Gwyddion. The structure is crazy, but apparently accessible to analysis.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is always helpful when I have have more different files. Meaning measured in different modes, with different choices what is saved, …, whatever options exist for Keyence. In other words with [possibly] different structure/content.
I can write an initial VK6 import implementation using the single file I have. But I have no idea about the variability of the file format. So – in the extreme case – the import module might be able to read just this single file (unlikely to happen here, but you get the idea).
It would definitely help if you could test the import on a wide set of VK6 files. Of course that can be done only after I actually implement it…
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I added support for the Keyence VK6 file format, please test (tomorrow's or later development snapshot).
The import module currently reads the embedded VK4 file and some new metadata. I know how to read the new HDR data too, but I am not sure about the utility of that…
There is also some kind of error image among the new data. This one could be useful for creating a mask over invalid pixels if this is indeed what it represents. It is just filled with zeros in the file I have – presumably all pixels are good there?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I also added import of the VK6 HDR images. The import module replaces the VK4 Peak images with them since this is what they seem to represent. And speculatively it now also reads the Error image, but I have no real example where the Error image contains any information.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, is there a way to access the arithmetic functions through the pygwy console? I have a short script that opens .vk6 files in a directory and saves them as a different file format. Before the final saving function is initiated however, I would like to apply the "0.2126 * d1 + 0.7152 * d2 + 0.0722 * d2" grayscale operation on the image, with d1 being the height map and d2 being one of the peak images.
I tried to categorize height as d1 and peak red as d2. I am not sure if this can be done in this manner, though. It saves all the .vk6 files as .jpeg, but I am unsure about how to proceed with the arithmetic function as I tried a few different things and they all seemed to crash the console.
Thank you for your help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No, there is no need. Arithmetic is a C implementation of what you can do in Python much more easily using numpy. Create numpy arrays from the data fields
Running the above script yields the following error:
"Saving of 'filename.jpeg' failed: file contains no exportable channel. Full file path: 'filename.jpeg' Saved using: jpegcairo."
I tried changing os.chdir(root) to gwy_app_set_current_directory(root) and gwy.gwy_app_file_write() to gwy.gwy_file_save(), though it still gave the same error expect in the pygwy console itself. If I use gwy.gwy_app_file_save() with no arguments, the program crashes entirely. Other than that, the console seems to be running the script fine, but I am unsure if the script actually carries out the arithmetic operation. Should I assign the mathematical expression to "a3" and then call "a3.data_changed()"? Would something like this be necessary for changes to take effect?
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Never mind, I made more alterations and have it working successfully on Windows 7. I was having issues with it on Windows 10 as the entire program kept crashing when I ran the script. I will update if there are any other issues, but so far everything seems to be working fine.
David, thank you very much for all your help with the coding and for implementing .vk6 support!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was really glad to find this thread. I was looking to import some vk6 data. Downloaded the latest nightly and it works perfectly. Thanks for a great program.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As a small follow up to ensure the code does not crash on Win 11.:
I had to include the lines: "gwy.gwy_app_data_browser_set_gui_enabled(False)" to not open a new window for each file I am looping over, and "gwy.gwy_app_data_browser_remove(container) " to release the memory.
importgwy,numpy,osimportgwyutilsimportmatplotlib.pyplotaspltimportpandasaspdroot=(r'C:\Users\schlenge\Desktop\Line6')os.chdir(root)gwy.gwy_app_data_browser_set_gui_enabled(False)forfilenameinos.listdir(root):iffilename.endswith('.vk6'):container=gwy.gwy_app_file_load(filename)# create data fieldsd1=container['/1/data']d2=container['/2/data']d3=container['/3/data']d4=container['/4/data']gwy.gwy_app_data_browser_remove(container)# convert to np.arraya1=numpy.array(d1.get_data())a2=numpy.array(d2.get_data())a3=numpy.array(d3.get_data())a4=numpy.array(d4.get_data())
BTW: Amazing work David, much appreciated!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I m having similar issue in saving the file, i m getting below error, please advise, i m using window 11 , gwyddion 32 bit and python 2.7 glib.GError: File contains no exportable channel.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I m having similar issue in saving the file, i m getting below error, please advise, i m using window 11 , gwyddion 32 bit and python 2.7 glib.GError: File contains no exportable channel.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was surprised to find out that Gwyddion handled .vk4 files as I've never seen any other open-source microscopy programs that worked with any of Keyence's file formats. How similar are .vk6 files to the .vk4 file extension? I could not find any documentation on the .vk6 files and there's no real information about it online. Could .vk6 file support be implemented in future releases of Gwyddion and does anyone know where to get any information about it?
I am trying to find a way to convert .vk6 files into .jpeg through Python, but I am unsure of where to begin as there is so little information about it. Does anyone have any experience with converting .vk6 using ImageJ or Python?
Thank you.
I have no idea – I have never seen any vk6 file. Of course it is a key question. So please provide some files.
Would it help if the image was of something specific or could I just take a picture of a piece of paper and share it with you? Would any of those factors matter in conducting analysis of the file format?
Thank you for your help.
It does not matter for checking if the file structure resembles something we know and/or seems accessible to analysis (the VK4 format consists of large binary structs and is not easy to analyse, so I do not have extra high hopes…). It is always good to have some idea what data are in the file though – see also here.
Thanks for the file sample. It is definitely quite different. However, it is easy to begin picking it apart.
It starts with a 7-byte header, V, K, 6, f, 0xc2, 0x01, 0x00 (not sure about the meaning of the last 3 bytes).
Then there is an embedded Windows 3.x BMP file. You can easily extracting using the size specified in the BMP header.
Immediately after that follows an embedded ZIP archive. It contains files
I will not get to more analysis over the weekend now, but I am cautiously optimistic about implementation in Gwyddion. The structure is crazy, but apparently accessible to analysis.
That's incredible, I had no idea this information could be extracted from it. Is there anything that I can help with? Is any other information needed?
It is always helpful when I have have more different files. Meaning measured in different modes, with different choices what is saved, …, whatever options exist for Keyence. In other words with [possibly] different structure/content.
I can write an initial VK6 import implementation using the single file I have. But I have no idea about the variability of the file format. So – in the extreme case – the import module might be able to read just this single file (unlikely to happen here, but you get the idea).
It would definitely help if you could test the import on a wide set of VK6 files. Of course that can be done only after I actually implement it…
I will see if the optical microscope will be available for use today and see what other options there are to choose from.
I added support for the Keyence VK6 file format, please test (tomorrow's or later development snapshot).
The import module currently reads the embedded VK4 file and some new metadata. I know how to read the new HDR data too, but I am not sure about the utility of that…
There is also some kind of error image among the new data. This one could be useful for creating a mask over invalid pixels if this is indeed what it represents. It is just filled with zeros in the file I have – presumably all pixels are good there?
I also added import of the VK6 HDR images. The import module replaces the VK4 Peak images with them since this is what they seem to represent. And speculatively it now also reads the Error image, but I have no real example where the Error image contains any information.
Hello, is there a way to access the arithmetic functions through the pygwy console? I have a short script that opens .vk6 files in a directory and saves them as a different file format. Before the final saving function is initiated however, I would like to apply the "0.2126 * d1 + 0.7152 * d2 + 0.0722 * d2" grayscale operation on the image, with d1 being the height map and d2 being one of the peak images.
This is what I have currently:
I tried to categorize height as d1 and peak red as d2. I am not sure if this can be done in this manner, though. It saves all the .vk6 files as .jpeg, but I am unsure about how to proceed with the arithmetic function as I tried a few different things and they all seemed to crash the console.
Thank you for your help.
No, there is no need. Arithmetic is a C implementation of what you can do in Python much more easily using numpy. Create numpy arrays from the data fields
and then you can just use any mathematical expressions with the arrays.
I altered the script and now have this configuration:
Running the above script yields the following error:
"Saving of 'filename.jpeg' failed: file contains no exportable channel. Full file path: 'filename.jpeg' Saved using: jpegcairo."
I tried changing os.chdir(root) to gwy_app_set_current_directory(root) and gwy.gwy_app_file_write() to gwy.gwy_file_save(), though it still gave the same error expect in the pygwy console itself. If I use gwy.gwy_app_file_save() with no arguments, the program crashes entirely. Other than that, the console seems to be running the script fine, but I am unsure if the script actually carries out the arithmetic operation. Should I assign the mathematical expression to "a3" and then call "a3.data_changed()"? Would something like this be necessary for changes to take effect?
Thank you.
Never mind, I made more alterations and have it working successfully on Windows 7. I was having issues with it on Windows 10 as the entire program kept crashing when I ran the script. I will update if there are any other issues, but so far everything seems to be working fine.
David, thank you very much for all your help with the coding and for implementing .vk6 support!
I was really glad to find this thread. I was looking to import some vk6 data. Downloaded the latest nightly and it works perfectly. Thanks for a great program.
Hi together,
As a small follow up to ensure the code does not crash on Win 11.:
I had to include the lines: "gwy.gwy_app_data_browser_set_gui_enabled(False)" to not open a new window for each file I am looping over, and "gwy.gwy_app_data_browser_remove(container) " to release the memory.
BTW: Amazing work David, much appreciated!
Hi, I m having similar issue in saving the file, i m getting below error, please advise, i m using window 11 , gwyddion 32 bit and python 2.7
glib.GError: File contains no exportable channel.
Hi, I m having similar issue in saving the file, i m getting below error, please advise, i m using window 11 , gwyddion 32 bit and python 2.7
glib.GError: File contains no exportable channel.
this is the code i m using, it keeps failing with
glib.GError: File contains no exportable channel
Last edit: Vaishnavi Subramanian 2025-02-07