xnatqa 0.0.19__py3-none-any.whl → 0.0.21__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/tag/__init__.py CHANGED
@@ -11,7 +11,7 @@ def extract_bids_suffix(bids_string):
11
11
  bids_suffix = match.group(1)
12
12
  return bids_suffix
13
13
 
14
- def generate_tagger_config(dicom_dir):
14
+ def generate_tagger_config(dicom_dir, working_dir):
15
15
 
16
16
  # This calls the latest version of dcm2niix WITHOUT creating the *.nii.gz files, only the BIDS metadata *.json sidecars.
17
17
  # dcm2niix automatically skips scans that it has identified as being non-BIDS (i.e., localizers, scouts)
@@ -19,10 +19,10 @@ 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} &>>log.txt")
22
+ os.system(f"dcm2niix -s y -a y -b o -o {working_dir} -f 'output_%s_%d' -w 0 -m 1 -i y {dicom_dir} &>>{working_dir}/log.txt")
23
23
 
24
24
  # idenfity all of these text files
25
- jsonFiles = glob(os.path.abspath('./output*.json'))
25
+ jsonFiles = glob(f'{working_dir}/output*.json')
26
26
 
27
27
  # sort the found files so that they are in decensing order by series_number
28
28
  # this is probably unnecssary
@@ -177,23 +177,27 @@ def generate_tagger_config(dicom_dir):
177
177
  continue
178
178
 
179
179
  # write tagger data to a yaml file. used by the xnattagger package for uploading tags to XNAT. See github.com/harvard-nrg/xnattager
180
- with open('tagger.yaml', 'a') as file:
180
+ with open(f'{working_dir}/tagger.yaml', 'a') as file:
181
181
  yaml.dump(tagger_data, file)
182
182
 
183
- def update_xnat_tags(MRsession):
183
+ def update_xnat_tags(MRsession, working_dir):
184
184
 
185
- # make sure an xnat authentication files has already been created. See YXAIL documentation.
185
+ # make sure an xnat authentication files has already been created. See YAXIL documentation.
186
186
  assert os.path.exists(os.path.expanduser('~/.xnat_auth')), 'xnat authentication needs to be run'
187
187
 
188
188
  # run the command
189
- os.system(f'xnat_tagger.py --label {MRsession} --target-modality all --xnat-alias xnat --config tagger.yaml')
189
+ os.system(f'xnat_tagger.py --label {MRsession} --target-modality all --xnat-alias xnat --config {working_dir}/tagger.yaml')
190
190
 
191
- def tag_scans(dicom_dir, MRsession, dryrun):
191
+ def tag_scans(dicom_dir, MRsession, working_dir, dryrun):
192
192
 
193
+ this_session_working_dir=os.path.join(working_dir, MRsession)
194
+
195
+ os.mkdir(this_session_working_dir)
196
+
193
197
  # generate the xnattag config file
194
- generate_tagger_config(dicom_dir)
198
+ generate_tagger_config(dicom_dir, this_session_working_dir)
195
199
 
196
200
  # update the xnat tags
197
201
  if not dryrun:
198
- update_xnat_tags(MRsession)
202
+ update_xnat_tags(MRsession, this_session_working_dir)
199
203
 
xnatqa/xnatqa.py CHANGED
@@ -8,15 +8,17 @@ 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("--working_dir", default = '/tmp', help="Where should intermediate files get written?")
11
12
  parser.add_argument("--dryrun", default = "", action='store_true', help="Run in dry run mode: No upload to XNAT")
12
13
 
13
14
  args, unknown_args = parser.parse_known_args()
14
- dicom_dir = os.path.join(args.dicom_dir)
15
- experiment = args.experiment
16
- dryrun = args.dryrun
15
+ dicom_dir = os.path.join(args.dicom_dir)
16
+ experiment = args.experiment
17
+ working_dir = args.working_dir
18
+ dryrun = args.dryrun
17
19
 
18
20
  # tag all scans in this session
19
- tag_scans(dicom_dir, experiment, dryrun)
21
+ tag_scans(dicom_dir, experiment, working_dir, dryrun)
20
22
 
21
23
  if __name__ == "__main__":
22
24
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xnatqa
3
- Version: 0.0.19
3
+ Version: 0.0.21
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=QWqLdwfbq28cmeJd4XQcV2wxs2ZGRX85uzFmxHydmfg,1963
3
+ xnatqa/xnatqa.py,sha256=PEAe3LGFKZ2KSVO4Bd5vAGuMeaFkXCg5GVY1sCr8K-E,915
4
+ xnatqa/tag/__init__.py,sha256=Yioqr-MPvxVtiWT3r1CPwz1UXnV0253owG57QaF2D2k,9215
5
+ xnatqa-0.0.21.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ xnatqa-0.0.21.dist-info/METADATA,sha256=8ZyM8p0vuknR0buL1RJ3QZKJmdFBjEtcLMJAH11bmjk,1187
7
+ xnatqa-0.0.21.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
8
+ xnatqa-0.0.21.dist-info/entry_points.txt,sha256=g5CvKDfx6vIIp76wdB1aiWe1SkBORj2S8gFReBBxBws,74
9
+ xnatqa-0.0.21.dist-info/top_level.txt,sha256=FmRWgO6ww0FwyNs5ccyhP9FcAxI129qSJqLs2OKOxJw,7
10
+ xnatqa-0.0.21.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- xnatqa/__init__.py,sha256=RIG_ihjfFD1upKlhlxI-9Fs4ISf0lIW4Zg7CaFirV4A,644
2
- xnatqa/launch.py,sha256=QWqLdwfbq28cmeJd4XQcV2wxs2ZGRX85uzFmxHydmfg,1963
3
- xnatqa/xnatqa.py,sha256=lWNFbtJPvM-0DuUV3pjL_xfPnBxEZqGK8PIdlBaxJWE,748
4
- xnatqa/tag/__init__.py,sha256=wXPBIbHucCqITYVZ4V5bt3VJWq8svyrJoBjbrpH1bNE,8969
5
- xnatqa-0.0.19.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- xnatqa-0.0.19.dist-info/METADATA,sha256=Ze37T8xBNT1oigywvb7XA-b1nvUe6DDJeRewPXHcrj0,1187
7
- xnatqa-0.0.19.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
8
- xnatqa-0.0.19.dist-info/entry_points.txt,sha256=g5CvKDfx6vIIp76wdB1aiWe1SkBORj2S8gFReBBxBws,74
9
- xnatqa-0.0.19.dist-info/top_level.txt,sha256=FmRWgO6ww0FwyNs5ccyhP9FcAxI129qSJqLs2OKOxJw,7
10
- xnatqa-0.0.19.dist-info/RECORD,,