xnatqa 0.0.18__py3-none-any.whl → 0.0.20__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 +12 -10
- xnatqa/xnatqa.py +6 -4
- {xnatqa-0.0.18.dist-info → xnatqa-0.0.20.dist-info}/METADATA +1 -1
- xnatqa-0.0.20.dist-info/RECORD +10 -0
- xnatqa-0.0.18.dist-info/RECORD +0 -10
- {xnatqa-0.0.18.dist-info → xnatqa-0.0.20.dist-info}/WHEEL +0 -0
- {xnatqa-0.0.18.dist-info → xnatqa-0.0.20.dist-info}/entry_points.txt +0 -0
- {xnatqa-0.0.18.dist-info → xnatqa-0.0.20.dist-info}/licenses/LICENSE +0 -0
- {xnatqa-0.0.18.dist-info → xnatqa-0.0.20.dist-info}/top_level.txt +0 -0
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
|
|
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(
|
|
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,25 @@ 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
|
|
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
|
+
|
|
193
195
|
# generate the xnattag config file
|
|
194
|
-
generate_tagger_config(dicom_dir)
|
|
196
|
+
generate_tagger_config(dicom_dir, this_session_working_dir)
|
|
195
197
|
|
|
196
198
|
# update the xnat tags
|
|
197
199
|
if not dryrun:
|
|
198
|
-
update_xnat_tags(MRsession)
|
|
200
|
+
update_xnat_tags(MRsession, this_session_working_dir)
|
|
199
201
|
|
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
|
|
15
|
-
experiment
|
|
16
|
-
|
|
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()
|
|
@@ -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=dmreB5C3_GqL6v3JIfUai59NeUtBQy6xSTb2UilcREM,9175
|
|
5
|
+
xnatqa-0.0.20.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
xnatqa-0.0.20.dist-info/METADATA,sha256=TVvwxvUXdB2mQSGJlCGEctq_BtjA30mqomn1jn1Kwa4,1187
|
|
7
|
+
xnatqa-0.0.20.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
8
|
+
xnatqa-0.0.20.dist-info/entry_points.txt,sha256=g5CvKDfx6vIIp76wdB1aiWe1SkBORj2S8gFReBBxBws,74
|
|
9
|
+
xnatqa-0.0.20.dist-info/top_level.txt,sha256=FmRWgO6ww0FwyNs5ccyhP9FcAxI129qSJqLs2OKOxJw,7
|
|
10
|
+
xnatqa-0.0.20.dist-info/RECORD,,
|
xnatqa-0.0.18.dist-info/RECORD
DELETED
|
@@ -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=Ld6ARbw3czfRWKqubOdRW4VMBOCuONTr7uxjCbBPLrg,757
|
|
4
|
-
xnatqa/tag/__init__.py,sha256=wXPBIbHucCqITYVZ4V5bt3VJWq8svyrJoBjbrpH1bNE,8969
|
|
5
|
-
xnatqa-0.0.18.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
xnatqa-0.0.18.dist-info/METADATA,sha256=YSR_e--Cs6nA5kOykqS50e7fdaR76ClMFAYiM3GPteY,1187
|
|
7
|
-
xnatqa-0.0.18.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
8
|
-
xnatqa-0.0.18.dist-info/entry_points.txt,sha256=g5CvKDfx6vIIp76wdB1aiWe1SkBORj2S8gFReBBxBws,74
|
|
9
|
-
xnatqa-0.0.18.dist-info/top_level.txt,sha256=FmRWgO6ww0FwyNs5ccyhP9FcAxI129qSJqLs2OKOxJw,7
|
|
10
|
-
xnatqa-0.0.18.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|