Skip to content

add units field for anatomical scans - #160

Merged
elizabethlorenc merged 4 commits into
mainfrom
fix-bids-anat-phase-units
Jul 21, 2025
Merged

add units field for anatomical scans#160
elizabethlorenc merged 4 commits into
mainfrom
fix-bids-anat-phase-units

Conversation

@fordmcdonald

@fordmcdonald fordmcdonald commented Jul 8, 2025

Copy link
Copy Markdown
Member

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:

	[ERROR] SIDECAR_KEY_REQUIRED A data file's JSON sidecar is missing a key listed as required.
		Units

@fordmcdonald
fordmcdonald marked this pull request as ready for review July 8, 2025 14:47
@fordmcdonald fordmcdonald self-assigned this Jul 8, 2025

@elizabethlorenc elizabethlorenc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Screenshot 2025-07-14 at 12 53 55 PM

Comment thread xnat_tools/bids_utils.py Outdated
f"{bids_dir}/sub-{subj}/ses-{sess}/anat" for subj in sub_list for sess in sess_list
]

for dir in anat_dirs:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to first check whether the directory exists; if there is no anat directory, this will error out

fordmcdonald and others added 2 commits July 15, 2025 14:55
… 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
elizabethlorenc self-requested a review July 21, 2025 14:47
@elizabethlorenc
elizabethlorenc merged commit 67b4f1a into main Jul 21, 2025
5 checks passed
@elizabethlorenc
elizabethlorenc deleted the fix-bids-anat-phase-units branch July 21, 2025 14:48
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

Successfully merging this pull request may close these issues.

2 participants