Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XNAT-Group
XNAT_Query_Client_XSA
Commits
c5006e1a
Commit
c5006e1a
authored
Dec 12, 2014
by
Franziska Koehn
Browse files
now, result-table shows requested fields
parent
26d01fdf
Changes
5
Hide whitespace changes
Inline
Side-by-side
datatypes/xnat_mrScanData.js
View file @
c5006e1a
...
...
@@ -13,6 +13,6 @@
{
"
label
"
:
"
Project-ID
"
,
"
field
"
:
"
xnat:mrSessionData/PROJECT
"
,
"
required
"
:
true
},
{
"
label
"
:
"
Subject-ID
"
,
"
field
"
:
"
xnat:mrSessionData/SUBJECT_ID
"
,
"
required
"
:
true
},
{
"
label
"
:
"
Session-ID
"
,
"
field
"
:
"
xnat:mrSessionData/SESSION_ID
"
,
"
required
"
:
true
},
{
"
label
"
:
"
Scan-ID
"
,
"
field
"
:
"
xnat:mrScanData/ID
"
,
"
required
"
:
true
}
{
"
label
"
:
"
Scan-ID
"
,
"
field
"
:
"
xnat:mrScanData/ID
"
,
"
required
"
:
true
,
"
key
"
:
"
id
"
}
]
}
xnat_search.py
View file @
c5006e1a
...
...
@@ -90,6 +90,13 @@ def get_fields_of_type(type):
except
ValueError
:
pass
def
get_field_label
(
type
,
key
):
fields
=
get_fields_of_type
(
type
)
for
f
in
fields
:
if
"key"
in
f
and
f
[
"key"
]
==
key
:
return
f
[
"label"
]
return
key
def
get_fields_from_labels
(
labels
,
type
):
result
=
[]
fields
=
get_fields_of_type
(
type
)
...
...
@@ -101,20 +108,6 @@ def get_fields_from_labels(labels, type):
break
return
result
def
get_search_fields
():
import
json
return
json
.
loads
(
"""[{"label":"type", "field":"xnat:mrScanData/TYPE"},
{"label":"fov_x", "field":"xnat:mrScanData/PARAMETERS_FOV_X"},
{"label":"fov_y", "field":"xnat:mrScanData/PARAMETERS_FOV_Y"},
{"label":"tr", "field": "xnat:mrScanData/PARAMETERS_TR"},
{"label":"te", "field": "xnat:mrScanData/PARAMETERS_TE"},
{"label":"ti", "field": "xnat:mrScanData/PARAMETERS_TI"},
{"label":"flip", "field": "xnat:mrScanData/PARAMETERS_FLIP"},
{"label":"voxel_res_x", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_X"},
{"label":"voxel_res_y", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_Y"},
{"label":"voxel_res_z", "field":"xnat:mrScanData/PARAMETERS_VOXELRES_Z"}
]"""
)
def
get_query_methods
():
return
[
"AND"
,
"OR"
]
...
...
xnat_search_gui.py
View file @
c5006e1a
...
...
@@ -63,7 +63,7 @@ class XnatSearchApp(gtk.Window):
else
:
self
.
results
=
query_results
self
.
vbox_results
.
show_data
(
self
.
results
)
self
.
vbox_results
.
show_data
(
self
.
results
,
root_type
)
self
.
statusbar
.
push
(
0
,
"%s Results"
%
len
(
self
.
results
))
self
.
chart_view
.
update_chart
(
self
.
results
)
...
...
xnatgtk/query_view.py
View file @
c5006e1a
...
...
@@ -21,7 +21,7 @@ class QueryView(gtk.VBox):
self
.
entry_host
.
set_text
(
new_host
)
def
__send_query
(
self
):
self
.
emit
(
"send-query"
,
self
.
host
,
self
.
credentials
,
self
.
combobox
.
get_selected_item
(),
self
.
treeView_search
.
get_query
(),
self
.
treeView_fields
.
get_selected_fields
())
self
.
emit
(
"send-query"
,
self
.
host
,
self
.
credentials
,
self
.
combobox
.
get_selected_item
(),
self
.
treeView_search
.
get_query
(
self
.
combobox
.
get_selected_item
()
),
self
.
treeView_fields
.
get_selected_fields
())
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
QueryView
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -350,10 +350,10 @@ class TreeViewQuery(gtk.TreeView):
import
xnat_search
self
.
operators
=
xnat_search
.
get_operators
()
def
get_query
(
self
):
def
get_query
(
self
,
type
):
import
xnat_search
search_fields
=
xnat_search
.
get_
search_fields
(
)
search_fields
=
xnat_search
.
get_
fields_of_type
(
type
)
query
=
[]
def
add_next_to_querry
(
iter
):
...
...
xnatgtk/results_view.py
View file @
c5006e1a
...
...
@@ -2,8 +2,8 @@ import gtk
class
ResultsDownloadView
(
gtk
.
VBox
):
def
show_data
(
self
,
results
):
self
.
treeViewResults
.
show_data
(
results
)
def
show_data
(
self
,
results
,
root_type
):
self
.
treeViewResults
.
show_data
(
results
,
root_type
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
ResultsDownloadView
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -19,20 +19,17 @@ class ResultsDownloadView(gtk.VBox):
buttonBox_download
=
gtk
.
HButtonBox
()
self
.
pack_end
(
buttonBox_download
,
expand
=
False
,
fill
=
False
)
results_tree_view_store
=
self
.
treeViewResults
.
store
def
event_clicked_download
(
button
,
*
_
):
import
gobject
import
xnat_search
enabled
=
(
d
for
d
in
results_
tree
_v
iew
_
store
if
d
[
0
])
enabled
=
(
d
for
d
in
self
.
tree
V
iew
Results
.
store
if
d
[
0
])
for
d
in
enabled
:
def
stop_spinner
(
_row
):
_row
[
7
]
=
False
# Hide spinner
_row
[
2
]
=
False
# Hide spinner
_row
[
0
]
=
False
# Checkbox to false
d
[
8
]
=
0
d
[
7
]
=
True
# Show Spinner
xnat_search
.
download_async
(
d
[
6
],
button
.
destination
,
cb
=
stop_spinner
,
cb_args
=
(
d
,))
d
[
3
]
=
0
d
[
2
]
=
True
# Show Spinner
xnat_search
.
download_async
(
d
[
1
],
button
.
destination
,
cb
=
stop_spinner
,
cb_args
=
(
d
,))
def
event_clicked_toggle_selection
(
*
_
):
self
.
treeViewResults
.
toggle_selection
()
...
...
@@ -73,23 +70,26 @@ class ButtonDownloadResults(gtk.Button):
class
TreeViewResults
(
gtk
.
TreeView
):
store
=
[]
def
__init__
(
self
):
import
gobject
super
(
TreeViewResults
,
self
).
__init__
()
self
.
create_columns
()
self
.
store
=
gtk
.
ListStore
(
bool
,
str
,
str
,
str
,
str
,
str
,
gobject
.
TYPE_PYOBJECT
,
bool
,
int
)
self
.
set_model
(
self
.
store
)
self
.
show_data
([],
None
)
gobject
.
timeout_add
(
150
,
self
.
move_spinners
)
def
move_spinners
(
self
):
for
r
in
self
.
store
:
if
r
[
7
]:
# if spinner is visible
r
[
8
]
+=
1
if
r
[
2
]:
# if spinner is visible
r
[
3
]
+=
1
return
True
def
create_columns
(
self
):
def
create_columns
(
self
,
column_labels
):
for
c
in
self
.
get_columns
():
self
.
remove_column
(
c
)
def
callback_toggled
(
cellrenderertoggle
,
path_string
,
col
,
*
_
):
it
=
self
.
store
.
get_iter_from_string
(
path_string
)
...
...
@@ -106,48 +106,50 @@ class TreeViewResults(gtk.TreeView):
self
.
append_column
(
column
)
renderer
=
gtk
.
CellRendererSpinner
()
column
=
gtk
.
TreeViewColumn
(
""
,
renderer
,
active
=
7
,
pulse
=
8
)
column
=
gtk
.
TreeViewColumn
(
""
,
renderer
,
active
=
2
,
pulse
=
3
)
self
.
append_column
(
column
)
column
=
gtk
.
TreeViewColumn
(
"Project-ID"
,
gtk
.
CellRendererText
(),
text
=
1
)
column
.
set_sort_column_id
(
1
)
column
.
set_resizable
(
True
)
self
.
append_column
(
column
)
for
i
,
cl
in
enumerate
(
column_labels
,
start
=
4
):
column
=
gtk
.
TreeViewColumn
(
cl
,
gtk
.
CellRendererText
(),
text
=
i
)
column
.
set_sort_column_id
(
i
)
column
.
set_resizable
(
True
)
self
.
append_column
(
column
)
column
=
gtk
.
TreeViewColumn
(
"Subject-ID"
,
gtk
.
CellRendererText
(),
text
=
2
)
column
.
set_sort_column_id
(
2
)
column
.
set_resizable
(
True
)
self
.
append_column
(
column
)
def
toggle_selection
(
self
):
for
row
in
self
.
store
:
row
[
0
]
=
not
row
[
0
]
column
=
gtk
.
TreeViewColumn
(
"Session-ID"
,
gtk
.
CellRendererText
(),
text
=
3
)
column
.
set_sort_column_id
(
3
)
column
.
set_resizable
(
True
)
self
.
append_column
(
column
)
def
show_data
(
self
,
data
,
root_type
):
import
gobject
if
data
==
[]:
self
.
create_columns
([])
return
column
=
gtk
.
TreeViewColumn
(
"Scan-ID"
,
gtk
.
CellRendererText
(),
text
=
4
)
column
.
set_sort_column_id
(
4
)
column
.
set_resizable
(
True
)
self
.
append_column
(
column
)
column
=
gtk
.
TreeViewColumn
(
"Scan-Type"
,
gtk
.
CellRendererText
(),
text
=
5
)
column
.
set_sort_column_id
(
5
)
column
.
set_resizable
(
True
)
self
.
append_column
(
column
)
keys
=
data
.
headers
()
def
toggle_selection
(
self
):
for
row
in
self
.
store
:
row
[
0
]
=
not
row
[
0
]
model_columns
=
[]
model_columns
.
append
(
bool
)
# 0 is selected (for download selection)
model_columns
.
append
(
gobject
.
TYPE_PYOBJECT
)
# 1 query result
model_columns
.
append
(
bool
)
# 2 is spinner visible
model_columns
.
append
(
int
)
# 3 spinner pulse
for
k
in
keys
:
model_columns
.
append
(
str
)
self
.
store
=
gtk
.
ListStore
(
*
model_columns
)
def
show_data
(
self
,
data
):
self
.
store
.
clear
()
for
d
in
data
:
self
.
store
.
append
(
[
True
,
d
[
'xnat_mrsessiondata_project'
],
d
[
'xnat_mrsessiondata_subject_id'
],
d
[
'xnat_mrsessiondata_session_id'
],
d
[
'id'
],
d
[
'type'
],
d
,
False
,
0
])
result
=
[]
result
.
append
(
True
)
result
.
append
(
d
)
result
.
append
(
False
)
result
.
append
(
0
)
for
k
in
keys
:
result
.
append
(
d
[
k
])
self
.
store
.
append
(
result
)
import
xnat_search
keys_
=
list
(
xnat_search
.
get_field_label
(
root_type
,
key
)
for
key
in
keys
)
self
.
create_columns
(
keys_
)
# TODO labels
self
.
set_model
(
self
.
store
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment