Skip to content

Commit

Permalink
fix sidecarChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbore committed Jul 5, 2023
1 parent a09a693 commit 62830c0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions dcm2bids/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(
custom_entities="",
id=None,
srcSidecar=None,
sidecarChanges=None,
sidecar_changes=None,
**kwargs
):
self.logger = logging.getLogger(__name__)
Expand All @@ -44,10 +44,10 @@ def __init__(
self.custom_entities = custom_entities
self.srcSidecar = srcSidecar

if sidecarChanges is None:
self.sidecarChanges = {}
if sidecar_changes is None:
self.sidecar_changes = {}
else:
self.sidecarChanges = sidecarChanges
self.sidecar_changes = sidecar_changes

if id is None:
self.id = None
Expand Down Expand Up @@ -204,16 +204,16 @@ def dstSidecarData(self, idList):
if 'TaskName' in self.srcSidecar.data:
data["TaskName"] = self.srcSidecar.data["TaskName"]

# sidecarChanges
for key, value in self.sidecarChanges.items():
# sidecar_changes
for key, value in self.sidecar_changes.items():
values = []

if not isinstance(value, list):
value = [value]

for val in value:
if isinstance(val, str):
if val not in idList and key in DEFAULT.keyWithPathSidecarChanges:
if val not in idList and key in DEFAULT.keyWithPathsidecar_changes:
logging.warning(f"No id found for '{key}' value '{val}'.")
logging.warning(f"No sidecar changes for field '{key}' "
f"will be made "
Expand Down
2 changes: 1 addition & 1 deletion dcm2bids/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DEFAULT(object):
"run", "mod", "echo", "flip", "inv", "mt", "part",
"recording"]

keyWithPathSidecarChanges = ['IntendedFor', 'Sources']
keyWithPathsidecar_changes = ['IntendedFor', 'Sources']

# misc
tmp_dir_name = "tmp_dcm2bids"
Expand Down
10 changes: 5 additions & 5 deletions docs/how-to/create-config-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"SeriesDescription": "*T2*",
"EchoTime": 0.1
},
"sidecarChanges": {
"sidecar_changes": {
"ProtocolName": "T2"
}
},
Expand Down Expand Up @@ -42,7 +42,7 @@
"criteria": {
"SeriesDescription": "bold_task-learning"
},
"sidecarChanges": {
"sidecar_changes": {
"TaskName": "learning"
}
},
Expand All @@ -53,7 +53,7 @@
"SeriesDescription": "fmap_task-learning"
},
"IntendedFor": "id_task_learning",
"sidecarChanges": {
"sidecar_changes": {
"TaskName": "learning"
}
}
Expand Down Expand Up @@ -148,7 +148,7 @@ custom_entities could also be combined with extractors.
See [custom_entities combined with extractors](./use-advanced-commands.md#custom_entities-combined-with-extractors)


## sidecarChanges
## sidecar_changes

Optional field to change or add information in a sidecar.

Expand All @@ -159,7 +159,7 @@ You will need to set an id to the corresponding description and put the same id

Fo example, **`task_rest`** means it is intended for `task-rest_bold`
and **`id_task_learning`** is intended for `task-learning` which will be
renamed to only `learning` because of the `"sidecarChanges": { "TaskName": "learning" }` field.
renamed to only `learning` because of the `"sidecar_changes": { "TaskName": "learning" }` field.

## Multiple config files

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/use-advanced-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ It means you don't have to add the field in the config file like this.

```
{
"sidecarChanges": {
"sidecar_changes": {
"TaskName": "learning"
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorial/first-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ task name:
"criteria": {
"SeriesDescription": "Axial EPI-FMRI (Interleaved I to S)*"
},
"sidecarChanges": {
"sidecar_changes": {
"TaskName": "rest"
}
}
Expand Down Expand Up @@ -835,7 +835,7 @@ task name:
"criteria": {
"SeriesDescription": "*Axial EPI-FMRI (Interleaved I to S)*"
},
"sidecarChanges": {
"sidecar_changes": {
"TaskName": "rest"
}
}
Expand Down Expand Up @@ -892,7 +892,7 @@ file with the appropriate info.
"criteria": {
"SeriesDescription": "Axial EPI-FMRI (Interleaved I to S)*"
},
"sidecarChanges": {
"sidecar_changes": {
"TaskName": "rest"
}
},
Expand Down
2 changes: 1 addition & 1 deletion example/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"criteria": {
"SeriesDescription": "rs_fMRI"
},
"sidecarChanges": {
"sidecar_changes": {
"SeriesDescription": "rsfMRI"
}
},
Expand Down
8 changes: 4 additions & 4 deletions tests/data/config_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"criteria": {
"SeriesDescription": "locali*"
},
"sidecarChanges": {
"sidecar_changes": {
"ProcedureStepDescription": "Modify by dcm2bids"
}
},
Expand Down Expand Up @@ -46,7 +46,7 @@
"EchoNumber": 1,
"EchoTime": 0.00492
},
"sidecarChanges": {
"sidecar_changes": {
"IntendedFor": ["id_dwi", "T1", "dummy"]
}
},
Expand All @@ -59,7 +59,7 @@
"EchoTime": 0.00738,
"ImageType": ["ORIGINAL", "PRIMARY", "M", "ND"]
},
"sidecarChanges": {
"sidecar_changes": {
"IntendedFor": "id_dwi"
}
},
Expand All @@ -70,7 +70,7 @@
"criteria": {
"SeriesDescription": "DTI_FA"
},
"sidecarChanges": {
"sidecar_changes": {
"IntendedFor": ["id_dwi", "T1"]
}
},
Expand Down
4 changes: 2 additions & 2 deletions tests/data/config_test_auto_extract.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"criteria": {
"SeriesDescription": "gre_field_mapping"
},
"sidecarChanges": {
"sidecar_changes": {
"IntendedFor": ["id_dwi", "T1", "dummy"]
}
},
Expand All @@ -50,7 +50,7 @@
"criteria": {
"SeriesDescription": "DTI_FA"
},
"sidecarChanges": {
"sidecar_changes": {
"IntendedFor": ["id_dwi", "T1"]
}
}
Expand Down

0 comments on commit 62830c0

Please sign in to comment.