@@ -28,6 +28,10 @@ def __init__(self, proj_code, stormdblogin='~/.stormdblogin', username=None, ver
28
28
print 'ERROR: Bad project code?'
29
29
sysexit (- 1 )
30
30
31
+ self .proj_code = proj_code
32
+ self ._server = 'http://hyades00.pet.auh.dk/modules/StormDb/extract/'
33
+ self ._wget_cmd = 'wget -qO - test ' + self ._server
34
+
31
35
try :
32
36
with open (os .path .expanduser (stormdblogin )):
33
37
if verbose :
@@ -56,10 +60,6 @@ def __init__(self, proj_code, stormdblogin='~/.stormdblogin', username=None, ver
56
60
fout .close ()
57
61
os .chmod (os .path .expanduser (stormdblogin ), 0400 )
58
62
59
- self .proj_code = proj_code
60
- self ._server = 'http://hyades00.pet.auh.dk/modules/StormDb/extract/'
61
- self ._wget_cmd = 'wget -qO - test ' + self ._server
62
-
63
63
@staticmethod
64
64
def _wget_error_handling (stdout ):
65
65
if 'error' in stdout :
@@ -120,32 +120,40 @@ def get_studies(self, subj_id, modality=None, unique=True, verbose=False):
120
120
stud_list = [x for x in stud_list if x ]
121
121
122
122
if modality :
123
- for study in stud_list :
123
+ for ii , study in enumerate ( stud_list ) :
124
124
url = 'modalities?' + self ._login_code + '\\ &projectCode=' + self .proj_code + '\\ &subjectNo=' + \
125
125
subj_id + '\\ &study=' + study
126
126
output = self ._wget_system_call (url ).split ('\n ' )
127
127
#print output, '==', modality
128
128
129
- for entry in output :
130
- if entry == modality :
131
- if unique :
132
- return study
133
- ### NB!! This only matches first hit! If subject contains several studies
134
- ### with this modality,
135
- ### only first one is returned... Fix me!
136
- else :
137
- # must re-write code a bit to accommodate the existence of
138
- # several studies containing the desired modality...
139
- print "Error: non-unique modalities not implemented yet!"
140
- sysexit (- 1 )
129
+ if modality in output :
130
+ if unique :
131
+ return study # NB: returns string! Should change to [study] to return list...
132
+ else :
133
+ stud_list [ii ] = None
134
+
135
+ stud_list = filter (None , stud_list )
136
+ # for entry in output:
137
+ # if entry == modality:
138
+ # if unique:
139
+ # return study
140
+ # ### NB!! This only matches first hit! If subject contains several studies
141
+ # ### with this modality,
142
+ # ### only first one is returned... Fix me!
143
+ # else:
144
+ # stud_list = [x for x in stud_list if x
145
+ # else:
146
+ # # must re-write code a bit to accommodate the existence of
147
+ # # several studies containing the desired modality...
148
+ # print "Error: non-unique modalities not implemented yet!"
149
+ # sysexit(-1)
141
150
142
151
# If we get this far, no studies found with the desired modality
143
152
if verbose :
144
153
print "No studies found with the desired modality"
145
- return None
154
+ return None
146
155
147
- else :
148
- return stud_list
156
+ return stud_list
149
157
150
158
def get_series (self , subj_id , study , modality , verbose = False ):
151
159
0 commit comments