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

Add file collection metadata as array-type fields to JSONs #403

Open
tsalo opened this issue Jan 17, 2025 · 0 comments
Open

Add file collection metadata as array-type fields to JSONs #403

tsalo opened this issue Jan 17, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@tsalo
Copy link
Member

tsalo commented Jan 17, 2025

Summary

We could either add this functionality to cubids add-nifti-info or create a new command (cubids add-collection-info?). The idea would be to look for file collections (the combinations of entity and suffix to look for will need to be hardcoded), grab all files in a collection, load the relevant metadata fields, and concatenate them across the files to create an array-type metadata field that would be added to all of the JSONs for the files in the collection.

For example, with a multi-echo BOLD scan, we might have the following files:

  • sub-01_task-rest_echo-1_bold.nii.gz
  • sub-01_task-rest_echo-2_bold.nii.gz
  • sub-01_task-rest_echo-3_bold.nii.gz

The relevant metadata field in this scenario is EchoTime. Let's say that the files have the following metadata dictionaries, respectively:

  • {"EchoTime": 0.015}
  • {"EchoTime": 0.03}
  • {"EchoTime": 0.045}

The aggregation step should flag all three files, collect the EchoTime value from each, and concatenate those values in a new array that gets written out to all three metadata files, so they end up with the following:

  • {"EchoTime": 0.015, "EchoTimes": [0.015, 0.03, 0.045]}
  • {"EchoTime": 0.03, "EchoTimes": [0.015, 0.03, 0.045]}
  • {"EchoTime": 0.045, "EchoTimes": [0.015, 0.03, 0.045]}

Then, cubids group will only have to compare echo 1 to echo 1 across subjects, echo 2 to echo 2, etc. but if there is a variant run where echo 3 has a value of 0.05, then all three echoes of that variant run will be flagged as a variant because the array of echo times ([0.015, 0.03, 0.05] vs. the regular [0.015, 0.03, 0.045]) will differ from the dominant group.

In order to make this work, we need to encode the following in the function:

  1. The "bold" suffix + the "echo" entity defines a file collection.
  2. A file collection defined by the "echo" entity relies on the "EchoTime" metadata field.
@tsalo tsalo added the enhancement New feature or request label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant