Design¶
The package is organized as:
src/xnatcli/cli.py— argparse setup and subcommand dispatch.src/xnatcli/login.py— interactive credential capture, verification, and on-disk storage; also exposesload_credentialsfor the other subcommands.src/xnatcli/download.py— experiment download.src/xnatcli/query.py— CSV listing of (project, subject, experiment) triplets.src/xnatcli/mriconfig.py— runsdcm2bids_helperagainst a downloaded experiment directory.src/xnatcli/mriconvert.py— converts downloaded XNAT sessions to BIDS viadcm2bids.src/xnatcli/cubids.py— runsCuBIDSadd-nifti-infoandgroupon a BIDS dataset.src/xnatcli/bidsmap.py— generates/updates a participant/session mapping TSV for amriconvert-produced BIDS dataset and, with-o, applies renames by copying the dataset to a new tree (usespandas).src/xnatcli/physioconvert.py— converts physio recordings associated (viamriconvert'smriconvert_qc.tsvphysiocolumn) with a BIDS dataset, placing them directly alongside their paired scan (usesphys2bids).
Credentials live in ~/.xnatcli/credentials.cfg, a plain-text configparser file with a single [xnatcli] section storing server, username, and password. The file is created via os.open with mode 0o600 and re-chmod-ed to 0o600 after writing so only the owner can read or write it. (On Windows, os.chmod only toggles the read-only bit — the permissions model there is ACL-based; the 0o600 call still runs for portability.)