xnatqa 0.0.15__py3-none-any.whl → 0.0.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
xnatqa/launch.py ADDED
@@ -0,0 +1,50 @@
1
+ import os
2
+ import yaxil
3
+ import argparse
4
+
5
+ def main():
6
+ # So, at this point, everything has been labeled for this session.
7
+ # We now need to:
8
+
9
+ # Identify all of the tagged scans in this sessions
10
+ # For each tagged scan, launch the appropriate QA routine
11
+
12
+ # parse input arguments
13
+ parser = argparse.ArgumentParser(description="XNAT QA Workflow")
14
+ parser.add_argument("--experiment", default = "", required=True)
15
+ parser.add_argument("--dryrun", default = "", action='store_true', help="Run in dry run mode: No launching of jobs")
16
+
17
+ args, unknown_args = parser.parse_known_args()
18
+ MRsession = args.experiment
19
+ dryrun = args.dryrun
20
+
21
+ # authenticate with xnat using the ~/.xnat_auth file created earlier in the workflow
22
+ auth = yaxil.auth(alias = 'xnat')
23
+
24
+ # open and automatically close a connection to XNAT using the auth
25
+ with yaxil.session(auth) as sess:
26
+ # keep track of the number of BOLD (b) and ANAT (a) scans idenfified
27
+ b = 0
28
+ a = 0
29
+
30
+ # for each scan in this session...
31
+ for scan in sess.scans(label=MRsession):
32
+
33
+ # this scan's note
34
+ note = scan['note']
35
+
36
+ # if that note has a "#BOLD" tag...
37
+ if '#BOLD' in note:
38
+ print('Run BOLDQC:')
39
+ print(f'qsub -P cncxnat boldqc.qsub {MRsession} {b}')
40
+ if not dryrun:
41
+ os.system(f'qsub -P cncxnat boldqc.qsub {MRsession} {b}')
42
+ b+=1
43
+
44
+ # if that note has a "#T1w" tag...
45
+ if '#T1w' in note:
46
+ print('Run ANATQC:')
47
+ print(f'qsub -P cncxnat anatqc.qsub {MRsession} {a}')
48
+ if not dryrun:
49
+ os.system(f'qsub -P cncxnat anatqc.qsub {MRsession} {a}')
50
+ a+=1
xnatqa/tag/__init__.py CHANGED
@@ -19,7 +19,7 @@ def generate_tagger_config(dicom_dir):
19
19
  # This seems to work well most of the time, with the odd hicups. I include manual code here to catch the "hicups".
20
20
 
21
21
  # call to dcm2niix. generates a bunch of *.json text files in the current working directory.
22
- os.system(f"dcm2niix -s y -a y -b o -o $PWD -f 'output_%s_%d' -w 0 -m 1 -i y {dicom_dir}")
22
+ os.system(f"dcm2niix -s y -a y -b o -o $PWD -f 'output_%s_%d' -w 0 -m 1 -i y {dicom_dir} &>>log.txt")
23
23
 
24
24
  # idenfity all of these text files
25
25
  jsonFiles = glob(os.path.abspath('./output*.json'))
@@ -180,8 +180,6 @@ def generate_tagger_config(dicom_dir):
180
180
  with open('tagger.yaml', 'a') as file:
181
181
  yaml.dump(tagger_data, file)
182
182
 
183
- print(tagger_data)
184
-
185
183
  def update_xnat_tags(MRsession):
186
184
 
187
185
  # make sure an xnat authentication files has already been created. See YXAIL documentation.
@@ -190,11 +188,12 @@ def update_xnat_tags(MRsession):
190
188
  # run the command
191
189
  os.system(f'xnat_tagger.py --label {MRsession} --target-modality all --xnat-alias xnat --config tagger.yaml')
192
190
 
193
- def tag_scans(dicom_dir, MRsession):
191
+ def tag_scans(dicom_dir, MRsession, dryrun):
194
192
 
195
193
  # generate the xnattag config file
196
194
  generate_tagger_config(dicom_dir)
197
195
 
198
196
  # update the xnat tags
199
- update_xnat_tags(MRsession)
197
+ if not dryrun:
198
+ update_xnat_tags(MRsession)
200
199
 
xnatqa/xnatqa.py CHANGED
@@ -8,17 +8,19 @@ def main():
8
8
  parser = argparse.ArgumentParser(description="XNAT QA Workflow")
9
9
  parser.add_argument("--dicom_dir", default="/input", help = "where the DICOMs are located", required=True)
10
10
  parser.add_argument("--experiment", default = "", required=True)
11
+ parser.add_argument("--dryrun", default = "", action='store_true', help="Run in dry run mode: No upload to XNAT")
11
12
 
12
13
  args, unknown_args = parser.parse_known_args()
13
14
  dicom_dir = os.path.join(args.dicom_dir, 'SCANS')
14
15
  experiment = args.experiment
16
+ dryrun = args.dryrun
15
17
 
16
18
  # run xnat authentication for this container. writes an ~/.xnat_auth file to the home directory
17
19
  # this file is used in all subsequent calls to XNAT
18
20
  os.system(f'xnat_auth --alias xnat --url $XNAT_HOST --username $XNAT_USER --password $XNAT_PASS')
19
21
 
20
22
  # tag all scans in this session
21
- tag_scans(dicom_dir, experiment)
23
+ tag_scans(dicom_dir, experiment, dryrun)
22
24
 
23
25
  if __name__ == "__main__":
24
26
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xnatqa
3
- Version: 0.0.15
3
+ Version: 0.0.17
4
4
  Summary: A workflow for automatically tagging MRI scans within XNAT
5
5
  Author-email: Kyle Kurkela <kkurkela@bu.edu>
6
6
  License-Expression: MIT
@@ -0,0 +1,10 @@
1
+ xnatqa/__init__.py,sha256=RIG_ihjfFD1upKlhlxI-9Fs4ISf0lIW4Zg7CaFirV4A,644
2
+ xnatqa/launch.py,sha256=jZTCAftrT5MBcbPKXNorFux5TkezyktJBhzJaKI4ypM,1797
3
+ xnatqa/xnatqa.py,sha256=KUXfs6EAZX15K2s8JcsIXuUOV1swma_7gJw-IRkD1yM,1016
4
+ xnatqa/tag/__init__.py,sha256=wXPBIbHucCqITYVZ4V5bt3VJWq8svyrJoBjbrpH1bNE,8969
5
+ xnatqa-0.0.17.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ xnatqa-0.0.17.dist-info/METADATA,sha256=NdGanatTgamPgLnL20wQHgJYdJj7eHU2ZGoNdnXs2eE,1187
7
+ xnatqa-0.0.17.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
8
+ xnatqa-0.0.17.dist-info/entry_points.txt,sha256=g5CvKDfx6vIIp76wdB1aiWe1SkBORj2S8gFReBBxBws,74
9
+ xnatqa-0.0.17.dist-info/top_level.txt,sha256=FmRWgO6ww0FwyNs5ccyhP9FcAxI129qSJqLs2OKOxJw,7
10
+ xnatqa-0.0.17.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
+ launch = xnatqa.launch:main
2
3
  xnatqa = xnatqa.xnatqa:main
@@ -1,9 +0,0 @@
1
- xnatqa/__init__.py,sha256=RIG_ihjfFD1upKlhlxI-9Fs4ISf0lIW4Zg7CaFirV4A,644
2
- xnatqa/xnatqa.py,sha256=RJp65oIE13COs_0UG4hEku_f6YFDpoQV4JHEhtppXfs,861
3
- xnatqa/tag/__init__.py,sha256=7i24jiDBNJdv6VF9RzkRrprXuZKpnV63bvEXnLaDXk0,8951
4
- xnatqa-0.0.15.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- xnatqa-0.0.15.dist-info/METADATA,sha256=Pi0vL85UOTqbwRUYFbU4obHjif3acmEAoqeBf5yhMAQ,1187
6
- xnatqa-0.0.15.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
7
- xnatqa-0.0.15.dist-info/entry_points.txt,sha256=UqPAByHiJTqwkT0UBymn6EOIGBlPsb9mEZK86HIahs8,46
8
- xnatqa-0.0.15.dist-info/top_level.txt,sha256=FmRWgO6ww0FwyNs5ccyhP9FcAxI129qSJqLs2OKOxJw,7
9
- xnatqa-0.0.15.dist-info/RECORD,,