soft-matter / pims

Python Image Sequence: Load video and sequential images in many formats with a simple, consistent interface.
http://soft-matter.github.io/pims/
Other
258 stars 67 forks source link

Request : return list of supported Bioformats extensions #387

Open b-grimaud opened 3 years ago

b-grimaud commented 3 years ago

Hi,

I would like my script to be able to check wether video files are compatible with its reader, and skip files that aren't. For now, I'm only dealing with TIFF files with imageio, but I'm planning on working with several different proprietary formats, and so I would like to switch to Pims while still retaining that checking capability.

I know it is possible to get a list of Bioformats-supported file types, as described here. However, I feel like it would be much more efficient and convenient to directly call that command from Pims since, as I understand it, there's already a JPype VM running.

Could it be possible to implement such a function ?

nkeim commented 3 years ago

The idiomatic way to do this is to use a try ... except block to try opening the file, and then skip it in case of an IOError (or whatever PIMS raises when it can't read a file; that's easy to check). PIMS does not have separate code to inspect a file for compatibility before it's opened.