brain_deer.infrastructure.bids.import_convert¶
Convert DICOM or flat NIfTI folders into a minimal BIDS layout.
DICOM import is pure Python (pydicom + nibabel) — no MATLAB, no Lead-DBS binaries. The default session split mirrors the common DBS clinical layout:
ses-preop— structural MR (T1w / T2w / FLAIR / SWI / …)ses-postop— post-op CT (and CT variants viaacq-)One NIfTI per
(session, suffix, acq)— no runawayrun-*spamWhen several series collide on the same key, keep the latest study date
Classes¶
Editable mapping row shown in the review UI before commit. |
Functions¶
|
Return |
|
Map one DICOM series to BIDS session/suffix/acq, or |
|
Find |
|
Dry-run: discover subjects/series and return editable review rows (no writes). |
|
Write reviewed rows to |
|
Convert DICOM series into a BIDS tree. Returns dataset root. |
|
Organize loose NIfTI/TRK files into a BIDS-like tree. |
Module Contents¶
- brain_deer.infrastructure.bids.import_convert.guess_suffix_datatype(filename: str, *, modality: str = '', description: str = '', path_hint: str = '') tuple[str, str]¶
Return
(suffix, datatype_folder)from filename / DICOM / folder hints.
- brain_deer.infrastructure.bids.import_convert.classify_dicom_series(series, *, session_mode: str = 'clinical', session_override: str | None = None) SeriesPlan | None¶
Map one DICOM series to BIDS session/suffix/acq, or
Noneto skip.
- brain_deer.infrastructure.bids.import_convert.discover_dicom_subject_folders(root: str | pathlib.Path) list[tuple[str, pathlib.Path]]¶
Find
(subject_id, dicom_folder)pairs under a cohort or single-patient tree.Cohort (e.g. HOTDBS1): each child dir is one patient → one subject.
Single patient folder: returns that folder alone (not one subject per date).
Flat DICOM dump: returns
(folder_name, root).
- class brain_deer.infrastructure.bids.import_convert.ImportReviewRow¶
Editable mapping row shown in the review UI before commit.
- brain_deer.infrastructure.bids.import_convert.plan_dicom_import(dicom_dir: str | pathlib.Path, *, subject: str = 'auto', session: str = 'auto', series_indices: list[int] | None = None, session_mode: str = 'clinical') list[ImportReviewRow]¶
Dry-run: discover subjects/series and return editable review rows (no writes).
- brain_deer.infrastructure.bids.import_convert.commit_dicom_import(rows: list[ImportReviewRow], output_root: str | pathlib.Path, *, dataset_name: str = 'BrainDeer DICOM import', source: str | pathlib.Path | None = None, progress_callback=None) pathlib.Path¶
Write reviewed rows to
rawdata/+ Lead-DBS-stylerawimages.json.
- brain_deer.infrastructure.bids.import_convert.import_dicom_to_bids(dicom_dir: str | pathlib.Path, output_root: str | pathlib.Path, *, subject: str = 'auto', session: str = 'auto', dataset_name: str = 'BrainDeer DICOM import', series_indices: list[int] | None = None, session_mode: str = 'clinical', progress_callback=None, review_rows: list[ImportReviewRow] | None = None) pathlib.Path¶
Convert DICOM series into a BIDS tree. Returns dataset root.
Pure Python — does not call MATLAB or Lead-DBS.
Pass
review_rowsfrom the mapping UI to skip re-planning; otherwise plans automatically (no interactive review — use the dialog for that).
- brain_deer.infrastructure.bids.import_convert.bidsify_flat_folder(source_dir: str | pathlib.Path, output_root: str | pathlib.Path, *, subject: str = '01', session: str = '01', dataset_name: str = 'BrainDeer BIDSify import', copy_files: bool = True) pathlib.Path¶
Organize loose NIfTI/TRK files into a BIDS-like tree.