Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4c298ee
improve version + internet check
SamGuay Jun 11, 2026
dd2909e
add most recent stable bids schema
SamGuay Jun 11, 2026
33ddf4e
avoir circular import when adding schema feature
SamGuay Jun 12, 2026
35fe793
add first pass for schema
SamGuay Jun 12, 2026
2ed8738
add bids_version feature
SamGuay Jun 12, 2026
499e9b7
add tests
SamGuay Jun 12, 2026
120ad4e
house cleaning
SamGuay Jun 12, 2026
0ef2704
remove DONE todo
SamGuay Jun 12, 2026
c94cc6e
try forcing a download before moving to local bundled spec
SamGuay Jun 12, 2026
936195d
moving testing entities to locally bundled schema instead
SamGuay Jun 12, 2026
26c59c1
improve default use
SamGuay Jun 26, 2026
42a9579
complete the mri entity only
SamGuay Jun 30, 2026
96e08fb
fix schema test
SamGuay Jun 30, 2026
02bff33
disable codespell on the raw schema (:
SamGuay Jun 30, 2026
623c69f
third time's a charm
SamGuay Jun 30, 2026
2d33232
fix typos
SamGuay Jun 30, 2026
506e2f0
update tuto
SamGuay Jun 30, 2026
3e97f71
document the new feature
SamGuay Jun 30, 2026
a911174
swap bundled for default
SamGuay Jun 30, 2026
51cad56
Fix easy comments from Arnaud's review
SamGuay Jun 30, 2026
38afb95
refactor schema stuff from dcm2bids cli to schema.py
SamGuay Jun 30, 2026
dab0ca4
remove empty space
SamGuay Jul 1, 2026
db06044
Merge branch 'dev' into pull_schema
SamGuay Jul 1, 2026
19deb4c
change default for schema-derived
SamGuay Jul 8, 2026
1b30711
Revert "change default for schema-derived"
SamGuay Jul 8, 2026
e614384
fix linting issues + mv schema version
SamGuay Jul 10, 2026
9bb9b0b
revert to drop in replacement for default.entities*
SamGuay Jul 10, 2026
679538e
break down get_schema
SamGuay Jul 10, 2026
32e8de1
Merge remote-tracking branch 'upstream/dev' into pull_schema
SamGuay Jul 10, 2026
59ea7dc
Update first-steps.md
arnaudbore Jul 29, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
run: uv sync --group test

- name: Run tests
run: uv run pytest
run: uv run pytest
4 changes: 1 addition & 3 deletions dcm2bids/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ def setExtraDstFile(self, new_entities):
"""
Return:
The destination filename formatted following
the v1.9.0 BIDS entity key table
https://bids-specification.readthedocs.io/en/v1.9.0/99-appendices/04-entity-table.html
the BIDS entity key order according to the schema
"""

if self.custom_entities.strip() == "":
Expand Down Expand Up @@ -258,7 +257,6 @@ def setDstFile(self):
to: {new_name}""")
self.dstFile = new_name


def dstSidecarData(self, idList):
"""
"""
Expand Down
44 changes: 36 additions & 8 deletions dcm2bids/cli/dcm2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from dcm2bids.dcm2bids_gen import Dcm2BidsGen
from dcm2bids.utils.utils import DEFAULT
from dcm2bids.utils.tools import dcm2niix_version, check_latest
from dcm2bids.utils.schema import load_schema
from dcm2bids.participant import Participant
from dcm2bids.utils.logger import setup_logging
from dcm2bids.version import __version__
Expand Down Expand Up @@ -61,7 +62,7 @@ def _build_arg_parser():
g = p.add_mutually_exclusive_group()
g.add_argument("--auto_extract_entities",
action='store_true',
help="If set, it will automatically try to extract entity"
help="If set, it will automatically try to extract entity "
"information [task, dir, echo] based on the suffix and datatype."
" Default is [%(default)s]")

Expand All @@ -73,6 +74,18 @@ def _build_arg_parser():
"Cannot be used with --auto_extract_entities. "
" Default is [%(default)s]")

p.add_argument("-b", "--bids_version",
default=None,
help=(
"Set the BIDS specification version to follow (e.g. 'v1.11.1', 'stable', 'latest' or 'default')."
"\nThis controls which BIDS schema and rules dcm2bids uses for automatic entity extraction and ordering."
"\nIf not provided, dcm2bids uses the 'default' BIDS spec for reproducible, offline-friendly behavior."
"\nFor long-running or shared pipelines, consider pinning a specific tag (e.g. 'v1.11.1')."
"\nWhen internet is available, it will check once whether the remote 'stable' is newer and, if so, \n"
"suggest updating to that specific version tag."
),
)

p.add_argument("--bids_validate",
action='store_true',
help="If set, once your conversion is done it "
Expand All @@ -98,15 +111,20 @@ def _build_arg_parser():
required=False,
default=DEFAULT.cli_log_level,
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
help="Set logging level to the console."
help="Set logging level to the console."
" The default level is [%(default)s]"
)

p.add_argument("-v", "--version",
action="version",
version=f"dcm2bids version:\t{__version__}\n"
f"Based on BIDS version:\t{DEFAULT.bids_version}",
help="Report dcm2bids version and the BIDS version.")
# This uses version.__BIDSversion__, which reflects the bundled schema version.
version=(
f"dcm2bids version:\t{__version__}\n"
f"default BIDS version:\t{DEFAULT.bids_version} "
"unless overridden by --bids_version."
),
help="Report dcm2bids version and the default BIDS specification version it follows by default."
)

return p

Expand All @@ -129,13 +147,23 @@ def main():
logger.info("Running the following command: " + " ".join(sys.argv))
logger.info("OS version: %s", platform.platform())
logger.info("Python version: %s", sys.version.replace("\n", ""))
logger.info(f"dcm2bids version: { __version__}")
logger.info(f"dcm2bids version: {__version__}")
logger.info(f"dcm2niix version: {dcm2niix_version()}")
logger.info("Checking for software update")

check_latest("dcm2bids")
check_latest("dcm2bids", log_dir=log_dir)
if not args.skip_dcm2niix:
check_latest("dcm2niix")
check_latest("dcm2niix", log_dir=log_dir)

schema, derived_entities = load_schema(args.bids_version, log_dir=log_dir)

# Update the DEFAULT based on the requested version directly, otherwise uses default values
if args.bids_version is not None:
DEFAULT.bids_version = schema["bids_version"]
DEFAULT.entityTableKeys = derived_entities.get("entity_table_keys",
DEFAULT.entityTableKeys)
DEFAULT.auto_entities = derived_entities.get("auto_entities",
DEFAULT.auto_entities)

logger.info(f"participant: {participant.name}")
if participant.session:
Expand Down
8 changes: 5 additions & 3 deletions dcm2bids/cli/dcm2bids_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,14 @@ def main():
logger.info("Running the following command: " + " ".join(sys.argv))
logger.info("OS version: %s", platform.platform())
logger.info("Python version: %s", sys.version.replace("\n", ""))
logger.info(f"dcm2bids version: { __version__}")
logger.info(f"dcm2bids version: {__version__}")
logger.info(f"dcm2niix version: {dcm2niix_version()}")
logger.info("Checking for software update")

check_latest("dcm2bids")
check_latest("dcm2niix")
log_dir = log_file.parent

check_latest("dcm2bids", log_dir=log_dir)
check_latest("dcm2niix", log_dir=log_dir)

app = Dcm2niixGen(dicom_dirs=args.dicom_dir, bids_dir=out_dir, helper=True)

Expand Down
6 changes: 4 additions & 2 deletions dcm2bids/cli/dcm2bids_scaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ def main():
logger.info("Running the following command: " + " ".join(sys.argv))
logger.info("OS version: %s", platform.platform())
logger.info("Python version: %s", sys.version.replace("\n", ""))
logger.info(f"dcm2bids version: { __version__}")
logger.info(f"dcm2bids version: {__version__}")
logger.info("Checking for software update")

check_latest("dcm2bids")
log_dir = log_file.parent
check_latest("dcm2bids", log_dir=log_dir)


logger.info("The files used to create your BIDS directory were taken from "
"https://github.com/bids-standard/bids-starter-kit. \n")
Expand Down
6 changes: 3 additions & 3 deletions dcm2bids/dcm2bids_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
output_dir=DEFAULT.output_dir,
bids_validate=DEFAULT.bids_validate,
auto_extract_entities=DEFAULT.auto_extract_entities,
do_not_reorder_entities = DEFAULT.do_not_reorder_entities,
do_not_reorder_entities=DEFAULT.do_not_reorder_entities,
session=DEFAULT.session,
clobber=DEFAULT.clobber,
force_dcm2bids=DEFAULT.force_dcm2bids,
Expand All @@ -64,8 +64,8 @@ def __init__(

if self.auto_extract_entities and self.do_not_reorder_entities:
raise ValueError("Auto extract entities is set to True and "
"do not reorder entities is set to True. "
"Please choose only one option.")
"do not reorder entities is set to True. "
"Please choose only one option.")

@property
def dicom_dirs(self):
Expand Down
4 changes: 2 additions & 2 deletions dcm2bids/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def name(self, name):

if not self._name.replace('sub-', '').isalnum():
raise NameError(f"Participant '{self._name.replace('sub-', '')}' "
"should contains only alphanumeric characters.")
"should contain only alphanumeric characters.")

@property
def session(self):
Expand All @@ -64,7 +64,7 @@ def session(self, session):

if not self._session.replace('ses-', '').isalnum() and self._session:
raise NameError(f"Session '{self._session.replace('ses-', '')}' "
"should contains only alphanumeric characters.")
"should contain only alphanumeric characters.")

@property
def directory(self):
Expand Down
Loading