Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with cine.py #401

Open
malopez00 opened this issue Jan 11, 2022 · 4 comments
Open

Problem with cine.py #401

malopez00 opened this issue Jan 11, 2022 · 4 comments
Labels

Comments

@malopez00
Copy link

malopez00 commented Jan 11, 2022

Hi, I just wanted to point out that, after updating Pims I started to have problems while using the .get_frame() function in cine.py

I managed to track down the error to the call to function get_time_to_trigger:

531, in get_frame
    'time_to_trigger': self.get_time_to_trigger(j),

I get the error:

File "C:\Users\malopez\miniconda3\envs\desarrollo\lib\site-packages\pims\cine.py", line 707, in get_time_to_trigger
    tt = tt['datetime'].timestamp() + tt['second_fraction']

OSError: [Errno 22] Invalid argument

I managed to bypass this issue by just deleting the 'time_to_trigger' attribute of the metadata (deleting line 531) but that is just a hotfix. Maybe you guys can figure out which is the problem. Maybe my cine files are old and don't work with new versions of Pims.

Thanks

@schen44
Copy link

schen44 commented Feb 6, 2024

Same problem here.
It can read the file using pims.open, but if I want to call one frame
file = pims.open('file.cine')
plt.imshow(file[0])

The same message showed up.
tt = tt['datetime'].timestamp() + tt['second_fraction']
[Errno 22] Invalid argument

I am using anaconda, Python 3.11.5 with win 10. I attached a file that failed to work with the code.
tt.zip

@nkeim
Copy link
Contributor

nkeim commented Feb 10, 2024

Thanks for the bug reports! After corresponding with @schen44 we're pretty sure that pims can't properly interpret the timestamp(s) in these Cine files, which fails silently on Mac (and results in nonsense timestamps), but raises an error on Windows. It's more likely that your cine files are too new — I'm pretty sure timestamps were working correctly several years ago. We're now trying to track down an updated version of the file format documentation — any leads would be helpful.

@nkeim nkeim added the bug label Feb 10, 2024
@nkeim
Copy link
Contributor

nkeim commented Feb 10, 2024

I can confirm that the two cine files included with pims, in the pims/tests/data directory, both have trigger timestamps that can be properly read by pims. They are from 2008 and 2019. I believe the 2019 file was saved by PCC version 3.3 (see #317). So there is a new format for this timestamp (or that location in the file is now being used for something else, and the timestamp is stored in a new location).

The issue seems to be that the "bad" files' trigger time is interpreted as being around 1970. So a possible crude workaround (besides editing the code) is to manually change the raw value to be something less surprising, for example:

cinefile = pims.open('filename.cine')
cinefile.header_dict['trigger_time'] = int(6e18)

I'll be interested to know if this works!

@schen44
Copy link

schen44 commented Feb 12, 2024

Yes, this works! Thank you so much.

cinefile = pims.open(name)
cinefile.header_dict['trigger_time'] = int(6e18)
print(cinefile[0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants