Skip to content

Commit 8de2755

Browse files
committed
Make bidscoiner more robust against unknown runs
1 parent dd47203 commit 8de2755

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

bidscoin/bids.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,8 @@ def get_bidsname(subid: str, sesid: str, modality: str, run: dict, runindex: str
12261226
assert modality in bidsmodalities + (unknownmodality, ignoremodality)
12271227

12281228
# Try to update the sub/ses-ids
1229-
subid, sesid = get_subid_sesid(Path(run['provenance']), subid, sesid, subprefix, sesprefix)
1229+
if run['provenance']:
1230+
subid, sesid = get_subid_sesid(Path(run['provenance']), subid, sesid, subprefix, sesprefix)
12301231

12311232
# Validate and do some checks to allow for dragging the run entries between the different modality-sections
12321233
run = copy.deepcopy(run) # Avoid side effects when changing run

heuristics/bidsmap_dccn.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DICOM:
4141
subject: <<SourceFilePath>> # <<SourceFilePath>> extracts the subject label from the source directory during bidscoiner runtime. A DICOM attribute can also be used as subject-label instead, e.g. <PatientID>
4242
session: <<SourceFilePath>> # <<SourceFilePath>> extracts the session label from the source directory during bidscoiner runtime. A DICOM attribute can also be used as session-label instead, e.g. <StudyID>
4343
anat: # ----------------------- All anatomical runs --------------------
44-
- provenance: ~ # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
44+
- provenance: "" # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
4545
attributes: &anatattributes_dicom # The first item with empty attributes will not match anything but will be used when changing modality in the bidseditor GUI -> suffix = T1w
4646
Modality: ~
4747
ProtocolName: ~
@@ -518,7 +518,7 @@ PAR:
518518
subject: <<SourceFilePath>> # <<SourceFilePath>> extracts the subject label from the source directory during bidscoiner runtime. A DICOM attribute can also be used as subject-label instead, e.g. <PatientID>
519519
session: <<SourceFilePath>> # <<SourceFilePath>> extracts the session label from the source directory during bidscoiner runtime. A DICOM attribute can also be used as session-label instead, e.g. <StudyID>
520520
anat: # ----------------------- All anatomical runs --------------------
521-
- provenance: ~ # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
521+
- provenance: "" # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
522522
attributes: &anatattributes_par
523523
series_type: ~
524524
exam_name: ~
@@ -540,7 +540,7 @@ PAR:
540540
run: <<1>>
541541
mod: ~
542542
suffix: T1w
543-
- provenance: ~ # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
543+
- provenance: "" # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
544544
attributes:
545545
<<: *anatattributes_par
546546
protocol_name: ['*mprage*', '*MPRAGE*', '*MPRage*', '*t1w*', '*T1w*', '*T1W*', '*T1*']

heuristics/bidsmap_template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DICOM:
4141
subject: <<SourceFilePath>> # <<SourceFilePath>> extracts the subject label from the source directory during bidscoiner runtime. A DICOM attribute can also be used as subject-label instead, e.g. <PatientID>
4242
session: <<SourceFilePath>> # <<SourceFilePath>> extracts the session label from the source directory during bidscoiner runtime. A DICOM attribute can also be used as session-label instead, e.g. <StudyID>
4343
anat: # ----------------------- All anatomical runs --------------------
44-
- provenance: ~ # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
44+
- provenance: "" # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
4545
attributes: &anatattributes_dicom
4646
Modality: ~
4747
ProtocolName: ~
@@ -399,7 +399,7 @@ PAR:
399399
subject: <<SourceFilePath>> # <<SourceFilePath>> extracts the subject label from the source directory during bidscoiner runtime. A DICOM attribute can also be used as subject-label instead, e.g. <PatientID>
400400
session: <<SourceFilePath>> # <<SourceFilePath>> extracts the session label from the source directory during bidscoiner runtime. A DICOM attribute can also be used as session-label instead, e.g. <StudyID>
401401
anat: # ----------------------- All anatomical runs --------------------
402-
- provenance: ~ # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
402+
- provenance: "" # The fullpath name of the DICOM file from which the attributes are read. Serves also as a look-up key to find a run in the bidsmap
403403
attributes: &anatattributes_par
404404
series_type: ~
405405
exam_name: ~

0 commit comments

Comments
 (0)