Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

convertall.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import os
  2. # create a function called create_key
  3. def create_key(template, outtype=('nii.gz',), annotation_classes=None):
  4. if template is None or not template:
  5. raise ValueError('Template must be a valid format string')
  6. return template, outtype, annotation_classes
  7. def infotodict(seqinfo):
  8. # Section 1: These key definitions should be revised by the user
  9. ###################################################################
  10. # For each sequence, define a variable using the create_key function:
  11. # variable = create_key(output_directory_path_and_name).
  12. #
  13. # "data" creates sequential numbers which can be for naming sequences.
  14. # This is especially valuable if you run the same sequence multiple times at the scanner.
  15. data = create_key('run-{item:03d}')
  16. t1w = create_key('sub-{subject}/{session}/anat/sub-{subject}_{session}_T1w')
  17. tse = create_key('sub-{subject}/{session}/anat/sub-{subject}_{session}_acq-tse_T2w')
  18. dwi = create_key('sub-{subject}/{session}/dwi/sub-{subject}_{session}_acq-AP_dwi')
  19. fmap_rev_phase = create_key('sub-{subject}/{session}/fmap/sub-{subject}_{session}_dir-PA_epi')
  20. fmap_mag = create_key('sub-{subject}/{session}/fmap/sub-{subject}_{session}_magnitude')
  21. fmap_phase = create_key('sub-{subject}/{session}/fmap/sub-{subject}_{session}_phasediff')
  22. func_rest = create_key('sub-{subject}/{session}/func/sub-{subject}_{session}_task-rest_run-01_bold')
  23. func_rest_post = create_key('sub-{subject}/{session}/func/sub-{subject}_{session}_task-rest_run-02_bold')
  24. asl = create_key('sub-{subject}/{session}/func/sub-{subject}_{session}_acq-asl_run-01')
  25. asl_post = create_key('sub-{subject}/{session}/func/sub-{subject}_{session}_acq-asl_run-02')
  26. # Section 1b: This data dictionary (below) should be revised by the user.
  27. # It uses the variables defines above as keys.
  28. ##########################################################################
  29. # Enter a key in the dictionary for each key you created above in section 1.
  30. info = {data: [], t1w: [], tse: [], dwi: [], fmap_rev_phase: [], fmap_mag: [], fmap_phase: [], func_rest: [], func_rest_post: [], asl: [], asl_post: []}
  31. last_run = len(seqinfo)
  32. # Section 2: These criteria should be revised by user.
  33. ##########################################################
  34. # Define test criteria to check that each dicom sequence is correct
  35. # seqinfo (s) refers to information in dicominfo.tsv. Consult that file for
  36. # available criteria.
  37. # Here we use two types of criteria:
  38. # 1) An equivalent field "==" (e.g., good for checking dimensions)
  39. # 2) A field that includes a string (e.g., 'mprage' in s.protocol_name)
  40. for idx, s in enumerate(seqinfo):
  41. if ('mprage' in s.protocol_name) and (s.dim3 == 176):
  42. info[t1w].append(s.series_id)
  43. if ('TSE' in s.protocol_name):
  44. info[tse].append(s.series_id)
  45. if ('DTI' in s.protocol_name) and (s.dim3 == 74) and (s.dim4 == 32):
  46. info[dwi].append(s.series_id)
  47. if ('verify_P-A' in s.protocol_name):
  48. info[fmap_rev_phase] = [s.series_id]
  49. if ('field_mapping' in s.protocol_name) and (s.dim3 == 64):
  50. info[fmap_mag] = [s.series_id]
  51. if ('field_mapping' in s.protocol_name) and (s.dim3 == 32):
  52. info[fmap_phase] = [s.series_id]
  53. if ('restingstate' == s.protocol_name):
  54. info[func_rest].append(s.series_id)
  55. if ('Post_TMS_restingstate' == s.protocol_name):
  56. info[func_rest_post].append(s.series_id)
  57. if ('ASL_3D_tra_iso' == s.protocol_name):
  58. info[asl].append(s.series_id)
  59. if ('Post_TMS_ASL_3D_tra_iso' == s.protocol_name):
  60. info[asl_post].append(s.series_id)
  61. return info