tritemio / FRETBursts

Burst analysis software for smFRET. **Moved to OpenSMFS organization**
https://github.com/OpenSMFS/FRETBursts
GNU General Public License v2.0
16 stars 17 forks source link

OpenFileDialog in 0.6.3 #59

Closed DanielisRutkauskas closed 7 years ago

DanielisRutkauskas commented 7 years ago

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

tritemio commented 7 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?

DanielisRutkauskas commented 7 years ago

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 7 years ago

Mhh, strange. Does calling:

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

makes any difference?

Can you also post the output of conda list?

DanielisRutkauskas commented 7 years ago

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 7 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.

DanielisRutkauskas commented 7 years ago

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.

tritemio commented 7 years ago

This issue was moved to OpenSMFS/FRETBursts#3