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

BUG: ecatpet2bids.py: negative values overflowing into positive ones #294

Closed
nbeliy opened this issue Apr 15, 2024 · 3 comments · Fixed by #278
Closed

BUG: ecatpet2bids.py: negative values overflowing into positive ones #294

nbeliy opened this issue Apr 15, 2024 · 3 comments · Fixed by #278
Assignees
Labels
bug Something isn't working

Comments

@nbeliy
Copy link

nbeliy commented Apr 15, 2024

Describe the bug
Having an ECAT7 image with negative voxels (we have images reconstructed with FBP), the converted images contains only positive and very large values. Where spm's spm_ecat2nifti shows -2266.532958984375, ecatpet2bids produces 72494.859375

Positive values are the same, comparing with spm.

To Reproduce
Convert ECAT image with negative values

Expected behaviour
The negative values must be conserved.

Desktop (please complete the following information):
Python 3.8.10
pypet2bids==1.3.9

@nbeliy nbeliy added the bug Something isn't working label Apr 15, 2024
@mnoergaard
Copy link
Contributor

Hi @nbeliy. Thanks for raising this issue. We are of aware of this bug for the python part (#272), and are currently working on a solution. Matlab version works fine.

@nbeliy
Copy link
Author

nbeliy commented Apr 15, 2024

Ah, ok.

If it could help, problem may come from read_ecat.py:408, where data type 6 is interpreted as unsigned int16 (>H), while nibabel interprets as signed int16. SPM treats all data types as int16.

Nibabel reference some documents on Turku website, but the documents are no longer there.

As I'm here, the lines :

    if ".gz" in ecat_file:
        ecat_file = decompress(ecat_file)

may cause a crash if the name of file contains .gz somewhere in the middle. It will be better to replace the if by:

    if ecat_file.endswith(".gz"):
        ecat_file = decompress(ecat_file)

@bendhouseart
Copy link
Contributor

Duplicate issue to #272, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants