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

Find all and only image files for specific filter #771

Closed
mateuszpawlik opened this issue Aug 30, 2021 · 4 comments
Closed

Find all and only image files for specific filter #771

mateuszpawlik opened this issue Aug 30, 2021 · 4 comments

Comments

@mateuszpawlik
Copy link

I'd like to find all image files and only image files for, for example, bold suffix. The following query returns json and image files:

layout.get(scope='raw',suffix='bold')

How to get only image files in the output of get without constraining the file extensions? There are nice classes BIDSJSONFile and BIDSImageFile but I haven't found a way to use them as filters in get.

As a side note, the documentation is rather scarce in that matter and outdated (version 0.11.1 is online). The filters are not really explained.

@effigies
Copy link
Collaborator

I would use:

layout.get(scope='raw',suffix='bold', extension=[".nii", ".nii.gz"])

And yes, we do need to fix our docs. Thanks for reminding me. I'll rebuild and push manually for now...

@mateuszpawlik
Copy link
Author

Thank you, my current solution also used the extension but with a regex.

Now, if I'd like to use BIDSImageFile.get_image(), I have to make sure that I have an image file. I can do this by using the extension in the filter (as you propose) or I found the BIDSFile.class_. Is the class_ attribute meant for such a use case?

@effigies
Copy link
Collaborator

effigies commented Aug 30, 2021

Generally if I find something that begins or ends with _, I would expect that to be a private variable that should not be relied upon by outside tools.

I think isinstance(x, BIDSImageFile) or hasattr(x, "get_image") are going to be the more standard Python ways of checking your object types.

@mateuszpawlik
Copy link
Author

I wanted to avoid type checking but you're right. Thank you.

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

No branches or pull requests

2 participants