Skip to content

Commit

Permalink
added possibility to change what is stored in 'name' in json sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
plbenveniste committed Nov 29, 2024
1 parent 477ac83 commit 412aad3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions manual_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ def get_parser():
}\n
"""),
)
parser.add_argument(
'-task-name', type=str, required=False, default='Manual',
help=
"R|The name of the task being done, which will be added in the json file. It must be added between \"\"."
" For example: \"Manual correction of lesions generated from model XXX\" Default: \"Manual\".",
)
parser.add_argument(
'-change-orient',
type=str,
Expand Down Expand Up @@ -530,7 +536,7 @@ def load_custom_json(fname):
sys.exit("ERROR: The file {} is not a valid JSON file.".format(fname))


def update_json(fname_nifti, name_rater, json_metadata):
def update_json(fname_nifti, name_rater, json_metadata, task_name):
"""
Create/update JSON sidecar with meta information
:param fname_nifti: str: File name of the nifti image to associate with the JSON sidecar
Expand Down Expand Up @@ -563,7 +569,7 @@ def update_json(fname_nifti, name_rater, json_metadata):
json_dict['GeneratedBy'].append(json_metadata)

# If the label was modified or just checked, add "Name": "Manual" to the JSON sidecar
json_dict['GeneratedBy'].append({'Name': 'Manual',
json_dict['GeneratedBy'].append({'Name': task_name,
'Author': name_rater,
'Date': time.strftime('%Y-%m-%d %H:%M:%S')})

Expand Down Expand Up @@ -936,10 +942,10 @@ def main():
if args.add_seg_only:
# We use update_json because we are adding a new segmentation, and we want to create
# a JSON file
update_json(fname_out, name_rater, json_metadata)
update_json(fname_out, name_rater, json_metadata, args.task_name)
# Generate QC report
else:
update_json(fname_out, name_rater, json_metadata)
update_json(fname_out, name_rater, json_metadata, args.task_name)
# Generate QC report
generate_qc(fname, fname_out, task, fname_qc, subject, args.config, args.qc_lesion_plane, suffix_dict)

Expand Down

0 comments on commit 412aad3

Please sign in to comment.