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]: cannot load a nifti image in the medical folder dataset of Fed-BioMed if it contains dots (.) in its name #1105

Open
ybouilla opened this issue May 16, 2024 · 1 comment · May be fixed by #1249
Labels
bug this issue is about reporting and resolving a suspected bug good first issue nice to pick for a new contributor in review issue implementation is finished, a merge request open and is ready for review (or under review)

Comments

@ybouilla
Copy link
Contributor

When loading a medical folder dataset, if the name of your image contains dots ., the medical folder dataset loader fails to recognize it as a nifti image and raise an error IndexError.

As an example, if I load my.nifti.image.nii, medical folder dataset parses it as of extension nifti.image.nii instead of nii and fails to load the dataset.

This is due in the code of the p.suffixes in load_image in the MedicalFolderDataset that only considers what remains after the first dot as the file extension, which is a weak way to process file name.

@ybouilla ybouilla added bug this issue is about reporting and resolving a suspected bug good first issue nice to pick for a new contributor labels May 16, 2024
@ybouilla
Copy link
Contributor Author

One solution could be to use os.path.splitext to extract extension

As an example:

>>> os.path.splitext('1.4.9.12.34.1.8527.4108713574735248556281156520855496517752_t1_se_tra_20180424000000_4.nii')
('1.4.9.12.34.1.8527.4108713574735248556281156520855496517752_t1_se_tra_20180424000000_4',
 '.nii')

ybouilla added a commit that referenced this issue Nov 21, 2024
…n issue #1105

Details:
This bug is raised if the image name contains dots( eg '1.345.234.nii` will fail).
 This is due to how nifti images are detected in the code of medical folder
ybouilla added a commit that referenced this issue Nov 21, 2024
…ts (`.`)

Details:
Previous behaviour was that the extension was captured when the first dot in th>
name of the file was found.
Now, with the bug fix, it Only checks the ending of the string, and compares it
to allowed extension.
@ybouilla ybouilla linked a pull request Nov 21, 2024 that will close this issue
@ybouilla ybouilla added the in review issue implementation is finished, a merge request open and is ready for review (or under review) label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug this issue is about reporting and resolving a suspected bug good first issue nice to pick for a new contributor in review issue implementation is finished, a merge request open and is ready for review (or under review)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant