I want to analyze a diffraction pattern. Py4dSTEM is asking for a datacube to start with. I thought it might be able to convert an image to this format:


But I get this error:

Exception: Unrecognized file extension .png.  To force reading as a particular filetype, pass the 'ft' keyword argument.

Since py4DSTEM doesn't seem to work directly with images, is there any software that can convert say a png (or any other common image format) to their datacube format?

Then I tried: py4DSTEM.io.read('tinicu.png', ft='None')

And I get this error:

  if binfactor > 1:
     86         assert(mem!='MEMMAP'), "Error: binning is not supported for memory mapping.  Either set binfactor=1 or set mem='RAM'"
---> 87     assert(ft in [None,'dm','empad','mrc_relativity','gatan_K2_bin','kitware_counted']), "Error: ft argument not recognized"
     89     if ft is None:

AssertionError: Error: ft argument not recognized
  • $\begingroup$ Do you have some reason to believe this program can read in data from a PNG? All the examples and documentation on the GitHub page seem to suggest that it requires very specialized files. $\endgroup$
    – Tyberius
    Jun 5 at 2:01
  • $\begingroup$ Thanks Tyberius, yep, it does not accept .png. I was thinking it might be useful for analyzing diffraction patterns and so would accept most standard image formats. It still might be useful by using a different library to read in .png then convert to a py4DSTEM object like a DiffractionSlice depending on what analysis I want to do. $\endgroup$
    – user3679
    Jun 5 at 4:31
  • 2
    $\begingroup$ Have you looked at the documentation of py4dstem? As the name suggests, it specializes in analyzing 4d STEM data. I don't think it will be convenient for analyzing regular 2d STEM images. $\endgroup$ Jun 26 at 20:24
  • $\begingroup$ @leopold.talirz Yes, thanks. I had assumed analyzing a 2D image would be a part of analyzing a 4D dataset, and I could use that. However, it doesn't read in a 2D image as a default option. $\endgroup$
    – user3679
    Jun 29 at 0:25
  • $\begingroup$ Why is your account unregistered? I was considering to add a 50-point bounty to this question, but with an unregistered account, I'm not even sure if you'll see the answer if I were to do that. $\endgroup$ Jul 12 at 6:47