OpenSMFS / FRETBursts

Burst analysis software for single and multi-spot single-molecule FRET (smFRET) data.
https://opensmfs.github.io/FRETBursts/
GNU General Public License v2.0
12 stars 9 forks source link

OpenFileDialog in 0.6.3 #3

Closed tritemio closed 6 years ago

tritemio commented 6 years ago

From @DanielisRutkauskas on May 15, 2017 8:59

Hi,

In FRETBursts release 0.6.3 the combination: filename = OpenFileDialog() d = loader.photon_hdf5(filename) does not work, whereas it functioned with older versions. Can this be fixed?

Danielis

Copied from original issue: tritemio/FRETBursts#59

tritemio commented 6 years ago

@DanielisRutkauskas, it should work in 0.6.3 as well, if not is a bug or an issue with installation. I tested it on several windows and mac os machines. Did you install fretbursts via conda? What operating system are you using? Do you get any error message? Does it open the file dialog or not? If the dialog launches, can you type filename in a cell to see the value of filename after using the dialog?

tritemio commented 6 years ago

From @DanielisRutkauskas on May 15, 2017 21:2

Yes, I installed FRETBursts via conda. Windows 10. I get the following: AssertionError Traceback (most recent call last)

in () ----> 1 d = loader.photon_hdf5(filename) C:\Users\Danielis\Anaconda3\lib\site-packages\fretbursts\loader.py in photon_hdf5(filename, ondisk, strict) 250 """ 251 filename = str(filename) --> 252 assert os.path.isfile(filename), 'File not found.' 253 version = phc.hdf5._check_version(filename) 254 if version == u'0.2': AssertionError: File not found. The file dialog opens fine. I can type the filename and see the value of the filename.: b'C:/Users/Danielis/DOC/Work/DataAnalysis/2017_05_15/M3_R.NgoAVII E320C/outAlex.h5' It all works except that the loader function does not digest it as an argument. Must be something simple.
tritemio commented 6 years ago

Mhh, strange. Does calling:

d = loader.photon_hdf5(filename.decode())

makes any difference?

Can you also post the output of conda list?

tritemio commented 6 years ago

From @DanielisRutkauskas on May 16, 2017 6:28

Yes, this makes the difference: d = loader.photon_hdf5(filename.decode()) does not produce an error. However, d does not contain ph_times_t attribute any more. Instead it contains ph_times_m, which should not be there before executing alex functions. And like this, it is not possible to execute any alex functions on d. Conda list is attached. condalist.txt

tritemio commented 6 years ago

@DanielisRutkauskas, you are likely opening an old file that you didn't update to use the ALEX measurement_type. You can check this by opening the file with the graphical utility HDFView, you should see smFRET-usALEX in measurement_type.

The fact that it didn't give any error means that the file is now found (unlike before).

The issue is that OpenFileDialog returns a binary string (note the b before the string) and in your system os.path.isfile does not recognize it as a correct file name. I think the easiest fix would be for FRETBursts to check if the input filename is a binary string and convert it to a normal unicode string so that there are no errors. I cannot get this error on another windows 10 machine so it must depend on some special characters or system locale.

When using OpenFileDialog you can use the already mentioned workaround until the next release:

d = loader.photon_hdf5(filename.decode())

I let you know when I have a fix so you can test it before the next release.

tritemio commented 6 years ago

From @DanielisRutkauskas on May 17, 2017 7:11

All right, the workaround works now, as you suggested it must have been some confusion with Alex/non-Alex files. Thank you for the effort.