Last active
May 16, 2017 15:09
-
-
Save mattsouth/b10e8250138d67d9aae6b586aa5c9873 to your computer and use it in GitHub Desktop.
Prints the subject_id and experiment_id of XNAT experiments whose scans are all missing snapshots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prints the subject_id and experiment_id of XNAT experiments whose scans are all missing snapshots | |
# used against XNAT 1.6.5 by python 2.7 | |
import xnat # see https://xnat.readthedocs.io/en/latest/ | |
url = raw_input("Enter XNAT url: ") | |
user = raw_input("Enter username: ") | |
session = xnat.connect(url, user=user) | |
name = raw_input("Enter project: ") | |
project = session.projects[name] | |
print 'subject, session' | |
for subject_id in project.subjects.keys(): | |
for experiment_id in project.subjects[subject_id].experiments.keys(): | |
has_snapshots = False | |
for scan_id in project.subjects[subject_id].experiments[experiment_id].scans.keys(): | |
for resource_id in project.subjects[subject_id].experiments[experiment_id].scans[scan_id].resources.keys(): | |
resource = project.subjects[subject_id].experiments[experiment_id].scans[scan_id].resources[resource_id] | |
if resource.label=='SNAPSHOTS' and len(resource.files)>0: | |
has_snapshots = True | |
break | |
if has_snapshots: | |
break | |
if has_snapshots==False: | |
print '{}, {}'.format(subject_id, experiment_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment