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

Fix: fetch specific label from gii labels #574

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions siibra/volumes/providers/gifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,19 @@ def __init__(self, url: Union[str, dict]):
else:
raise NotImplementedError(f"Urls for {self.__class__.__name__} are expected to be of type str or dict.")

def fetch(self, fragment: str = None, **kwargs):
def fetch(self, fragment: str = None, label: int = None, **kwargs):
"""Returns a 1D numpy array of label indices."""
labels = []
for fragment_name, loader in self._loaders.items():
if fragment is not None and fragment.lower() not in fragment_name.lower():
continue
assert len(loader.data.darrays) == 1
labels.append(loader.data.darrays[0].data)
if label is not None:
labels.append(
((loader.data.darrays[0].data == label) * label).astype('uint8')
)
else:
labels.append(loader.data.darrays[0].data)

return {"labels": np.hstack(labels)}

Expand Down
Loading