Skip to content

Commit c8fad4e

Browse files
Remove difference between visually checked and modified
1 parent be73315 commit c8fad4e

File tree

1 file changed

+7
-30
lines changed

1 file changed

+7
-30
lines changed

manual_correction.py

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -483,27 +483,11 @@ def get_modification_time(fname):
483483
return datetime.datetime.fromtimestamp(os.path.getmtime(fname))
484484

485485

486-
def check_if_modified(time_one, time_two):
487-
"""
488-
Check if the file was modified by the user. Return True if the file was modified, False otherwise.
489-
:param time_one: modification time of the file before viewing
490-
:param time_two: modification time of the file after viewing
491-
:return:
492-
"""
493-
if time_one != time_two:
494-
print("The label file was modified.")
495-
return True
496-
else:
497-
print("The label file was not modified.")
498-
return False
499-
500-
501-
def update_json(fname_nifti, name_rater, modified):
486+
def update_json(fname_nifti, name_rater):
502487
"""
503488
Create/update JSON sidecar with meta information
504489
:param fname_nifti: str: File name of the nifti image to associate with the JSON sidecar
505490
:param name_rater: str: Name of the expert rater
506-
:param modified: bool: True if the file was modified by the user
507491
:return:
508492
"""
509493
fname_json = fname_nifti.replace('.gz', '').replace('.nii', '.json')
@@ -523,16 +507,10 @@ def update_json(fname_nifti, name_rater, modified):
523507
json_dict = {'SpatialReference': 'orig',
524508
'GeneratedBy': []}
525509

526-
# If the label was modified, add "Name": "Manual" to the JSON sidecar
527-
if modified:
528-
json_dict['GeneratedBy'].append({'Name': 'Manual',
529-
'Author': name_rater,
530-
'Date': time.strftime('%Y-%m-%d %H:%M:%S')})
531-
# If the was not modified, add "Name": ""Visually verified"" to the JSON sidecar
532-
else:
533-
json_dict['GeneratedBy'].append({'Name': 'Visually verified',
534-
'Author': name_rater,
535-
'Date': time.strftime('%Y-%m-%d %H:%M:%S')})
510+
# If the label was modified or just checked, add "Name": "Manual" to the JSON sidecar
511+
json_dict['GeneratedBy'].append({'Name': 'Manual',
512+
'Author': name_rater,
513+
'Date': time.strftime('%Y-%m-%d %H:%M:%S')})
536514

537515
# Write the data to the JSON file
538516
with open(fname_json, 'w') as outfile: # w to overwrite the file
@@ -895,11 +873,10 @@ def main():
895873
if args.add_seg_only:
896874
# We are passing modified=True because we are adding a new segmentation and we want
897875
# to create a JSON file
898-
update_json(fname_out, name_rater, modified=True)
876+
update_json(fname_out, name_rater)
899877
# Generate QC report
900878
else:
901-
modified = check_if_modified(time_one, time_two)
902-
update_json(fname_out, name_rater, modified)
879+
update_json(fname_out, name_rater)
903880
# Generate QC report
904881
generate_qc(fname, fname_out, task, fname_qc, subject, args.config, args.qc_lesion_plane, suffix_dict)
905882

0 commit comments

Comments
 (0)