Skip to content

Commit

Permalink
fix comments + fstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
SamGuay committed Sep 12, 2023
1 parent 895d87b commit 5c84d76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions dcm2bids/dcm2bids_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def run(self):

def move(self, acq, idList, post_op):
"""Move an acquisition to BIDS format"""
for srcFile in sorted(glob(acq.srcRoot + ".*"), reverse=True):
for srcFile in sorted(glob(f"{acq.srcRoot}.*"), reverse=True):
ext = Path(srcFile).suffixes
ext = [curr_ext for curr_ext in ext if curr_ext in ['.nii', '.gz',
'.json',
Expand Down Expand Up @@ -177,8 +177,10 @@ def move(self, acq, idList, post_op):
acq.setExtraDstFile(curr_post_op["custom_entities"])

# Copy json file with this new set of custom entities.
shutil.copy(str(srcFile).replace("".join(ext), ".json"),
str(acq.extraDstFile) + ".json")
shutil.copy(
str(srcFile).replace("".join(ext), ".json"),
f"{str(acq.extraDstFile)}.json",
)
cmd = cmd.replace('dst_file',
str(acq.extraDstFile) + ''.join(ext))
else:
Expand Down
8 changes: 4 additions & 4 deletions dcm2bids/sidecar.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def post_op(self, value):
"Please check the documentation.")

if 'src_file' not in cmd_split or 'dst_file' not in cmd_split:
raise ValueError("post_op cmd is not defined correctly."
"src_file and/or dst_file is missing."
raise ValueError("post_op cmd is not defined correctly. "
"<src_file> and/or <dst_file> is missing. "
"Please check the documentation.")

if isinstance(datatype, str):
Expand All @@ -208,14 +208,14 @@ def post_op(self, value):
res = list(set([ele for ele in pairs if pairs.count(ele) > 1]))
if res:
raise ValueError("Some post operations apply on "
"the same combination of datatype/suffix."
"the same combination of datatype/suffix. "
"Please fix post_op key in your config file."
f"{pairs}")

self._post_op = post_op

except Exception:
raise ValueError("post_op is not defined correctly."
raise ValueError("post_op is not defined correctly. "
"Please check the documentation.")

@property
Expand Down

0 comments on commit 5c84d76

Please sign in to comment.