add units field for anatomical scans - #160
Merged
Merged
Conversation
elizabethlorenc
requested changes
Jul 14, 2025
elizabethlorenc
left a comment
Contributor
There was a problem hiding this comment.
It looks like the requirement that the Units field be specified applies to all scans with the part-phase entity, not just anatomical scans (and not all anatomical scans need the Units field, which I think is what this current version is doing).
For example, XNAT_E01066 scans 8 & 9 are EPI data - scan 8 is part-mag and scan 9 is part-phase. They end up in the func/ folder as this series of files:

| f"{bids_dir}/sub-{subj}/ses-{sess}/anat" for subj in sub_list for sess in sess_list | ||
| ] | ||
|
|
||
| for dir in anat_dirs: |
Contributor
There was a problem hiding this comment.
We need to first check whether the directory exists; if there is no anat directory, this will error out
… func
When we correct phase jsons from with the xnat2bids pipeline, we always pass bids dir, subject, session(s), but if people want to call just the correct_for_bids_schema_validator function they're likely to want to run it on an entire BIDS directory.
E.g.
python -c "from xnat_tools.bids_utils import correct_for_bids_schema_validator; correct_for_bids_schema_validator('~/Documents/BNC/demodat2_mrs/bnc/study-demodat2/bids')"
Also switch to using log_info function, which will use logger if we're in the xnat2bids pipeline and simple print statements if people are calling just the correct_for_bids_schema_validator function
elizabethlorenc
self-requested a review
July 21, 2025 14:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Appends "Units" Field to Anatomical Scans
The required units values, according to the validator, is "rad" or "arbitrary". I chose the latter, but this can be changed if needed.
Q. Is it correct behavior to append the "Units" field to all anatomical scans? If this is only needed for ME-GRE, we could only apply the change to those files. This would require us to ensure scans are properly named at the scanner, ending in MERGE.
The following BIDS Validator 2.0 error for scan XNAT_E00676 was resolved with these changes: