Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] - Enable to automagically fill Sources key #211

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
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
33 changes: 16 additions & 17 deletions dcm2bids/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,9 @@ def __init__(
self.modalityLabel = modalityLabel
self.customEntities = customEntities
self.srcSidecar = srcSidecar

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

if intendedFor is None:
self.intendedFor = IntendedFor
else:
self.intendedFor = intendedFor

if id is None:
self.id = None
else:
self.id = id

self.sidecarChanges = {} if sidecarChanges is None else sidecarChanges
self.intendedFor = IntendedFor if intendedFor is None else intendedFor
self.id = None if id is None else id
self.dstFile = ''

def __eq__(self, other):
Expand Down Expand Up @@ -237,7 +224,19 @@ def dstSidecarData(self, intendedForList):

# sidecarChanges
for key, value in self.sidecarChanges.items():
data[key] = value
if key == "Sources":
values = [intendedForList.get(val, val) for val in value]
# handle if nested list vs str
flat_value_list = []
for item in values:
if isinstance(item, list):
flat_value_list += item
else:
flat_value_list.append(item)
data[key] = flat_value_list
else:
data[key] = value


return data

Expand Down