xnatqa 0.0.15__tar.gz → 0.0.17__tar.gz
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-0.0.15/xnatqa.egg-info → xnatqa-0.0.17}/PKG-INFO +1 -1
- {xnatqa-0.0.15 → xnatqa-0.0.17}/pyproject.toml +2 -1
- xnatqa-0.0.17/xnatqa/launch.py +50 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/xnatqa/tag/__init__.py +4 -5
- {xnatqa-0.0.15 → xnatqa-0.0.17}/xnatqa/xnatqa.py +3 -1
- {xnatqa-0.0.15 → xnatqa-0.0.17/xnatqa.egg-info}/PKG-INFO +1 -1
- {xnatqa-0.0.15 → xnatqa-0.0.17}/xnatqa.egg-info/SOURCES.txt +1 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/xnatqa.egg-info/entry_points.txt +1 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/LICENSE +0 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/README.md +0 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/setup.cfg +0 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/xnatqa/__init__.py +0 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/xnatqa.egg-info/dependency_links.txt +0 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/xnatqa.egg-info/requires.txt +0 -0
- {xnatqa-0.0.15 → xnatqa-0.0.17}/xnatqa.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "xnatqa"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.17"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name="Kyle Kurkela", email="kkurkela@bu.edu" },
|
|
6
6
|
]
|
|
@@ -22,6 +22,7 @@ dependencies = [
|
|
|
22
22
|
|
|
23
23
|
[project.scripts]
|
|
24
24
|
xnatqa = "xnatqa.xnatqa:main"
|
|
25
|
+
launch = "xnatqa.launch:main"
|
|
25
26
|
|
|
26
27
|
[project.urls]
|
|
27
28
|
Homepage = "https://github.com/kakurk/auto_labeler"
|
|
@@ -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
|
|
@@ -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
|
-
|
|
197
|
+
if not dryrun:
|
|
198
|
+
update_xnat_tags(MRsession)
|
|
200
199
|
|
|
@@ -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()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|